Jump to content

Determining if a user is being Generous or Ungenerous, based on vote-statistics.


NeoMarine

Recommended Posts

I hold two statistics in my database, one for "Thumbs Up" and one for "Thumbs Down". Based on the ratio of Thumbs up/down, I want to display a message to the user such as: "You are generous" (mostly thumbs up) or "You are ungenerous" (mostly thumbs down).

 

I have the following math done:

 

$thumbsCombinedTotal=$thumbsUpCount+$thumbsDownCount;
$thumbsUpPercentage=round(($thumbsUpCount/$thumbsCombinedTotal)*100,2);

 

However, if the user has thumbs up = 1, and thumbs down = 0 - this will generate a value of 100% so I would say "you are extremely generous". But what I really would like to say is, "you are generous", because they have only voted on 1 thing altogether.

 

Can you think of some more detailed math so I can determine a more accurate description of their "favor in the ratio" (ie. how generous they are actually being?)

 

I need some kind of gradual scale in the math, which means, the more COMBINED thumbsup+thumbsdown they have, the more it will influence the severity of their generousity/ungenerousity.

 

I hope I am clear enough. Thanks a lot to whoever can help me.

I would do something more like

 

if ($thumbsUpCount > thumbsDownCount) {
echo "You are generous.";
}
else {
echo "You are ungenerous.";
}

or for something even better

$generosity = $thumbsUpCount - $thumbsDownCount;
if ($generosity < -50) {
echo "You are very ungenerous.";
}
elseif ($generosity < 0) {
echo "You are ungenerous.";
}
elseif ($generosity < 20) {
echo "You are generous.";
}
elseif ($generosity > 21) {
echo "You are very generous.";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.