0
$\begingroup$

I'm creating an algorithm that needs to be flexible on calculating the percentage of matches when comparing two range of numbers in order to give more weight to the external numbers of the range when they match, or more weight to the internal number when they match. What will determine which positions should receive more weight will be a parameter. Let me exemplify: enter image description here On both examples, we have the first 2 items in a range of 7 with a match, and the last 2 as well. With a normal percentage calculation, we have 4 matches out of 7 itens, which generates a 57.14%. On the example on the left, I gave more weight to the outer itens, and I generated a Factor with the help of this post ("Normalize" values to sum 1 but keeping their weights), and I generated a weighted factor of 77,27%. On the example on the right, I have more weight to the inner itens, and I generated a weighted factor of 22,27%. All that is fine and working.
My problem is generating the Weight column. Imagine I have a range of 0 to 100; when it is 50, the weight will be 1 on all rows; when it is 100, the weight of the outer will the the maximum and the inner with be 0, and when the parameter is 0, the inner with be maximum and the outer will be 0. I would like some help on creating a formula that would read this parameter, considering a varying number of rows in the range, and generated the weight. It would be similar to a parabola, with the number of itens on the range is the X, and if the parameter is 50, I would generate a flat Y. The closer it gets to 100, the steeper the parabola would be, point upwards, like this: enter image description here The closer it gets to 0, the steeper the parabola, but downwards. How can I achieve this objective? Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

The wording of your problem statement is very confusing so I may be interpreting it incorrectly. It sounds to me like you want a simple formula like:

$y = (p-50)x^2+1$,

where $p$ is your parameter ($p \in [0,100])$.

$\endgroup$
2
  • 1
    $\begingroup$ Sorry about the wording. Not a mathematician. Worked like a charm! Tks $\endgroup$
    – Pascal
    Commented Dec 20, 2016 at 16:59
  • $\begingroup$ Not a problem, just wanted to make sure I understood you properly. $\endgroup$
    – David
    Commented Dec 20, 2016 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .