29512/generate-some-random-numbers-with-distribution-using-python

Here is one file with probabilities for different values. Let's say for example:

1 0.2 2 0.25 3 0.35 4 0.4 5 0.5 6 0.3

I would like to generate completely random numbers using the distribution. Is there an existing module that handles this?

scipy.stats.rv_discrete is what you ned IMHO.

You can supply your probabilities via the values parameter and it's really easy and you will figure it out. Also, you can then use the rvs() method to generate random numbers when needed too.

You can also pass a keyword parameter to numpy.random.choice(),

Consider the following example:

numpy.random.choice(numpy.arange(1, 7), p=[0.35, 0.27, 0.35, 0.43, 0.1, 0.12]

Use numpy in the following manner: np.random.rand(3,4)*100 When you ...READ MORE

Use random.uniform(a, b): Returns a random floating point ...READ MORE

Hi, it is pretty simple, to be ...READ MORE

Good question. I actually was stuck with ...READ MORE

$ to match the end of the ...READ MORE

suppose you have a string with a ...READ MORE

You can also use the random library's ...READ MORE

Syntax : list. count(value) Code: colors = ['red', 'green', ...READ MORE

Enumerate() method adds a counter to an ...READ MORE

It seems like you're using the wrong ...READ MORE

OR

At least 1 upper-case and 1 lower-case letter

Minimum 8 characters and Maximum 50 characters

Already have an account? Sign in.