File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
galleries/examples/statistics Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 2020import matplotlib .pyplot as plt
2121import numpy as np
2222
23- np .random .seed (19680801 )
23+ rng = np .random .default_rng (19680801 )
2424
2525# example data
26- mu = 100 # mean of distribution
27- sigma = 15 # standard deviation of distribution
28- x = mu + sigma * np . random . randn ( 437 )
26+ mu = 106 # mean of distribution
27+ sigma = 17 # standard deviation of distribution
28+ x = rng . normal ( loc = mu , scale = sigma , size = 420 )
2929
30- num_bins = 50
30+ num_bins = 42
3131
3232fig , ax = plt .subplots ()
3333
3838y = ((1 / (np .sqrt (2 * np .pi ) * sigma )) *
3939 np .exp (- 0.5 * (1 / sigma * (bins - mu ))** 2 ))
4040ax .plot (bins , y , '--' )
41- ax .set_xlabel ('Smarts ' )
41+ ax .set_xlabel ('Value ' )
4242ax .set_ylabel ('Probability density' )
43- ax .set_title (r'Histogram of IQ: $\mu=100$, $\sigma=15$' )
43+ ax .set_title ('Histogram of normal distribution sample: '
44+ fr'$\mu={ mu :.0f} $, $\sigma={ sigma :.0f} $' )
4445
4546# Tweak spacing to prevent clipping of ylabel
4647fig .tight_layout ()
You can’t perform that action at this time.
0 commit comments