Solved

# why 1/Double.Epsilon gives infinity?

Posted on 2011-03-02
367 Views
Last Modified: 2012-05-11
why 1/Double.Epsilon gives infinity?
0
Question by:dadadude
• 6
• 4
10 Comments

LVL 44

Expert Comment

I was just about to say that in response to your (just deleted) question.
0

LVL 44

Expert Comment

Basically epsilon is the smallest number that can be represented by a double, just a fraction above zero.  Trying to divide one by epsilon just isn't handled by the .net framework.

Back to your original question - you need to set a limit below which the function isn't being called, rather than trying to hack around it by adding epsilon
0

Author Comment

well the other question was complicated i wanted to make it simpler lol.
i found that on google:
double.Epsilon is denormalized, so it is smaller than 2**(min exponent). There is no equivalent of denormalization for extremely large values, so the reciprocal is too large to be representable.
0

Author Comment

Andy what do u mean by:
Back to your original question - you need to set a limit below which the function isn't being called, rather than trying to hack around it by adding epsilon
0

Author Comment

Do you mean that there might be something wrong in the function.?
actually sigma is the Standard deviation:
``````public static double StandardDeviation(List<double> num)
{
double SumOfSqrs = 0;

double avg = num.Average();

for (int i = 0; i < num.Count; i++)
{
SumOfSqrs += Math.Pow(((double)num[i] - avg), 2);
}

double n = (double)num.Count;
if (n == 1)
{
return Math.Sqrt(SumOfSqrs);
}
else
{
return Math.Sqrt(SumOfSqrs / (n - 1));
}
}
``````
0

LVL 44

Accepted Solution

AndyAinscow earned 500 total points
Your other question where you attempted to add the value epsilon to prevent a divide by zero error.
Instead you need to check if the value you are going to divide by is below a limit (up to you how much it is) and then return a suitable default value.
0

LVL 44

Expert Comment

public static double StandardDeviation(List<double> num)
That looks OK, but that isn't the function in the deleted question:

I am having a problem with non-numerical
if sigma = 0;
it is always giving Non-numerica even if i add Double.Epsilon
double weight = (1.0 /( Math.Sqrt(2.0 * Math.PI * sigma + Double.Epsilon)+Double.Epsilon))*Math.Exp(-Math.Pow((double)s1.Count-mu,2.0)/(Math.Pow(sigma+Double.Epsilon,2.0)));
0

Author Comment

oh ok I understand.
yes i think that you are right.
anyway thanks for your help. always a pleasure.
i finish my work on the code today, i still have to normilize  the matrix.

Take care.
0

Author Comment

yes exactly I am computing the gaussian function to weight my values.
0

Author Comment

The formula is very complicated . I posted it many times in here. but i got no answer for weeks sometimes.
if u are interested you can check: Levine-nazif Inter cluster contrast and intra-cluster uniformity.
0

## Join & Write a Comment Already a member? Login.

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

#### 744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

#### Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!