mercredi 4 octobre 2017

Random Numbers in a range around a median

I have a median and a standard deviation, what i want is to generate random numbers between the median-std and the median+std.

I know how to do it like this:

import numpy as np
import random as rnd

median=30
std=15
random_nr=rnd.randint(median-std,median+std)

I also found the numpy.random.normal function but it doesn't seem to do what i need. Is there any other way of doing it? It would be great if the random generator would generate numbers in mirror as to the median, for example, an output for 6 generated random numbers should look like this:

numbers=magicfunction(median,std,6)
[29,31,20,40,25,35]




Aucun commentaire:

Enregistrer un commentaire