Message Boards Message Boards

0
|
1469 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Difference between Sum and NSum?

Posted 1 year ago

I have to compute this,image

I have written the Mathematica code, keeping Ta, and Tb as variables. Later we will compute prob[1,0,1,0,Ta,Tb]

In[75]:= prob[i_,j_,k_,l_,Ta_,Tb_]:= Sum[Binomial[ip,i]*Ta^i*(1-Ta)^(ip-i)*Binomial[jp,j]*Ta^j*(1-Ta)^(jp-j)*Binomial[kp,k]*Tb^k*(1-Tb)^(kp-k)*Binomial[lp,l]*Tb^l*(1-Tb)^(lp-l),{ip,1,Infinity},{jp,1,Infinity},{kp,1,Infinity},{lp,1,Infinity}];
In[80]:= prob[1,0,1,0,Ta,Tb]
Out[80]= ((-1+Ta) (-1+Tb))/(Ta^2 Tb^2)

My question is, 1. I have seen that if I use NSum in place of sum it takes too much to compute prob[1,0,1,0,Ta,Tb] what is the difference between sum and NSum here?
2. what will be a good idea to use here sum or NSum as I think Sum is not giving correct answer.(or maybe I am wrong that it is giving the correct answer)

POSTED BY: Indranil Maiti
2 Replies
Posted 1 year ago

Why do you think using Sum gives the wrong answer? There's no need to use NSum.

The way you've constructed the sum can be simplified and you have the product of 4 separate terms:

p[i_, t_] := Sum[Binomial[n, i]*t^i*(1 - t)^(n - i), {n, 1, \[Infinity]}]
prob[i_, j_, k_, l_, Ta_, Tb_] := p[i, Ta] p[j, Ta] p[k, Tb] p[l, Tb]
prob[1, 0, 1, 0, Ta, Tb]
(* ((1 - Ta) (1 - Tb))/(Ta^2 Tb^2) *)

Addition:

It appears that p[i, t] equals $-1+1/t$ for $i=0$ and $1/t$ for $i>0$ (with $i$ being a non-negative integer). That simplifies things considerably.

POSTED BY: Jim Baldwin

Thanks for your response

POSTED BY: Indranil Maiti
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract