In elementary statistics textbooks, the normal distribution is heavily relied upon to describe many different populations of data. Although many random processes do appear to look like normal distributions most of the time, real-life tends to be more complex. Stock market returns are a prime example of a distribution that can look fairly normal but in actuality be quite far off.
This recipe describes how to find daily stock market returns of the internet retail giant Amazon and informally test whether they follow a normal distribution.
- Load Amazon stock data and set the date as the index:
>>> amzn = pd.read_csv('data/amzn_stock.csv', index_col='Date', parse_dates=['Date']) >>> amzn.head()
- Create a Series by selecting only the closing price and then using the
pct_change
method to get the daily rate of return:
>>> amzn_daily_return = amzn.Close.pct_change() >>>...