Hi there,
I need to make a poisson distribution function that uses:
double Math.Exp(double d)
The d argument is a negative number in my case. When d becomes bigger and
bigger, the result loses precision and is finally 0 (when d reaches 650)
because it is too small to fit in a double. In my case, d can become 10000,
so I need to have a greater precision number and Exp function.
I've looked at decimal, but it cannot contain as small a number as double
(just try to put a small double in a decimal and the decimal will be 0).
Furthermore, there is no Math.Exp overload that takes decimals.
Any suggestions anyone?
Thanks,
Michel ms*@virtualsciences.nl 8 1627
"Michel" <ms*@virtualsciences.nl> wrote in message
news:bp**********@reader11.wxs.nl... Any suggestions anyone?
Maybe a good opportunity to try a Fortran compiler for .NET, I've found
some: http://www.salfordsoftware.co.uk/com...5/dotnet.shtml http://www.lahey.com/lf70/lfnet.htm
These compilers will probably handle numeric types with a higher precision
or provide a better implementation of Math functions. You can write a
component in Fortran.NET that does the job but you must remember that the
interface with this component must only use CLS compliant types,
System.Double or System.Decimal in your case.
Given the size of the value you're passing, I don't think there's any type
that would work well. I can think of a few things to try:
1) Find a library that supports larger exponents. There may be some on this
page  http://www.oonumerics.org/oon/  but my guess is that you won't find
a C# one. You might be able to find a free Java one and either
handtranslate or run the Java Language Conversion Assistant on it (assuming
the license allows that).
2) Modify your calculation so that you don't need to compute the entire
value all at once. If, for example, you are going to multiply this by
something that is pretty big, you can factor apart the calculation, apply
Math.Exp(10) 4 times to get the equivalent of Math.Exp(10000)
Hope that helps.

Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michel" <ms*@virtualsciences.nl> wrote in message
news:bp**********@reader11.wxs.nl... Hi there,
I need to make a poisson distribution function that uses:
double Math.Exp(double d)
The d argument is a negative number in my case. When d becomes bigger and bigger, the result loses precision and is finally 0 (when d reaches 650) because it is too small to fit in a double. In my case, d can
become 10000, so I need to have a greater precision number and Exp function.
I've looked at decimal, but it cannot contain as small a number as double (just try to put a small double in a decimal and the decimal will be 0). Furthermore, there is no Math.Exp overload that takes decimals.
Any suggestions anyone? Thanks, Michel ms*@virtualsciences.nl
Hi Eric,
I'd like to try breaking the calculation up.
How do I get from Math.Exp(10) back to Math.Exp(10000)?
I've done some testing....
Math.Exp(4) = Math.Exp(2) * Math.Exp(2)
However, this doesn't apply to e.g. 100:
Math.Exp(100) != Math.Exp(10) * Math.Exp(10).
Also, my input is not as "nice" as 10000, it'll be more like 1234,56.
Thanks,
Michel
"Eric Gunnerson [MS]" <er****@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Given the size of the value you're passing, I don't think there's any type that would work well. I can think of a few things to try:
1) Find a library that supports larger exponents. There may be some on
this page  http://www.oonumerics.org/oon/  but my guess is that you won't
find a C# one. You might be able to find a free Java one and either handtranslate or run the Java Language Conversion Assistant on it
(assuming the license allows that). 2) Modify your calculation so that you don't need to compute the entire value all at once. If, for example, you are going to multiply this by something that is pretty big, you can factor apart the calculation, apply Math.Exp(10) 4 times to get the equivalent of Math.Exp(10000)
Hope that helps.
 Eric Gunnerson
Visit the C# product team at http://www.csharp.net Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no
rights. "Michel" <ms*@virtualsciences.nl> wrote in message news:bp**********@reader11.wxs.nl... Hi there,
I need to make a poisson distribution function that uses:
double Math.Exp(double d)
The d argument is a negative number in my case. When d becomes bigger
and bigger, the result loses precision and is finally 0 (when d reaches 650) because it is too small to fit in a double. In my case, d can become 10000, so I need to have a greater precision number and Exp function.
I've looked at decimal, but it cannot contain as small a number as
double (just try to put a small double in a decimal and the decimal will be 0). Furthermore, there is no Math.Exp overload that takes decimals.
Any suggestions anyone? Thanks, Michel ms*@virtualsciences.nl
"Michel" <ms*@virtualsciences.nl> wrote in message news:<bp**********@reader11.wxs.nl>... Hi there,
I need to make a poisson distribution function that uses:
double Math.Exp(double d)
The d argument is a negative number in my case. When d becomes bigger and bigger, the result loses precision and is finally 0 (when d reaches 650) because it is too small to fit in a double. In my case, d can become 10000, so I need to have a greater precision number and Exp function.
I've looked at decimal, but it cannot contain as small a number as double (just try to put a small double in a decimal and the decimal will be 0). Furthermore, there is no Math.Exp overload that takes decimals.
Any suggestions anyone? Thanks, Michel ms*@virtualsciences.nl
If you look at http://groups.google.com/gr*********...ing.google.com
you'll see a discussion on how to calculate probabilities associated
with the Poisson distribution.
Ian Smith
Michel,
exp(100) == exp(10) * exp(10)
in mathematical terms. It's not equal in the computer, however, because the
floatingpoint representation is inexact.
I'm assuming that you would multiplying this the result of exp(10000) by a
large positive number. If not, then your result might be outside the range
of double anyway.
I hope that helps. If you have more questions, please give us some more
information on what you're trying to do and what algorithm you're using.

Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Michel" <ms*@virtualsciences.nl> wrote in message
news:bq**********@reader11.wxs.nl... Hi Eric,
I'd like to try breaking the calculation up. How do I get from Math.Exp(10) back to Math.Exp(10000)? I've done some testing.... Math.Exp(4) = Math.Exp(2) * Math.Exp(2)
However, this doesn't apply to e.g. 100: Math.Exp(100) != Math.Exp(10) * Math.Exp(10).
Also, my input is not as "nice" as 10000, it'll be more like 1234,56.
Thanks, Michel
"Eric Gunnerson [MS]" <er****@online.microsoft.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Given the size of the value you're passing, I don't think there's any
type that would work well. I can think of a few things to try:
1) Find a library that supports larger exponents. There may be some on this page  http://www.oonumerics.org/oon/  but my guess is that you won't find a C# one. You might be able to find a free Java one and either handtranslate or run the Java Language Conversion Assistant on it (assuming the license allows that). 2) Modify your calculation so that you don't need to compute the entire value all at once. If, for example, you are going to multiply this by something that is pretty big, you can factor apart the calculation, appl
y Math.Exp(10) 4 times to get the equivalent of Math.Exp(10000)
Hope that helps.
 Eric Gunnerson
Visit the C# product team at http://www.csharp.net Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights. "Michel" <ms*@virtualsciences.nl> wrote in message news:bp**********@reader11.wxs.nl... Hi there,
I need to make a poisson distribution function that uses:
double Math.Exp(double d)
The d argument is a negative number in my case. When d becomes bigger and bigger, the result loses precision and is finally 0 (when d reaches
650) because it is too small to fit in a double. In my case, d can
become 10000, so I need to have a greater precision number and Exp function.
I've looked at decimal, but it cannot contain as small a number as double (just try to put a small double in a decimal and the decimal will be
0). Furthermore, there is no Math.Exp overload that takes decimals.
Any suggestions anyone? Thanks, Michel ms*@virtualsciences.nl
Michel & Eric, exp(100) == exp(10) * exp(10)
in mathematical terms.
Nope, exp(10) * exp(10) == exp(20)
Mattias

Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Eric Gunnerson [MS] <er****@online.microsoft.com> wrote: exp(100) == exp(10) * exp(10)
in mathematical terms.
No it doesn't. exp (10) * exp(10) = exp (20)
Forget e here, let's take an example which is easier to work with: 3
3^2 * 3^3 = 9*27 = 243
3^(2*3) = 3^6 = 729
3^(2+3) = 3^5 = 243
In general, x^y * x^z = x^(y+z), not x^(y*z)

Jon Skeet  <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thanks Mattias and Jon  you are, of course, correct.

Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uD**************@TK2MSFTNGP09.phx.gbl... Michel & Eric,
exp(100) == exp(10) * exp(10)
in mathematical terms.
Nope, exp(10) * exp(10) == exp(20) Mattias
 Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ Please reply only to the newsgroup. This discussion thread is closed Replies have been disabled for this discussion. Similar topics
32 posts
views
Thread by f 
last post: by

11 posts
views
Thread by Christian Christmann 
last post: by

31 posts
views
Thread by Bjørn Augestad 
last post: by

8 posts
views
Thread by Michel 
last post: by

10 posts
views
Thread by Bryan Parkoff 
last post: by

67 posts
views
Thread by lcw1964 
last post: by

116 posts
views
Thread by Dilip 
last post: by

6 posts
views
Thread by Alexander Stoyakin 
last post: by
           