how can i solve equation with summation

1 回表示 (過去 30 日間)
Fatma Abdullah
Fatma Abdullah 2017 年 5 月 30 日
コメント済み: Rik 2017 年 5 月 30 日
i can't solve the attached img equation on matlab for : Pfa=10^(-6),M=8,i=s=1
(later i would change these variables)
i tried the following but errors rises
if true
M=8;
s=1;
i=s;
syms pfal M i s
eqn = symsum((nchoosek(M,i)*(pfal)^(i)*(1-pfal)^(M-i)), i, s, M)==8*10^(-6);
solve(eqn,pfal)
end

採用された回答

Rik
Rik 2017 年 5 月 30 日
I think I can read the summation index: it is an i. That would mean that you should initiate i as a sym not as a hard-coded value, and thus the result from nchoosek changes each summation part.
M=8;
s=1;
syms pfal i
f = nchoosek(M,i);
eqn = (symsum(f*(pfal)^(i)*(1-pfal)^(M-i), i, s, M)==10^(-6));
solve(eqn,pfal)
This exits without error, but results in 8 solutions, 6 of which are complex. One solution is indeed equal to the solution that Roger suggested (1.25e-7).
  4 件のコメント
Fatma Abdullah
Fatma Abdullah 2017 年 5 月 30 日
sorry to bother but i got that weird error:
Error using mupadmex Error in MuPAD command: Unexpected ']'. [line 1, col 44]
Error in sym/subsref (line 1577) B = mupadmex('symobj::subsref',A.s,inds{:});
Error in OSSOCFAR (line 11) result=result( result<1 & abs(imag(result))<2*eps );
Rik
Rik 2017 年 5 月 30 日
Ah, my bad, I forgot to add the line that converts to double.
result=solve(eqn,pfal);
result=double(result);
result=result( result<1 & abs(imag(result))<2*eps );

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

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2017 年 5 月 30 日
If I interpret your code correctly, you are doing things the hard way. Your expression for Pfa is simply the binomial expansion of ((Pfa1+(1-Pfa1))^M without the first term where i is equal to zero. Hence, you are trying to solve
(Pfa1 + (1-Pfa1))^8 = 1 = 10^(-6) + (1-Pfa1)^8
whose solution is easily found as
Pfa1 = 1 - 0.999999^(1/8)
Probably the cause of your error message is the reference to the numeric function ‘nchoosek’.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by