I am running these following code in Mathematica. But, MMA does not output anything. It is giving me an message as "The integrand .... has evaluated to non-numerical values for all sampling points in the \ region with boundaries {{[Infinity],1.}}".

$$\mathcal{L}_{I_{\text{M}}}[s]=\exp\left(-\pi p_b\lambda_{\text{M}}\mathbb{E}_H\left(\int_r^\infty\left(1-\exp\left(-sP_{\text{M}}Hr^{-1/\delta}\right)\right){\rm{d}}r\right)\right)$$

Note that when I put $K=0$, it works fine and gives me the expected result. But, for other values of $K$, It gives me the error.

  • $\begingroup$ Your LI which is equal to your M and then your B is not a number.... When your code doesn't run you should try to track back and find where the error is occuring. $\endgroup$ – Quantum_Oli May 12 '16 at 9:00
  • $\begingroup$ @Quantum_Oli, Yes, it is true. $B$ is a function of $r$. Note that this MMA code works fine for $K=0$. $\endgroup$ – Srestha Narayanan May 12 '16 at 9:02
  • $\begingroup$ In this case Expectation[int, h \[Distributed] ProbabilityDistribution[f[h], {h, 0, Infinity}]] is not returning a numerical value. (Even if it has a numerical r). $\endgroup$ – Quantum_Oli May 12 '16 at 9:03
  • $\begingroup$ @Quantum_Oli, is there anything that I can do? $\endgroup$ – Srestha Narayanan May 12 '16 at 9:31
  • 2
    $\begingroup$ Can you break your problem down and achieve intermediate steps? For example, what is the desired behaviour of LI? Is it a variable or a function? You'll likely have to attack the implementation of LI numerically with either NExpectation or just use NIntegrate. $\endgroup$ – Quantum_Oli May 12 '16 at 11:14

The problem is that Expectation does not evaluate to a numeric result in all cases. It's also quite slow. You could replace it by NExpectation in the final integrand. I threw in an extra N for just to be sure. It takes so long to evaluate, I didn't have time to experiment.

AverageProbSuccess[B_, λ_] := Block[{n = 0, i, Expectation},
   i[r0_?NumericQ] := 
    Block[{r = r0}, 
     B*2*Gamma[λ*π + 1]/Gamma[λ*π]*
        r*(1 - r^2)^(-1 + λ*π) /. 
       Expectation -> NExpectation // N];
   NIntegrate[i[r], {r, 0, Infinity},
    PrecisionGoal -> 4, AccuracyGoal -> 4, MaxRecursion -> 1,
    EvaluationMonitor :> If[Mod[++n, 10] == 0, Print[n]]]
   ] // AbsoluteTiming

Print["Starting AverageProbSuccess"]

AverageProbSuccess[B, λ]

Mathematica graphics

Not too surprising maybe, that it doesn't converge, since the following is so big:

Block[{r = 10.^12, Expectation = NExpectation},
 B*2*Gamma[λ*π + 1]/Gamma[λ*π]*
  r*(1 - r^2)^(-1 + λ*π)
(*  5.5*10^9232413018186 + 1.42*10^9232413018186 I  *)

Block[{r = 10.^15, Expectation = NExpectation},
 B*2*Gamma[λ*π + 1]/Gamma[λ*π]*
  r*(1 - r^2)^(-1 + λ*π)

General::ovfl: Overflow occurred in computation. >>

(*  Overflow[]  *)
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.