Hi:
Anyone who has run a Links SQL site for long has probably seen this... only long-standing sites get a fair shake at rating high. Well, one of my users just sent me a different formula than the simple average approach that Alex has in Links... and I thought it would be worth posting here for others to share in... well, that, and I want some help writting the code to impliment it!
It is called the Bayesian Estimate, and the formula goes like this:
weighted rank (WR) = (v ÷ (v+m)) × R + (m ÷ (v+m)) × C
where:
R = average for the link
v = number of votes for the link
m = minimum votes required to be listed in the top ranking
C = the mean vote across the whole report
Basically, pretty easy. Except I am not sure how to get the "C" component, the mean vote. I know I can do:
my $rows = $db->count ( { Votes } );
to get the total number of votes, but I am not sure how to get the total sum of all the votes... call that $sum.
$sum / $rows would equal C, right?...
So:
$rec->{Rating} = ($rec->{Votes} / ($rec->{Votes} / 10)) * $rec->{Rating} + (10 / ($rec->{Votes} + 10)) x ($sum / $rows );
right? So how do I get $sum?
Thanks!
dave
Big Cartoon DataBase
Big Comic Book DataBase
Anyone who has run a Links SQL site for long has probably seen this... only long-standing sites get a fair shake at rating high. Well, one of my users just sent me a different formula than the simple average approach that Alex has in Links... and I thought it would be worth posting here for others to share in... well, that, and I want some help writting the code to impliment it!
It is called the Bayesian Estimate, and the formula goes like this:
weighted rank (WR) = (v ÷ (v+m)) × R + (m ÷ (v+m)) × C
where:
R = average for the link
v = number of votes for the link
m = minimum votes required to be listed in the top ranking
C = the mean vote across the whole report
Basically, pretty easy. Except I am not sure how to get the "C" component, the mean vote. I know I can do:
my $rows = $db->count ( { Votes } );
to get the total number of votes, but I am not sure how to get the total sum of all the votes... call that $sum.
$sum / $rows would equal C, right?...
So:
$rec->{Rating} = ($rec->{Votes} / ($rec->{Votes} / 10)) * $rec->{Rating} + (10 / ($rec->{Votes} + 10)) x ($sum / $rows );
right? So how do I get $sum?
Thanks!
dave
Big Cartoon DataBase
Big Comic Book DataBase