
Generate a set of sample data from a distribution

Sandbo
Hi,
I know we can use gnoise(num) to generate a set of data with a Gaussian distribution;
similarly, is there an easy way to generate a set of data with an arbitrary distribution?
The above is my naive implementation. prCount is the arbitrary distribution. First, I multiply prCount (outside of this function) to make a large portion of it to be above 1. Then I am just stacking up terms according to the rounded number of the distribution.
December 10, 2018 at 10:36 am - Permalink
Hi,
What I was thinking is to integrate the initial prCounts function to create a pseudo-cumulative distribution function. I would normalize to 1 so the range of probability goes 0-1. I would then get a random value (0-1) from a uniform distribution(enoise(value)) and then do a search the pseudo-CDF to get a corresponding input value.
I mocked up an example and hopefully it aligns to your request.
Made a probability function, red, and note it is not normalized. These could be counts from a sensor or whatever. I then integrate that curve to create a cumulative distribution function and I have normalized it to 1. Now to get a random value from it you seed a uniformly seeded number fro enoise and input into a findlevel command to return a value based on your initial x value range. For example if I do a findlevel CDF, 0.3 it returns 70.7887.
Hopefully this makes sense and does it do what you need?
Andy
December 10, 2018 at 10:44 am - Permalink