Probability calculation for Bernoulli trials.

  • Write a MATLAB function subroutine bn.atleast.m, with the top line P = bn_atleast(p, N, k), calculating P = P{A occurs at least k times in the N trials} based on subroutine bn_exact.m, where p = P{A} is the probability of event A on any single trial; Nis the total number of trials; and k is the number of occurrences of event A.
  • Find P for p = 0.36643, N = 120,and k = 47. Also find P for p = 0.5, N = 100, and k = 50.

4 件のコメント

Geoff Hayes
Geoff Hayes 2022 年 3 月 30 日
@dlafont - what have you tried so far? Have you already written the function bn_exact?
dlafont
dlafont 2022 年 3 月 30 日
This is my codes and no matter how I adjust them I keep getting these erros
Torsten
Torsten 2022 年 3 月 31 日
function p = bn_exact(p,N,k)
does not work.
Rename one of the p's, e.g.
function P = bn_exact(p,N,k)
dlafont
dlafont 2022 年 3 月 31 日
Forgot to add in previous comment, this is the error
To many output arguments in this code

サインインしてコメントする。

回答 (1 件)

Geoff Hayes
Geoff Hayes 2022 年 3 月 31 日

0 投票

@dlafont - I think you need to update your bn_atleast function so that it returns something. Probably P
function P = bn_atleast(p,N,k)
P = 0; % not lower-case p
for i = k:N
P = P + bn_exact(k,N,p);
end
I have no idea if the code returns the correct value, but now it will return something and that should correct the "too many output" arguments error.

カテゴリ

質問済み:

2022 年 3 月 30 日

回答済み:

2022 年 3 月 31 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by