English 中文(简体)
Subsequent weighted algorithm for comparison
原标题:
  • 时间:2009-11-08 15:16:55
  •  标签:
  • math
  • algebra

I have two rows of numbers ...

1) 2 2 1 0 0 1

2) 1.5 1 0 .5 1 2

Each column is compared to each other. Lower values are better. For example Column 1, row 2 s value (1.5) is more accurate than row 1 (2)

In normal comparison I would take to the sum of each row and compare to the other row to find the lowest sum (most accurate). In this case both would be equal.

I want to create two other comparison methods When values ascend from column 1 they should be weighted more (col 2 should hold more weight than 1, 3 than 2 and so on)

Also the opposite

Originally I thought it would be best to divide the value by its position but that doesn t work correctly.

What would be the best way to do this for a row?

Thanks!

最佳回答

So all you re really doing is computing the product of your matrix with a weighting vector. See this page for more info on matrix multiplication.

I.e. your vector M is

M = | 2.0 2.0 1.0 0.0 0.0 1.0 |
    | 1.5 1.0 0.0 0.5 1.0 2.0 |

and in your first case the weighting vector w is:

w = (1, 1, 1, 1, 1, 1)

the product of which gives you:

M x w = (6, 6)

which are the two scores for the two rows.

For an ascending weighting use something like :

w = (1, 2, 3, 4, 5, 6)

which gives you:

M x w = (15, 22.5)

and for a descending weight you could use either:

w = (6, 5, 4, 3, 2, 1)

or

w = (1, 1/2, 1/3, 1/4, 1/5, 1/6)

(Note vectors are transposed for readability).

问题回答

Originally, all values have the same weight, so your factors for n values are all 1/n, so your sum is:

S = 1 * v_1 + 1 * v_2 + ... + 1 * v_n

Your try to divide the value by its position would be:

S = 1/1 * v_1 + 1/2 * v_2 + ... + 1/n * v_n

Which is still a valid approach, but does the opposite of what you want (column 1 gets most weight).

What you want is something like this:

S = 1/n * v_1 + 1/n-1 * v_2 + ... + 1/1 * v_n

You might also consider to start with 1/n+1 and end with 1/2 so the last value will be a bit less important.

I don t know if I have understood what you wanna do, but maybe it s this:

for (i=0, i<length, i++)
  difference += (a[i] - b[i]) * w[i];

w[] would be an array with the weights by column (e.g.: w={1,2,3,4,5}), although could well be any other value/function.

So in the end, if difference is higher than 0, a[] is better, and if it s lower than 0 is worse.





相关问题
Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: subsubsection{The expectation of (X^2)} Causes an error in the file that contains the ...

Math Overflow -- Handling Large Numbers

I am having a problem handling large numbers. I need to calculate the log of a very large number. The number is the product of a series of numbers. For example: log(2x3x66x435x444) though my actual ...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Subsequent weighted algorithm for comparison

I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2 s value (1.5) is more ...

热门标签