1
$\begingroup$

In a simulation, I got the following error message:

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

The reason why I think this happens, it's because in the next portion of code, data is a list that may get very small numbers, at the edge of machine precision, and I need to normalize them to 1, but in a way that they may be used as probabilities for a Multinomial Distribution.

Normalize[Threshold[Normalize[data, Total], $MachineEpsilon/10], 
  Total];

This is the only place in my programme where I use Normalize. The problem is that I haven't been able to reproduce that error message... So, I'm not sure how to correct it. Any help would be appreciated.

$\endgroup$
  • 2
    $\begingroup$ "Normalized machine number" is unrelated to Normalize. It refers to this: en.wikipedia.org/wiki/Denormal_number $\endgroup$ – Szabolcs Apr 14 at 8:07
  • 1
    $\begingroup$ The actual problem is this: Exp[-709.859] < $MinMachineNumber. $\endgroup$ – Henrik Schumacher Apr 14 at 8:28
  • 1
    $\begingroup$ @HenrikSchumacher Many thanks for that piece of information. It gives me a precious hint on how to deal with this. ;) $\endgroup$ – An old man in the sea. Apr 14 at 8:31
  • 1
    $\begingroup$ You're welcome! $\endgroup$ – Henrik Schumacher Apr 14 at 8:32
  • 1
    $\begingroup$ Yes, the usual hardware floating point representation works down to $MinMachineNumber. There is a small range below $MinMachineNumber that is still representable with compromises: precision will be lost and performance will be bad. These are "denormal numbers". Below that range, number just can't be represented as machine numbers at all (they can using Mathematica's arbitrary precision numbers). $\endgroup$ – Szabolcs Apr 14 at 8:54

Your Answer

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

Browse other questions tagged or ask your own question.