<jupyter_start><jupyter_text>概率统计/Probability and Statistics<jupyter_code>import numpy as np
from scipy.stats import norm
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>下面应该是本章重点的”蒙特卡洛积分“了，不过，因为蒙特卡洛是一种基于概率统计的方法，所以这里把直接相关的一些内容也来复习一下。  Random Variables, Expectation, and Variance - Cumulative Distribution Function: $F(x) = P(X \leq x)$    - $P(X > a) = 1-P(X \leq a) = 1-F(a)$    - Interval Probabilities: $P(a < X \leq b) = F(b)-F(a)$- Linearity of Expectation: $E(aX+b) = aE(X)+b$    - $E(X+Y) = E(X)+E(Y)$ , $E(X-Y) = E(X)-E(Y)$    - Variance: $V(X+Y) = V(X)+V(Y)+2(E(XY)-EX \cdot EY)$- Variance: Expected squared difference between X and its mean    - $V(X) = E[(X-\mu)^2]$    - $V(X)=E[X^2]-E[X]^2$- Standard deviation： $\sigma_X = +\sqrt{V(x)}$    - Addition: $V(X+b) = V(X)$- Scaling: $V(aX) = a^2 V(X)$, $\sigma_{aX} = |a| \sigma_x$- Affine Transformation: $V(aX+b)=a^2 V(X)$  Distribution Families Discrete Distribution Families| Distribution | Notation | PMF | Mean:$\mu$ | Variance | CDF:$F(n)$ || -- |  -- | -- | -- | -- | -- || Bernoulli |  $$X \sim B_p$$ | $$p$$ | $$p$$ | $$pq$$| || Binomial  | $$X \sim B_{p,n}(k)$$ | $$\binom{n}{k} p^k q^{n-k}$$ | $$np$$ | $$npq$$ | || Poisson | $$X \sim P_{\lambda}(k)$$ | $$e^{-\lambda} \frac{{\lambda}^k}{k!}$$ | $$\lambda$$ | $$\lambda$$ | || Geometric | $$X \sim G_p(n)$$ | $$p \cdot q^{n-1}$$ | $$\frac{1}{p}$$ | $$\frac{q}{p^2}$$ | $$1-q^n$$ | Continuous Distribution Families    | Distribution | Notation | PDF | Mean:$\mu$ | Variance | CDF:$F(n)$ || -- |  -- | -- | -- | -- | -- || Uniform | $$X \sim U_[a,b]$$ | $$\frac{1}{b-a}$$ | $$\frac{a+b}{2}$$  | $$\frac{(b-a)^2}{12}$$  | $$\frac{x-a}{b-a}$$ || Exponential | $$X \sim f_{\lambda}$$ | $$\lambda e^{-\lambda x}, x \geq 0 $$ | $$\frac{1}{\lambda}$$ | $$\frac{1}{\lambda^2}$$ | $$1-e^{-\lambda x}, x \geq 0$$ | 正态分布- 标准正态分布: $Z \sim \mathcal{N}(0, 1)$$$Z \sim \mathcal{N}(0, 1) \\P(Z \leq a) = \Phi(a) \\P(Z \geq a) = 1-\Phi(a) \\P(a \le Z \le b) = \Phi(b) - \Phi(a)$$- 一般正态分布: $X\sim\mathcal{N}(\mu,\sigma^2)$$$f_X(x) = \frac{1}{\sqrt{2\pi\sigma^2}} e ^{-(x-\mu)^2/(2 \sigma^2)}$$<jupyter_code>x = np.linspace(-4,4,100)
y = norm.pdf(x)

plt.figure(figsize=[9,9])
plt.title("Normal Distribution")
plt.plot(x,y)
plt.grid()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.29700390794615716, 'fraction_numerical': 0.0182370820668693, 'mean_word_length': 3.79002079002079, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '145772', 'license': 'MIT', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1072, 'n_words': 201, 'path': 'docs/part-1/05-Probability.ipynb', 'repo_name': 'neil3d/LearnPBR', 'size': '2303'}