Post Reply 
Integration with series.
05-17-2021, 10:54 PM (This post was last modified: 05-18-2021 12:40 AM by t_angenbrandt.)
Post: #1
Integration with series.
The CAS does not detect that a series is 0 for the PDF of the binomial random distribution above k=n, so there are some simplifications that can be made with this assumption;
   
I use the following program to calculate the variance in the value-domain:

Code:

// Erwartungswert für eine gegebene PDF p_func(p_var)
function s_e(p_func,p_var)
local i_func:=subst(p_func,p_var=ivar);
return ∫(ivar*i_func,ivar,-inf,inf);
END;

// Varianz für eine gegebene PDF p_func(p_var).
function s_var(p_func,p_var)
local i_func:=subst(p_func,p_var=ivar);
r := ∫(ivar^2*i_func,ivar,-inf,inf)-(s_e(p_func,p_var))^2;
r := subst(r,ivar=p_var);
return r;
END;

The program is limited for binomial distribution that has been defined as a continuous function using Dirac():
It is basically identical to the usual schoolbook definition, but extended for a continuous argument.
Code:

function s_pdf_binom(n, p,var)
return sum(p^var*(-p+1)^(-var+n)*Dirac(-a+var)*n!/(var!*(-var+n)!),a,0,n);
END;

When this function, s_pdf_binom... is applied to s_var(), I get an integral as an answer (indicating that CAS could not integrate it).

Example:
Code:

s_var(s_pdf_binom(n,p,x),x) -> -integrate(x*sum(Dirac(-a+x)*e^(n*ln(-p+1)+x*ln(p)-x*ln(-p+1))*n!/(x!*(n-x)!),a,0,n),x,-±∞,∞)^2+integrate(x^2*sum(Dirac(-a+x)*e^(n*ln(-p+1)+x*ln(p)-x*ln(-p+1))*n!/(x!*(n-x)!),a,0,n),x,-±∞,∞)
   

Now here is what I want:
How can I get some hint from the CAS, that it has failed to integrate something or has done something else that does not give me a desired result?

One obvious way is simply by looking for "integrate" or "∫" characters in a string that is returned when integration is complete so that the program can then take a different approach to get the CAS to return a useful result.
But is there a more elegant solution like some function I can call to check for CAS behaviour without assuming the variables all the time?

(Not important but for the interested ones: for this example one might take the fourier-transform and evaluate it at s=0 for the mean value. The CAS perfectly works with this approach, but it takes sometimes a long time to calculate, so it is not always desirable.).
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: