找回密码
 快速注册
搜索
查看: 113|回复: 14

求解概率值

[复制链接]

1

主题

2

回帖

16

积分

积分
16

显示全部楼层

chenyu93 发表于 2023-5-31 10:54 |阅读模式
设抛掷硬币时,得到正面的概率为56%,得到反面的概率为44%,连续抛掷1500次,出现连续七次反面的概率是多少?

48

主题

992

回帖

1万

积分

积分
14981
QQ

显示全部楼层

Czhang271828 发表于 2023-5-31 12:45
其实问问 GPT 就可以了, 答案 $1-(1-0.56^7)^{1500-7+1}$.

-----------------------以下是解答过程----------------------


Question A coin is tossed 1500 times, and the probability of heads is 0.56. What is the probability that there exists 7 heads in a row?

Answer by $\mathsf{ChatGPT4}$
We can approach this by calculating the probability of the complement event, which is that there are no runs of $7$ consecutive heads.
Let $q=1-p=0.44$ be the probability of tails. We can use the formula for the probability of no runs of $k$ consecutive heads in $n$ tosses, which is:
\[P(\text{no $k$ consecutive heads in $n$ tosses})=(1-p^k)^{n-k+1}.\]
So, the probability of no runs of $7$ consecutive heads in $1500$ tosses is:
\begin{align*}
&P(\text{no $7$ consecutive heads in $1500$ tosses})\\
=\,&(1-0.56^7)^{1500-7+1}\\
=\,& 0.3917409259.
\end{align*}
Therefore, the probability that there is at least one run of $7$ consecutive heads in $1500$ tosses is:
\begin{align*}
&P(\text{at least $1$ run of $7$ consecutive heads in $1500$ tosses})\\
=\,&1-P(\text{no $7$ consecutive heads in $1500$ tosses})\\
=\,& 1-0.3917409259\\
=\,& 0.6082590741.
\end{align*}

Answer
\[P(\text{at least 1 run of 7 consecutive heads in } 1500 \text{ tosses}) \approx 0.6083.\]

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2023-5-31 13:03
知乎有相关问题:zhihu.com/question/46388875

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2023-5-31 14:56
Czhang271828 发表于 2023-5-31 12:45
其实问问 GPT 就可以了, 答案 $1-(1-0.56^7)^{1500-7+1}$.

-----------------------以下是解答过程----- ...

`P(\text{no $k$ consecutive heads in $n$ tosses})=(1-p^k)^{n-k+1}` 这是为啥呢?

1

主题

2

回帖

16

积分

积分
16

显示全部楼层

 楼主| chenyu93 发表于 2023-5-31 15:02
Czhang271828 发表于 2023-5-31 12:45
其实问问 GPT 就可以了, 答案 $1-(1-0.56^7)^{1500-7+1}$.

-----------------------以下是解答过程----- ...

1

主题

2

回帖

16

积分

积分
16

显示全部楼层

 楼主| chenyu93 发表于 2023-5-31 15:02
kuing 发表于 2023-5-31 14:56
`P(\text{no $k$ consecutive heads in $n$ tosses})=(1-p^k)^{n-k+1}` 这是为啥呢?

85

主题

432

回帖

5416

积分

积分
5416

显示全部楼层

tommywong 发表于 2023-5-31 15:27
Czhang271828 发表于 2023-5-31 12:45
其实问问 GPT 就可以了, 答案 $1-(1-0.56^7)^{1500-7+1}$.

-----------------------以下是解答过程----- ...

ChatGPT出名吹水同做錯數
$n=8$時$2p^7-p^8$
唔會係$1-(1-p^7)^{n-7+1}$

另外人哋係問緊連續七次反面,唔係正面
现充已死,エロ当立。
维基用户页:https://zh.wikipedia.org/wiki/User:Tttfffkkk
Notable algebra methods:https://artofproblemsolving.com/community/c728438
《方幂和及其推广和式》 数学学习与研究2016.

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2023-5-31 15:42
记 `a=0.44` 为反面概率,记 `P(n)` 为抛 `n` 次出现连续七次反面的概率。

显然当 `n<7` 时 `P(n)=0`,及 `P(7)=a^7`。

当 `n>7` 时,出现连续七次反面这个事件包含两种情况:

(1)前 `n-1` 次内已经出现连续七次反面;

(2)直至抛完最后一次才出现连续七次反面。

情况(1)概率就是 `P(n-1)`,至于情况(2),那就是前 `n-8` 次内都没有出现且最后 `8` 次为正反反反反反反反,因此概率为 `\bigl(1-P(n-8)\bigr)\cdot(1-a)a^7`。

综上,有
\[P(n)=P(n-1)+\bigl(1-P(n-8)\bigr)\cdot(1-a)a^7.\]

48

主题

992

回帖

1万

积分

积分
14981
QQ

显示全部楼层

Czhang271828 发表于 2023-5-31 16:25
本帖最后由 Czhang271828 于 2023-5-31 17:23 编辑 $\mathsf{GPT}$ 确实问题一堆. 可以尝试把
  1. M = Matrix([
  2.     [0.56 ,0.56 ,0.56 ,0.56 ,0.56 ,0.56 ,0.56 ,0],
  3.     [0.44 ,0    ,0    ,0    ,0    ,0    ,0    ,0],
  4.     [0    ,0.44 ,0    ,0    ,0    ,0    ,0    ,0],
  5.     [0    ,0    ,0.44 ,0    ,0    ,0    ,0    ,0],
  6.     [0    ,0    ,0    ,0.44 ,0    ,0    ,0    ,0],
  7.     [0    ,0    ,0    ,0    ,0.44 ,0    ,0    ,0],
  8.     [0    ,0    ,0    ,0    ,0    ,0.44 ,0    ,0],
  9.     [0    ,0    ,0    ,0    ,0    ,0    ,0.44 ,1]
  10. ]);
  11. V = Matrix([[1],[0],[0],[0],[0],[0],[0],[0]]);
  12. Out = (M^1500)*V;
  13. Out[-1]
复制代码

扔给 $\texttt{sage}$ 在线计算, 得到答案:
  1. (0.933403093589771)
复制代码

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2023-5-31 17:05
按 8# 的递推方法,在 MMA 里用如下命令
  1. a = 0.44;
  2. Do[P[n] = 0, {n, 0, 6}]
  3. P[7] = a^7;
  4. Do[P[n] = P[n - 1] + (1 - P[n - 8]) (1 - a) a^7, {n, 8, 1500}]
  5. P[1500]
复制代码

输出结果是 0.933403,不知会不会有数值误差……

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-5-31 17:13
kuing 发表于 2023-5-31 10:05
按 8# 的递推方法,在 MMA 里用如下命令

输出结果是 0.933403,不知会不会有数值误差…… ...

101341nkws2szktl32tm33.png In SageMath, (Python syntax) you need to initialize the list P with zeros using multiplication [0] * 7 and access the elements using square brackets P[n]. The rest of the code remains mostly unchanged.

  1. a = 0.44
  2. P = [0] * 7
  3. P.append(a**7)
  4. for n in range(8, 1501):
  5.     P.append(P[n-1] + (1 - P[n-8]) * (1 - a) * a**7)
  6. P[1500]
复制代码

Screenshot 2023-05-31 at 10-24-20 Octave Online · Cloud IDE compatible with MATLAB.png In Matlab / Octave, indexing starts from 1 instead of 0, so the range in the for loop starts from 9 instead of 8. The initial list P is initialized with zeros using zeros function, and P(8) is assigned the value a^7 instead of using append. The rest of the code remains the same.

  1. a = 0.44;
  2. P = zeros(1, 1501);
  3. P(8) = a^7;
  4. for n = 9:1501
  5.     P(n) = P(n-1) + (1 - P(n-8)) * (1 - a) * a^7;
  6. end
  7. P(1501)
复制代码

85

主题

432

回帖

5416

积分

积分
5416

显示全部楼层

tommywong 发表于 2023-5-31 17:17
#10同#11都冇錯,但#9唔知係乜

点评

#9 已修正:)  发表于 2023-5-31 17:46
现充已死,エロ当立。
维基用户页:https://zh.wikipedia.org/wiki/User:Tttfffkkk
Notable algebra methods:https://artofproblemsolving.com/community/c728438
《方幂和及其推广和式》 数学学习与研究2016.

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-5-31 17:18
Czhang271828 发表于 2023-5-31 09:25
$\mathsf{GPT}$ 确实问题一堆. 可以尝试把

扔给 $\texttt{sage}$ 在线计算, 得到答案.  ...

In Matlab / Octave, you can directly perform matrix multiplication using the * operator. The end keyword is used to refer to the last element of a vector or the last row/column of a matrix. Screenshot 2023-05-31 at 10-29-01 Octave Online · Cloud IDE compatible with MATLAB.png

  1. M = [0.56 ,0.56 ,0.56 ,0.56 ,0.56 ,0.56 ,0.56 ,0;
  2.      0.44 ,0    ,0    ,0    ,0    ,0    ,0    ,0;
  3.      0    ,0.44 ,0    ,0    ,0    ,0    ,0    ,0;
  4.      0    ,0    ,0.44 ,0    ,0    ,0    ,0    ,0;
  5.      0    ,0    ,0    ,0.44 ,0    ,0    ,0    ,0;
  6.      0    ,0    ,0    ,0    ,0.44 ,0    ,0    ,0;
  7.      0    ,0    ,0    ,0    ,0    ,0.44 ,0    ,0;
  8.      0    ,0    ,0    ,0    ,0    ,0    ,0.44 ,1];
  9. V = [1;0;0;0;0;0;0;0];
  10. Out = M^1500 * V;
  11. Out(end)
复制代码
In Mathematica, MatrixPower[M, n] is used to raise a matrix M to the power n, and Last[out] or out[[-1]] is equivalent to Out(end) in MATLAB, giving the last element of the vector out.
  1. M = {{0.56, 0.56, 0.56, 0.56, 0.56, 0.56, 0.56, 0},
  2.      {0.44, 0,    0,    0,    0,    0,    0,    0},
  3.      {0,    0.44, 0,    0,    0,    0,    0,    0},
  4.      {0,    0,    0.44, 0,    0,    0,    0,    0},
  5.      {0,    0,    0,    0.44, 0,    0,    0,    0},
  6.      {0,    0,    0,    0,    0.44, 0,    0,    0},
  7.      {0,    0,    0,    0,    0,    0.44, 0,    0},
  8.      {0,    0,    0,    0,    0,    0,    0.44, 1}};
  9. V = {1, 0, 0, 0, 0, 0, 0, 0};
  10. out = MatrixPower[M, 1500].V;
  11. out[[-1]]
复制代码

27

主题

1010

回帖

1万

积分

积分
12585

显示全部楼层

战巡 发表于 2023-5-31 18:20
搞这么复杂...就很简单的一个随机过程而已啊
p0191.png

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 12:20

Powered by Discuz!

× 快速回复 返回顶部 返回列表