Skip to content

Latest commit

 

History

History
39 lines (28 loc) · 1.75 KB

random.md

File metadata and controls

39 lines (28 loc) · 1.75 KB

Random Sampling and Standard Distributions

1. check the functions in numpy.random

- https://docs.scipy.org/doc/numpy-1.16.0/reference/routines.random.html
- https://numpy.org/devdocs/reference/random/index.html

2. plot histograms

  1. 1M samples generated from N(0,1)

    • np.random.normal()
  2. 1M samples from a continuous uniform distribution U(0,1)

    • np.random.uniform()
  3. 1M discrete random integer samples from U(0,1000)

    • np.randint()
  4. 1M trials from binomial distribution with $n=100$ trials and the probability of success (or head) p = 0.3

  5. 1M samples from Bernoulli distribution with $P(X=1) = 0.3$

  6. (extra) How many times will a fair die land on the same number (e.g. 5) out of 100 trials.

    • use 'np.random.binomial(n=100, p=1/6., size=N)` to generate the samples.
    • base event set = { face is 5, face is not 5 }, so it is binary. (the same applies to other numbers each)

3. CDF (Cumulative distribution function), PDF (Prob. distribution function), PMF (Prob. Mass Function)

  1. plot cdf and pdf of Normal (or Gaussian) distribution with ($$mean=0$$, $$\sigma=1$$) and ($mean=0$, $\sigma=5$), respectively.
  2. plot cdf and pdf of uniform distribution $U[0,1]$
  3. plot cdf and pmf of Bernoulli distribution with $p=0.3$
  4. plot cdf and pmf of $binomial(n=100, p=0.3)$