Note that there are some explanatory texts on larger screens.

plurals
  1. POAlgorithm for probability over 100%
    primarykey
    data
    text
    <p>I am in need of an algorithm (in Java, but the theory should be pretty general) for some sort of probability... thing. I don't even know what to call it, which is why I haven't had any luck Googling.</p> <p>To describe a bit better, I have a task that needs to be done X number of times when a function is called. Sometimes, there's only a 1 in 10 chance of that happening, meaning that (approximately) one out of every ten times that function is called that task will actually be performed - easy enough to do with random(). Sometimes it will be 2 in 10, or maybe even 10 in 10. Still easy enough, straightforward conditional, even if it's not always "X in 10"</p> <p>The problem is, it can have <em>greater</em> than a 1 in 1 chance. It may be 15 in 10 - half the time it runs once, the rest it runs <em>twice</em>. Or 10 in 5, where it runs twice (approximately) every time called. As you can see, this has now ventured out of simple inequality testing.</p> <p>So, what I'm looking for is some algorithm that, based on random numbers, will return a run <em>count</em> based on how frequently (1 in 10, 200%, 0.75, whatever format works) something ought to happen. If anyone can provide any leads on this - like, maybe an actual term to search for - it'd be much appreciated!</p> <p>EDIT: No wonder I can't find many results, everyone's as confused as I am!</p> <p>First and foremost, no real "maximum" value. Not formally defined. If the algorithm can extract that from the probability value it receives, that's great.</p> <p>It also definitely needs to be random, making it inherently imperfect. If you flip a coin 10 times, you may very well end up with 8 heads, even though it theoretically ought to be perfectly even! And that's alright. In fact, it's the point.</p> <p>I could tell you <em>why</em> I need it... but that would be in violation of proper object-oriented modularity practices :) External parties need only know the interface; it accepts a value (probably a float, "0.75" seems like it would work best) and returns an int. If you call it 100 times, with a probability of 1 in 5, the sum of its returned values should average out to 20.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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