Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could just give it a weighted score when ranking results, as opposed to just displaying the average vote so far, by multiplying with some function of the number of votes.</p> <p>An example in C# (because that's what <em>I</em> happen to know best...) that could easily be translated into your language of choice:</p> <pre><code>double avgScore = Math.Round(sum / n); double rank = avgScore * Math.Log(n); </code></pre> <p>Here I've used the logarithm of <code>n</code> as the weighting function - but it will only work well if the number of votes is neither too small or too large. Exactly how large is "optimal" depends on how much you want the number of votes to matter.</p> <p>If you like the logarithmic approach, but base <code>10</code> doesn't really work with your vote counts, you could easily use another base. For example, to do it in base <code>3</code> instead:</p> <pre><code>double rank = avgScore * Math.Log(n, 3); </code></pre> <p>Which function you should use for weighing is probably best decided by the order of magnitude of the number of votes you expect to reach. </p> <p>You could also use a custom weighting function by defining</p> <pre><code>double rank = avgScore * w(n); </code></pre> <p>where <code>w(n)</code> returns the weight value depending on the number of votes. You then define <code>w(n)</code> as you wish, for example like this:</p> <pre><code>double w(int n) { // caution! ugly example code ahead... // if you even want this approach, at least use a switch... :P if (n &gt; 100) { return 10; } else if (n &gt; 50) { return 8; } else if (n &gt; 40) { return 6; } else if (n &gt; 20) { return 3; } else if (n &gt; 10) { return 2; } else { return 1; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload