assignment 2

pdf

School

Western University *

*We aren’t endorsed by this school

Course

1000

Subject

Electrical Engineering

Date

Feb 20, 2024

Type

pdf

Pages

7

Uploaded by mackkenzie

Report
0.09991232866619165 0.00517214860149906 0.8949155227323093 0.8526102005152945 0.8413447460685429 In [313… import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from scipy.stats import norm from numpy.random import randn In [314… #5.a) norm . cdf ( 0.7 , loc = 0.8 , scale = 0.078 ) Out[314]: In [315… #b) 1 - norm . cdf ( 1.00 , loc = 0.8 , scale = 0.078 ) Out[315]: In [316… #d) norm . cdf ( 1.00 , loc = 0.8 , scale = 0.078 ) - norm . cdf ( 0.7 , loc = 0.8 , scale = 0.078 ) Out[316]: In [317… #e) norm . ppf ( 0.75 , loc = 0.8 , scale = 0.078 ) Out[317]: In [318… #6.a) norm . cdf ( 1 , loc = 0 , scale = 1 ) Out[318]:
{'mean': 0.1034254744458238, 'std': 1.0056048931496147, 'proportion_than-1': 0.83} {'mean': -0.0869132469881922, 'std': 1.026753744731724, 'proportion_than-1': 0.87} {'mean': 0.03276971493922777, 'std': 0.9829527545097617, 'proportion_than-1': 0.834} {'mean': 0.06306579672208415, 'std': 0.9996368660295929, 'proportion_than-1': 0.824} In [319… def stats_normal ( n ): sample = np . random . normal ( size = n ) sample_mean = np . mean ( sample ) sample_std = np . std ( sample , ddof = 1 ) proportion = np . mean ( sample < 1 ) return { 'mean' : sample_mean , 'std' : sample_std , 'proportion_than-1' : proportion } results = stats_normal ( 100 ) print ( results ) In [320… results = stats_normal ( 100 ) print ( results ) In [321… results = stats_normal ( 1000 ) print ( results ) In [322… results = stats_normal ( 1000 ) print ( results ) In [323… #7a) RBC = pd . read_csv ( "RBC_Returns.csv" ) RBC . head () Out[323]: In [324… percent_stock_change = pd . read_csv ( "RBC_Returns.csv" ) percent_stock_change = pd . DataFrame ( percent_stock_change ) sns . displot ( percent_stock_change . percent_stock_change , stat = 'percent' , kde = True ) plt . show ()
Mean: 0.058340604526355304 Standard Deviation 1.3958952363377914 6698.865469843081 fall between % daily change of − 3 and + 3 0.9973002039367398 is the proportion of values between − 3 and + 3 In [325… #b) mean = np . mean ( RBC [ "percent_stock_change" ]) standard_devaiation = np . std ( RBC [ "percent_stock_change" ], ddof = 1 ) print ( 'Mean:' , mean ) print ( 'Standard Deviation' , standard_devaiation ) In [326… #c.1 mu = 0.058340604526355304 sigma = 1.3958952363377914 cdf_upper_limit = norm . cdf ( mu + 3 * sigma , loc = mu , scale = sigma ) cdf_lower_limit = norm . cdf ( mu - 3 * sigma , loc = mu , scale = sigma ) number = cdf_upper_limit - cdf_lower_limit print (( number * 6717 ), 'fall between % daily change of − 3 and + 3 ' ) In [327… #2. proportion = number * 6717 print (( proportion / 6717 ), 'is the proportion of values between − 3 and + 3 ' )
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
In [328… #d.a sns . boxplot ( x = RBC [ "percent_stock_change" ]) plt . show () In [329… np . random . seed ( 123 ) normal = norm . rvs ( loc = 0.058340604526355304 , scale = 1.3958952363377914 , size = 671 sns . displot ( normal , stat = 'density' ) plt . show ()
In [330… sns . boxplot ( x = normal ) plt . show ()
In [331… np . random . seed ( 456 ) normal1 = norm . rvs ( loc = 0.058340604526355304 , scale = 1.3958952363377914 , size = 67 sns . displot ( normal , stat = 'density' ) plt . show () In [332… sns . boxplot ( x = normal1 ) plt . show ()
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help