Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5925
| From | Andrew Moylan <amoylan@wolfram.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: A Problem seemingly with NIntegrate |
| Date | 2011-10-27 10:28 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j8bbo1$8g1$1@smc.vnet.net> (permalink) |
Hi, Please try this:
In[40]:= K[
m_] := (4 Sqrt[Pi] Gamma[2 m] m^(2 m))/(Gamma[m]^2 Gamma[
2 m + 1/2] 2^(4 m - 1) \[CapitalOmega]^(2 m));
In[41]:= f1[r_] :=
K[m] r^(4 m - 1) Hypergeometric1F1[2 m,
2 m + 1/2, (m r^2)/(2 \[CapitalOmega])] Exp[-m r^2/\[CapitalOmega]]
In[42]:= f2[r_] := 1/(Sqrt[2 Pi] \[Sigma]) Exp[-r^2/(2 \[Sigma]^2)];
In[43]:= Clear[f3];
f3[z_?NumberQ] :=
Module[{x}, NIntegrate[1/x f1[x] f2[z/x], {x, 0, Infinity}]]
In[45]:= Block[{m = 1, \[CapitalOmega] = 1, \[Sigma] = 1},
NIntegrate[f3[x], {x, -\[Infinity], \[Infinity]}]]
Out[45]= 1.
Here are the changes I made:
- Use Module[{x}, ...] in definition of f3, to avoid confusing an x passed as an argument with the integration dummy variable x.
- Add a condition to f3 since f3[z] only makes sense for a specific numerical value NumberQ[z].
- Use specific numerical values for the parameters m = 1, \[CapitalOmega] = 1, \[Sigma] = 1 (probably you just forgot these in your original question).
- Integrate from -Infinity to Infinity which was your intention anyway.
I hope this helps you.
Regards,
Andrew Moylan
Wolfram Research
----- Original Message -----
> From: "choco munch" <choceam@gmail.com>
> To: mathgroup@smc.vnet.net
> Sent: Friday, October 21, 2011 3:26:05 AM
> Subject: A Problem seemingly with NIntegrate
>
> Hi,
>
> Here is my problem. I have two PDFs (Probability Density Functions).
> One is a sum of 2 IID Nakagami-m and the other is a zero mean
> Guassian. I am constructing a new RV which is the product of these
> two, so I have in effect:
> Z = (X1 + X2)*N = X12*N
> X1, X2 are distributed IID Nakagami and N is a zero mean Normal RV.
>
> Now I know how to compute the PDF of Z by using PDF_Z[z_] :=
> NIntegrate[1/x PDF_X12[x]* PDF_N[z/x], {x, 0, Infinity}]
>
> Unforutantely, when i do this
>
> NIntegrate[PDF_Z[z], {z, -Infinty, Infinty}] I do not get 1.
>
> there is something going on with NIntegrate here, but I don't know
> what. Here is the code:
>
> ==========================================================================
> (*K[m] is just a constant *)
> K[m_] := (4 Sqrt[Pi] Gamma[2 m] m^(2 m))/(Gamma[m]^2 Gamma[2 m + 1/2]
> 2^(4 m - 1) \[CapitalOmega]^(2 m));
>
> (*f1 is the sum of two Nakagami's*)
> f1[r_] := K[m] r^(4 m - 1) Hypergeometric1F1[2 m, 2 m + 1/2, (m r^2)/
> (2 \[CapitalOmega])] Exp[-m r^2/\[CapitalOmega]]
>
> (*f2 is the standard normal *)
> f2[r_] := 1/(Sqrt[2 Pi] \[Sigma]) Exp[-r^2/(2 \[Sigma]^2)];
>
> (*f3 is the product of X1+X2 and N*)
> f3[z_] := NIntegrate[1/x f1[x] f2[z/x], {x, 0, Infinity}]
>
> (*here is the problem*)
>
> NIntegrate[f3[x], {x, -10, 10}]
>
> (*this will not give 1, why? I have checked both f1 and f2, they are
> valid PDFs*)
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: A Problem seemingly with NIntegrate Andrew Moylan <amoylan@wolfram.com> - 2011-10-27 10:28 +0000
csiph-web