mardi 14 mai 2019

Generate Random Data for Each Player that Follows a Normal Distribution

I have a python dataframe that contains goals scored for players in the NHL from multiple seasons. My dataframe looks like this:

Player   2018-2019  2017-2018  2016-2015
John         25         22        23 
James        27         20        24   
Joe          18         19        18

What I'd like to do is for each player, I'd like to generate 1000 random numbers that follow a normal distribution based on their career mean and standard deviation, and a 95% confidence interval for those 1000 numbers.

I know I will need to use numpys random.normal function to calculate the random numbers, but I'm not sure about calculating the confidence interval within python.

I'm thinking the pseudo code for this process would be something like:

for rows in df:
    s = np.random.normal(avg, std_dev, 1000)
    df['Confidence Interval'] = 95% confidence interval function (s)

Thank you for any help!




Aucun commentaire:

Enregistrer un commentaire