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.

Link to comment
Share on other sites

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.";
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.