Random variables

In [1]:
import numpy as np
import seaborn as sns

Normal

In [2]:
def source1(shape=None):
    return np.random.normal(10, 2, shape)
In [3]:
source1()
Out[3]:
10.640236728514942
In [4]:
vals1 = source1(1000)
In [5]:
sns.distplot(vals1, kde=True, rug=True);
C:\Users\mclou\Anaconda3\lib\site-packages\scipy\stats\stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval

Uniform

In [6]:
def source2(shape=None):
    return np.random.uniform(0, 100, shape)
In [7]:
source2()
Out[7]:
16.94823906331788
In [8]:
vals2 = source2(1000)
In [9]:
sns.distplot(vals2, kde=True, rug=True);

Binomial

In [10]:
def source3(shape=None):
    return np.random.binomial(10, 0.5, shape)
In [11]:
source3()
Out[11]:
4
In [12]:
vals3 = source3(1000)
In [13]:
sns.distplot(vals3, kde=True, rug=True);

Chi-square

In [14]:
def source4(shape=None):
    return np.random.chisquare(1, shape)
In [15]:
source4()
Out[15]:
2.0901869671074977
In [16]:
vals4 = source4(1000)
In [17]:
sns.distplot(vals4, kde=True, rug=True);

Pareto

In [18]:
def source5(shape=None):
    return np.random.pareto(1.16, shape)
In [19]:
source5()
Out[19]:
0.28739400531779125
In [20]:
vals5 = source5(1000)
In [21]:
sns.distplot(vals5);

Poisson

In [22]:
def source6(shape=None):
    return np.random.poisson(3, shape)
In [23]:
source6()
Out[23]:
2
In [24]:
vals6 = source6(1000)
In [25]:
sns.distplot(vals6);

Student's t

In [26]:
def source6(shape=None):
    return np.random.standard_t(10, shape)
In [27]:
source6()
Out[27]:
-0.7910509164826577
In [28]:
vals6 = source6(1000)
In [29]:
sns.distplot(vals6);

End