1

I need to create random numbers between 100,000 and 100,000,000 using Erlang distribution. As it mentioned on the linked page, parameter x could be any number [0, +infinity); hence my range of values is theoretically acceptable.

However, when calculating the probability density function, the returned value is always 0 and that is because raising e to the power of -\lambda * x which with such big x values is always zero.

I need to be able to raise e to such big powers (indeed very small powers (e.g., -40,000)). My application is in .NET4.5 and I checked system.numerics namespace. However, so far I was not able to figure out how to perform this calculation.

Dr. Strangelove
  • 2,725
  • 3
  • 34
  • 61
  • Is there a reason to use c# explicitly ? Maybe something like Fortran or other math friendly language would be better ? and then just reference a .dll in yiur .net solution ? – Marty Jan 31 '16 at 21:42
  • well, that would be an option, but for now I would rather stick to C#. – Dr. Strangelove Jan 31 '16 at 21:45
  • 1
    To be close to C# you could use F# and the F# PowerPack. There you have a type `complex` which represents nearly everything. And you can use this in C# aswell. Behind `complex` BigRational is used. – Benjamin Abt Jan 31 '16 at 22:03

2 Answers2

2

For big floating point numbers you could use BigRational. This answer has a nice explanation about it.

Community
  • 1
  • 1
Teodor Kurtev
  • 1,049
  • 1
  • 13
  • 24
0

The default floating point numbers in .NET don't have the precision that you are looking for, because as you pointed out, the value of such exponents is smaller than the precision of the number (hence the 0 values).

If you want to stick to C#, why not use a wrapper for an arbitrary precision library.

http://gnumpnet.codeplex.com/

Geoffrey
  • 956
  • 1
  • 10
  • 16