Hello!

I recently had a question here, I took the path of forming a new value based on the distribution of probability. Thank you very much @neofit!

The result was an interesting picture, very reminiscent of the long-normal distribution:

distribution http://upload.dexstudio.com.ua/botva2.jpg

Now, actually, the question is how to generate a number from this distribution? There are ready-made solutions, for example, for Java, which are able to make this distribution and produce value somewhere among this beauty?

  • There is such an article . - andrybak
  • @Andrey, I need to get not a new distribution, but only a new number from the original one. - Dex
  • @Dex, I recommend to pay attention to the quantile transformation : getting a random value of a given distribution from a uniform one. - AlexeyM 10:10
  • @AlexeyM, yes, I have already seen it, but did not figure out how to implement it. - Dex
  • @Dex, for example, on Wikipedia , a method is indicated: we simulate a normally distributed random variable X, then Y = Exp [X] is the desired quantity. - AlexeyM

2 answers 2

Example:
You need event 1 to occur with a 75% chance, event 2 with a 10% chance, event 3 with a 15% chance. Generate a random number from 0 to 99. If the number is in the range of 0-74, then event 1, 75-84 event 2, 85-99 event 3.
In your question all the same. The sum of the lengths of all stripes is the number 99 in the example. The length of each strip sets the hit interval.

  • Implemented, thank you, one more step has been taken. True, the instability of such an option does not quite suit me. I want something more stable, which does not just "pop up" randomly, but depends somewhat on the previous values. But here's how ... - Dex

We do this:

  1. If we consider that our set of experimental values ​​is similar to the lognormal distribution, then we take the function approximating the lognormal distribution — for example, this one (essentially Gauss with logarithms)
  2. Next, using the least squares method, we find 2 parameters of the lognormal distribution (in the classic, sigma sets the “thickness” and mu sets the position of the extremum)
  3. Then calmly substitute values ​​into the resulting function and the generator is ready.