error in symbolic convolution using integral and isAlways

조회 수: 4 (최근 30일)
Muna Tageldin
Muna Tageldin 2024년 9월 6일
댓글: Torsten 2024년 9월 9일
I want to symbolically integrate the following function using int
This is actually similar to convoution
so this is what I did
syms z alpha lam_f u_f sigma ep
nCk = @(n,kVec,z)arrayfun(@(k)lam_f*exp(-lam_f*alpha).*(nchoosek(n,k)*(1*ep).^(k).*((1-ep)*normcdf(z,u_f,sigma)).^(n-(k)).*(normcdf(alpha-u_f-z,sigma))^k),kVec);
%expo
%tf = isAlways(lam_f > 0 & u_f > 0 & sigma > 0)
F(z,u_f,lam_f,ep)=int(sum(nCk(n,0:n,z)),alpha,0, z,'IgnoreAnalyticConstraints',true);
However, I get the following error
Unable to prove 'z < u_f & sigma == 0' literally. Use 'isAlways' to test the statement mathematically.
I tried also using isAlways
  댓글 수: 5
Muna Tageldin
Muna Tageldin 2024년 9월 8일
This is the random variable I'm trying to integrate where is the rest of summation part as in above
Muna Tageldin
Muna Tageldin 2024년 9월 8일
Do you know if I can numerically solve this CDF because I need to find the mean/average as well

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2024년 9월 6일
normpdf() is not designed to accept symbolic inputs.
You will need to re-implement normpdf without the line
p(sigma==0 & x<mu) = 0;
  댓글 수: 8
Muna Tageldin
Muna Tageldin 2024년 9월 9일
편집: Torsten 2024년 9월 9일
n=3;
syms z positive
syms alpha positive
syms lam_f positive
syms u_f positive
syms sigma positive
syms ep positive
syms z positive
nCk = @(n,kVec,z)arrayfun(@(k)lam_f*exp(-lam_f*alpha).*(nchoosek(n,k)*(1*ep).^(k).*((1-ep)*(0.5+0.5*erf((z-u_f)/(sqrt(2)*sigma)))).^(n-(k)).*(0.5+0.5*erf((z-alpha-u_f)/(sqrt(2)*sigma)))^k),kVec);
F(z,u_f,lam_f,sigma,ep)=int(nCk(n,0:n,z),alpha,0, z)
F(z, u_f, lam_f, sigma, ep) = 
Torsten
Torsten 2024년 9월 9일
If you look at what comes out for F(z,u_f,lam_f,sigma,ep), you'll see that the erf integrals are still left.
No chance for an analytical antiderivative, I guess.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2024년 9월 6일
Are you trying to tell MATLAB that % lam_f > 0 & u_f > 0 & sigma > 0 or are you trying to ask MATLAB if those three conditions are satisfied? Using isAlways asks that question. To tell MATLAB use assume and assumeAlso or tell MATLAB when it creates those symbolic variable that they're all positive, passing the positive option to syms or sym: syms x positive.
  댓글 수: 4
Muna Tageldin
Muna Tageldin 2024년 9월 6일
편집: Walter Roberson 2024년 9월 8일
n=2;
syms z positive
syms alpha positive
syms lam_f positive
syms u_f positive
syms sigma positive
syms ep positive
syms z positive
%assume(z < u_f )
assume (ep <1 & ep>0)
assumeAlso(sigma > 0)
%assume(x/2,"integer")
nCk = @(n,kVec,z)arrayfun(@(k)lam_f*exp(-lam_f*alpha).*(nchoosek(n,k)*(1*ep).^(k).*((1-ep)*normcdf(z,u_f,sigma)).^(n-(k)).*(normcdf(alpha-u_f-z,sigma))^k),kVec);
Error using symengine
Unable to prove 'z < u_f & sigma == 0' literally. Use 'isAlways' to test the statement mathematically.
Muna Tageldin
Muna Tageldin 2024년 9월 6일
편집: Walter Roberson 2024년 9월 8일
The error I got :
Error using symengine
Unable to prove 'z < u_f & sigma == 0' literally. Use 'isAlways' to test the statement mathematically.
Error in sym/subsindex (line 849)
X = find(mupadmex('symobj::logical',A.s,9)) - 1;
Error in sym/privsubsasgn (line 1124)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in sym/subsasgn (line 961)
C = privsubsasgn(L,R,inds{:});
Error in normcdf>localnormcdf (line 109)
p(sigma==0 & x<mu) = 0;
Error in normcdf (line 50)
[varargout{1:max(1,nargout)}] = localnormcdf(uflag,x,varargin{:});
Error in testing_convolution (line 75)
nCk =
@(n,kVec,z)arrayfun(@(k)lam_f*exp(-lam_f*alpha).*(nchoosek(n,k)*(1*ep).^(k).*((1-ep)*normcdf(z,u_f,sigma)).^(n-(k)).*(normcdf(alpha-u_f-z,sigma))^k),kVec);
Error in testing_convolution (line 75)
nCk =
@(n,kVec,z)arrayfun(@(k)lam_f*exp(-lam_f*alpha).*(nchoosek(n,k)*(1*ep).^(k).*((1-ep)*normcdf(z,u_f,sigma)).^(n-(k)).*(normcdf(alpha-u_f-z,sigma))^k),kVec);
Error in testing_convolution (line 81)
F(z,u_f,lam_f,ep)=int(sum(nCk(n,0:n,z)),alpha,0, z);%'IgnoreAnalyticConstraints');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by