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? Oct 31, 2018 in Python
edited Dec 14, 2018 142 views

## 1 answer to this question.

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]` answered Oct 31, 2018 by
• 2,070 points

edited Dec 14, 2018 by Anirudh

## How do I create 3 X 4 array of random numbers between 0 and 100 using python?

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

## How do I get a random number with a float range in python?

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

## How do I obtain the index list in a NumPy Array of all the NaN values present using Python?

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

## How can I lookup hostname using the IP address with a timeout in Python?

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

## how do i print only the last two letters in a string using regular expression in python?

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

## how do i change string to a list?

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

+1 vote

## how can i count the items in a list?

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