Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerate Random Weighted value
    primarykey
    data
    text
    <p><strong>Edit:</strong> I've rewritten the question in hopes that the goal is a little clearer.</p> <p>This is an extended question to this question <a href="https://stackoverflow.com/questions/445235/generating-random-results-by-weight-in-php">here</a>, and I really like the function provided in <a href="https://stackoverflow.com/questions/445235/generating-random-results-by-weight-in-php/445363#445363">this answer</a>.</p> <p>In the answer above, one is able to set the probability of hitting an extreme, with higher numbers producing a higher probability of getting lower numbers and vice-versa. The issue is that I must set the probabilities for 3 groups. Those groups are Lowest Value (LV), Highest Value (HV), and Middle Value (MV). However, to simplify the request, we can consider <code>EVP=HVP=LVP</code>.</p> <p>Given <em>any</em> range, the HV/LV should appear based on the specified EVP and, as you progress/degress through the range from each extreme, the probability of the next value in the range will increase, or decrease, based on the distance between EVP and MVP.</p> <p>Using an example range of 1-6, with 1 and 6 being weighted at 5% (EVP), the probability spread would be 1/6 is 5%, 2/4 is 15%, and 3/4 is 30% (MVP), totalling 100%. The reverse should also be possible, swapping EVP and MVP should produce an inverse of the graph below.</p> <p>Here's an image that I hope will convey the results expected from the given example.</p> <p><strong>Middle weighted:</strong></p> <p><img src="https://i.stack.imgur.com/WHuK1.png" alt="Middle Weighted Graph"></p> <p><strong>Bonus:</strong> It would be most excellent if I was able to set HVP and LVP separately producing a result similar to the graph below (<em>Note: The graph is not accurate to specification above</em>).</p> <p><strong>Middle weighted (bonus):</strong></p> <p><img src="https://i.stack.imgur.com/WW3Em.png" alt="Middle Weighted Bonus Graph"></p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

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