generate datarame column filled with random floats with n standard deviation and mean

I know I could fill a df with random numbers, specifying the lowest and highest bound.

data = np.random.randint(lowest integer, highest integer, size=number of random integers)
df = pd.DataFrame(data, columns=['column name'])

how can I do this exact thing but specifying StandardDeviation and mean?

I tried this method (and it works), but it's not the fastest for larger iterations:

    for i in range(sim_runs):
      steps = float(np.random.normal(loc=pf_ER, scale = pf_SD, size = 1) +1) # generate random array to multiply with resturns
      step.append(steps) # put into a string
    step = pd.DataFrame(step)

where

sim_runs = #simulation runs
pf_ER = mean return
pf_SD = standard deviation

Posted Mar 9, 2022, 7:38 PM UTC

13
Loading comments…