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*@virtualscie nces.nl 8 1806
"Michel" <ms*@virtualsci ences.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
hand-translate 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*@virtualsci ences.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*@virtualscie nces.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******** ********@TK2MSF TNGP12.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 hand-translate 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*@virtualsci ences.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*@virtualscie nces.nl
"Michel" <ms*@virtualsci ences.nl> wrote in message news:<bp******* ***@reader11.wx s.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*@virtualscie nces.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
floating-point 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*@virtualsci ences.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******** ********@TK2MSF TNGP12.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 hand-translate 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*@virtualsci ences.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*@virtualscie nces.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.co m> 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.o rg> wrote in message
news:uD******** ******@TK2MSFTN GP09.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 thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: f |
last post by:
I have this
double sum, a, b, c;
sum = a + b + c;
printf("%.20f = %.20f, %.20f, %.20f", sum, a, b, c);
I found that the debug version and release version of the same code
give me different result. I am using VC++ 6.0.
In debug version, the print out is:
|
by: Christian Christmann |
last post by:
Hi,
just a general question.
Which data type is more precise for large values:
float or double?
Thank you.
Chris
|
by: Bjørn Augestad |
last post by:
Below is a program which converts a double to an integer in two
different ways, giving me two different values for the int. The basic
expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable
becomes 364 and the other one becomes 365.
Does anyone have any insight to what the problem is?
Thanks in advance.
Bjørn
|
by: Michel |
last post by:
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...
|
by: Bryan Parkoff |
last post by:
The guideline says to use %f in printf() function using the keyword
float and double.
For example
float a = 1.2345;
double b = 5.166666667;
printf("%.2f\n %f\n", a, b);
| |
by: lcw1964 |
last post by:
This may be in the category of bush-league rudimentary, but I am quite
perplexed on this and diligent Googling has not provided me with a
clear straight answer--perhaps I don't know how to ask the quesion.
I have begun to familiarize myself here with the gcc compiler in a
win32 environment, in the form of MinGW using both Dev C++ and MSYS as...
|
by: Dilip |
last post by:
Recently in our code, I ran into a situation where were stuffing a
float inside a double. The precision was extended automatically
because of that. To make a long story short, this caused problems
elsewhere in another part of the system where that figure was used for
some calculation and some eventual truncation led to the system going...
|
by: Alexander Stoyakin |
last post by:
Hello,
please advise on the following issue. I need to check that difference
between two double values is not higher than defined limit.
int main()
{
double limit = 0.3;
double val1 = 0.5, val2 = 0.2;
if ( (val1 - val2) limit )
|
by: md |
last post by:
Hi
Does any body know, how to round a double value with a specific number
of digits after the decimal points?
A function like this:
RoundMyDouble (double &value, short numberOfPrecisions)
It then updates the value with numberOfPrecisions after the decimal
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |