Sample from Uniform, Normal, Binomial, Poisson, and Exponential distributions.
NumPy's random module supports statistical probability distributions essential for Monte Carlo simulations, physics modeling, and financial risk analysis.
Binomial models flipping a coin N times. Poisson models the number of customer arrivals per hour. Normal models human heights in a population.
`normal(loc, scale)`: Gaussian bell curve with center `loc` and width `scale`. `poisson(lam)`: Event arrivals with rate $\lambda$.
samples = np.random.normal(0, 1, 1000)np.random.normal(10, 2) # Samples 1 scalar valuenp.random.normal(10, 2, size=100)Include `size=N` to generate an entire array of sampled distribution points.
Solve the objective below using NumPy vectorized syntax
Set seed to 42, generate 3 normal samples with `loc=0`, `scale=1`, `size=3`, and print.
[ 0.497 -0.138 0.648]