Solved

why 1/Double.Epsilon gives infinity?

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

Expert Comment

by:AndyAinscow
ID: 35019856
I was just about to say that in response to your (just deleted) question.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 35019875
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

by:dadadude
ID: 35019879
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 

Author Comment

by:dadadude
ID: 35019892
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

by:dadadude
ID: 35019914
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));
        }
    }

Open in new window

0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 35019925
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

by:AndyAinscow
ID: 35019949
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

by:dadadude
ID: 35019962
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

by:dadadude
ID: 35019974
yes exactly I am computing the gaussian function to weight my values.
0
 

Author Comment

by:dadadude
ID: 35019986
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

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

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

Join & Ask a Question