#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar  8 13:18:41 2018

@author: teacher
"""

import random as r
import pandas as pd

# sample from the standard normal distribution with mu = 0
# and sigma = 1
num = r.gauss(0,1)
print(num)

# sample from the normal distribution many times,
# and plot the sampled values as a histogram

num_list = []
for i in range(100000):
    # sample from the normal distribution
    # (randomly generate a number from it)
    num = r.gauss(0,1)
    num_list.append(num)
num_series = pd.Series(num_list)
num_series.plot.hist(bins=20)

# estimate the probability that a generated number
# is between -1 and 1
less_than_cond = num_series <= 1  # mu + sigma = 2 + 4
greater_than_cond = num_series >= -1  # mu - sigma = 2-4

one_sigma = num_series[less_than_cond & greater_than_cond]

# estimate probability a number is 1 sigma from the mean
prob = len(one_sigma)/len(num_series)
print("Estimated probability number with sigma of mean:",prob)






