In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

In [51]:
N = 10000
data = np.random.randn(N)

In [52]:
plt.plot(data,".")


Out[52]:
[<matplotlib.lines.Line2D at 0x115770898>]

In [53]:
bins = np.arange(-5.5,5.5,0.25)
plt.hist(data,bins)


Out[53]:
(array([   0.,    0.,    0.,    0.,    0.,    0.,    1.,    4.,    1.,
           8.,   17.,   36.,   55.,   97.,  184.,  245.,  382.,  531.,
         668.,  818.,  948.,  938.,  973.,  960.,  862.,  655.,  573.,
         388.,  258.,  172.,  112.,   55.,   35.,   12.,    6.,    5.,
           0.,    1.,    0.,    0.,    0.,    0.,    0.]),
 array([-5.5 , -5.25, -5.  , -4.75, -4.5 , -4.25, -4.  , -3.75, -3.5 ,
        -3.25, -3.  , -2.75, -2.5 , -2.25, -2.  , -1.75, -1.5 , -1.25,
        -1.  , -0.75, -0.5 , -0.25,  0.  ,  0.25,  0.5 ,  0.75,  1.  ,
         1.25,  1.5 ,  1.75,  2.  ,  2.25,  2.5 ,  2.75,  3.  ,  3.25,
         3.5 ,  3.75,  4.  ,  4.25,  4.5 ,  4.75,  5.  ,  5.25]),
 <a list of 43 Patch objects>)

In [64]:
#Default 10 bins, equal sizes, no specific centering
plt.hist(data,11)


Out[64]:
(array([   10.,    72.,   346.,  1082.,  2198.,  2674.,  2162.,  1071.,
          319.,    57.,     9.]),
 array([-3.81425433, -3.11664382, -2.4190333 , -1.72142278, -1.02381226,
        -0.32620175,  0.37140877,  1.06901929,  1.76662981,  2.46424032,
         3.16185084,  3.85946136]),
 <a list of 11 Patch objects>)

In [55]:
np.std(data)


Out[55]:
0.99713493230620076

In [62]:
((-1 < data) & (data < 1)).sum()


Out[62]:
6822

In [63]:
(_/N) * 100


Out[63]:
68.219999999999999

In [65]:
from plotly.graph_objs import *
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)



In [72]:
plotlydata = [
    Histogram(
        x=data,
        xbins=dict(
        start=-4.5,
        end=4.5,
        size=1
    ),
    )
]
iplot(plotlydata)



In [ ]: