2
$\begingroup$

I have a code:-

Plot[Evaluate@PDF[NormalDistribution[1.6, 0.2], x], {x, -6, 6}]

And then I got the warning: General::munfl: Exp[-721.953] is too small to represent as a normalized machine number; precision may be lost. However, if I removed Evaluate, the warning disappears. Why would that? Would that matter?

I need to keep the Evaluate, since I am drawing various distributions.

Thanks in advance!

$\endgroup$
10
$\begingroup$

When you use Evaluate, the PDF evaluates to an exponential:

pdf = PDF[NormalDistribution[1.6, .2], x]

1.99471 E^(-12.5 (-1.6 + x)^2)

When you evaluate this object with a large enough number x (on the order of 10), the resulting object is too small to represent as a machine number:

pdf /. x -> 10

General::munfl: Exp[-882.] is too small to represent as a normalized machine number; precision may be lost.

0.

Let's check. The smallest machine number is:

$MinMachineNumber

2.22507*10^-308

If we convert the pdf expression to one using extended precision numbers:

epdf = SetPrecision[pdf, 20];

and then evaluate epdf at 10:

epdf /. x->10

1.7870924971057366*10^-383

We see that the result is much smaller than the smallest possible machine number. This is why evaluating pdf at 10 produces an error message and Mathematica returns 0.

Now, when you remove the Evaluate, then Plot only evaluates the PDF object when it is numerical, and this doesn't produce any messages:

PDF[NormalDistribution[1.6, .2], 10]

1.787092497106*10^-383

Of course, the above output is not a machine number:

Precision @ PDF[NormalDistribution[1.6, .2], 10]

13.0095

If you are multiplying extremely small numbers with extremely large numbers, then setting the small numbers to zero can be an issue. In that case, it makes sense to work with extended precision numbers instead.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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