测试格式
文字计数功能
正文
随便写点东西
格式测试
加粗test
横线test
斜体test
Sorted list
Sorted list
Sorted list
代码格式测试
1 2 3 $ hexo new post First_Test INFO Validating config INFO Created: D:\<user name>\source \_posts\2023-06-25-First-Test.md
1 2 import osprint ('hello world' )
测试标题
标题二
标题三
标题四
标题五
测试数学公式
测试用公式1
m = ( n ) p m= _{(n)}p
m = ( n ) p
n ∣ ( m − p ) n\ |\ (m-p)
n ∣ ( m − p )
m − p = k n m-p=kn
m − p = k n
As k k k is an integer.
There must exist a k k k that satisfied:
k = ⌊ m n ⌋ − ⌊ p n ⌋ k = \lfloor \frac{m}{n} \rfloor - \lfloor \frac{p}{n} \rfloor
k = ⌊ n m ⌋ − ⌊ n p ⌋
m − p = ( ⌊ m n ⌋ − ⌊ p n ⌋ ) n m − ⌊ m n ⌋ n = p − ⌊ p n ⌋ n m % n = p % n \begin{aligned}
m-p &= (\lfloor \frac{m}{n} \rfloor - \lfloor \frac{p}{n} \rfloor) n\\
m - \lfloor \frac{m}{n} \rfloor n &= p - \lfloor \frac{p}{n} \rfloor n\\
m\%n &= p\%n
\end{aligned} m − p m − ⌊ n m ⌋ n m % n = ( ⌊ n m ⌋ − ⌊ n p ⌋ ) n = p − ⌊ n p ⌋ n = p % n
测试用公式2
h ( θ ∣ X ) ∝ f ( X ∣ θ ) τ ( θ ) h(\theta|X) \propto f(X|\theta)\tau(\theta)
h ( θ ∣ X ) ∝ f ( X ∣ θ ) τ ( θ )
First we should figure out f ( X ∣ θ ) f(X|\theta) f ( X ∣ θ ) .
f ( X ∣ θ ) = f ( x 1 , x 2 , ⋯ , x n ∣ θ ) = f ( x 1 ∣ θ ) ⋅ f ( x 2 ∣ θ ) ⋯ f ( x n ∣ θ ) = ∏ i = 1 n 1 x i ! e − θ θ x i = ( ∏ i = 1 n 1 x i ! ) e − n θ θ ∑ i = 1 n x i \begin{aligned}
f(X|\theta) &= f(x_1,x_2,\cdots,x_n|\theta)\\
&= f(x_1|\theta) \cdot f(x_2|\theta) \cdots f(x_n|\theta)\\
&= \prod_{i=1}^n \frac{1}{x_i !} e^{-\theta}\theta^{x_i}\\
&= \left(\prod_{i=1}^n \frac{1}{x_i !}\right) e^{-n \theta}\theta^{\sum_{i=1}^n x_i}
\end{aligned} f ( X ∣ θ ) = f ( x 1 , x 2 , ⋯ , x n ∣ θ ) = f ( x 1 ∣ θ ) ⋅ f ( x 2 ∣ θ ) ⋯ f ( x n ∣ θ ) = i = 1 ∏ n x i ! 1 e − θ θ x i = ( i = 1 ∏ n x i ! 1 ) e − n θ θ ∑ i = 1 n x i
Therefore,
h ( θ ∣ X ) ∝ f ( X ∣ θ ) τ ( θ ) ∝ ( θ α − 1 e − θ / β ) ⋅ ( e − n θ θ ∑ i = 1 n x i ) = θ α + ∑ i = 1 n x i − 1 ⋅ e − θ ( n + 1 β ) = θ α + ∑ i = 1 n x i − 1 ⋅ e − θ / ( β n β + 1 ) \begin{aligned}
h(\theta|X) &\propto f(X|\theta)\tau(\theta)\\
&\propto (\theta^{\alpha-1}e^{-\theta/\beta}) \cdot (e^{-n \theta}\theta^{\sum_{i=1}^n x_i})\\
&= \theta^{\alpha+\sum_{i=1}^n x_i -1} \cdot e^{-\theta(n+\frac{1}{\beta})}\\
&= \theta^{\alpha+\sum_{i=1}^n x_i -1} \cdot e^{-\theta/(\frac{\beta}{n\beta+1})}
\end{aligned} h ( θ ∣ X ) ∝ f ( X ∣ θ ) τ ( θ ) ∝ ( θ α − 1 e − θ / β ) ⋅ ( e − n θ θ ∑ i = 1 n x i ) = θ α + ∑ i = 1 n x i − 1 ⋅ e − θ ( n + β 1 ) = θ α + ∑ i = 1 n x i − 1 ⋅ e − θ / ( n β + 1 β )
Therefore, the posterior distribution for θ \theta θ is :
G a m m a ( α + ∑ i = 1 n x i , β n β + 1 ) Gamma \left(\alpha+\sum_{i=1}^n x_i\ ,\ \frac{\beta}{n\beta+1} \right)
G a m m a ( α + i = 1 ∑ n x i , n β + 1 β )
例题
A single die is tossed; then n n n coins are tossed where n n n is the number shown on the die. Show that the probability of exactly two heads is close to 0.2578.
参考答案
We will sum up the probabilities of getting exactly two heads for each possible outcome of the die roll (1 through 6). Assume the first number rolled was N N N .
P ( X = 2 ) = P ( X = 2 ∩ N = 1 ) + P ( X = 2 ∩ N = 2 ) + P ( X = 2 ∩ N = 3 ) + P ( X = 2 ∩ N = 4 ) + P ( X = 2 ∩ N = 5 ) + P ( X = 2 ∩ N = 6 ) \begin{aligned}
P(X=2) &= P(X=2 \cap N=1) + P(X=2 \cap N=2) + P(X=2 \cap N=3) \\
&+ P(X=2 \cap N=4) + P(X=2 \cap N=5) + P(X=2 \cap N=6)
\end{aligned} P ( X = 2 ) = P ( X = 2 ∩ N = 1 ) + P ( X = 2 ∩ N = 2 ) + P ( X = 2 ∩ N = 3 ) + P ( X = 2 ∩ N = 4 ) + P ( X = 2 ∩ N = 5 ) + P ( X = 2 ∩ N = 6 )
The probability of getting exactly two heads when tossing n n n coins can be found using the binomial probability formula, which is given by:
P ( X = k ) = ( n k ) p k ( 1 − p ) n − k P(X=k) =\tbinom{n}{k}p^k(1-p)^{n-k}
P ( X = k ) = ( k n ) p k ( 1 − p ) n − k
( n k ) \tbinom{n}{k} ( k n ) is the binomial coefficient, which calculates the number of ways to choose k k k successes out of n n n trials.
p p p is the probability of success, for toss a coin which is 1 2 \frac{1}{2} 2 1 .
n n n is the number of trials.
k k k is the number of successes, in this question means two heads.
Only when n ≥ 2 n \geq 2 n ≥ 2 , P P P makes sense.
Therefore, We can have
P ( X = 2 ) = P ( X = 2 ∩ N = 1 ) + P ( X = 2 ∩ N = 2 ) + P ( X = 2 ∩ N = 3 ) + P ( X = 2 ∩ N = 4 ) + P ( X = 2 ∩ N = 5 ) + P ( X = 2 ∩ N = 6 ) = 1 6 ( ( 2 2 ) ( 1 2 ) 2 + ( 3 2 ) ( 1 2 ) 3 + ( 4 2 ) ( 1 2 ) 4 + ( 5 2 ) ( 1 2 ) 5 + ( 6 2 ) ( 1 2 ) 6 ) = 0.2578 \begin{aligned}
P(X=2) &= P(X=2 \cap N=1) + P(X=2 \cap N=2) + P(X=2 \cap N=3) \\
&+ P(X=2 \cap N=4) + P(X=2 \cap N=5) + P(X=2 \cap N=6)\\
&= \frac{1}{6}\left( \tbinom{2}{2}(\frac{1}{2})^2 + \tbinom{3}{2}(\frac{1}{2})^3 + \tbinom{4}{2}(\frac{1}{2})^4 + \tbinom{5}{2}(\frac{1}{2})^5 + \tbinom{6}{2}(\frac{1}{2})^6\right)\\
&= 0.2578
\end{aligned} P ( X = 2 ) = P ( X = 2 ∩ N = 1 ) + P ( X = 2 ∩ N = 2 ) + P ( X = 2 ∩ N = 3 ) + P ( X = 2 ∩ N = 4 ) + P ( X = 2 ∩ N = 5 ) + P ( X = 2 ∩ N = 6 ) = 6 1 ( ( 2 2 ) ( 2 1 ) 2 + ( 2 3 ) ( 2 1 ) 3 + ( 2 4 ) ( 2 1 ) 4 + ( 2 5 ) ( 2 1 ) 5 + ( 2 6 ) ( 2 1 ) 6 ) = 0 . 2 5 7 8