Message Boards Message Boards

0
|
7996 Views
|
11 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Histogram problem

Posted 10 years ago

I want to plot a Histogram,

 Mu = Mean[Hamerdif];
    Sigma = StandardDeviation[Hamerdif];
    ir1 = Histogram[Hamerdif, {\[Sigma]/2^6}, "PDF"];

But sometimes I have the next error. I do not understand why.

Power::infy: Infinite expression 1/0 encountered. >>
Infinity::indet: Indeterminate expression 0. ComplexInfinity encountered. >>
11 Replies
Posted 10 years ago

Finally I have noticed that something is wrong with Mathematica 10.2 version. For example with Mathematica 9.0 the execution is right.

Histogram does a lot, but I've found it can be a bit wonky with some data sets. As noted scaling may be an issue, but I have no idea what the underlying algorithm scheme is. Just for fun try to Histogram the following set of numbers: {1, 6^-8, -3^-8, -6^-8, -8^-8, 3*^-8}. On my machine (Mac, 10.2.0.0) it hangs until I abort it. This is a pared down version of a case I actually ran into - confused me for a while.

POSTED BY: Michael Burns

My Mathematica does not hang (Mavericks with 10.2.0) but the computation takes ~18 seconds roughly...

POSTED BY: Sander Huisman
Posted 10 years ago

I think a normalization of the numbers could be a solution. Thanks for your help.

Perhaps your numbers are too small. If I rescale them I get no errors:

Hamerdif = 10^17*{-7.75205766163486/10^17, -5.629097590588154/10^17, 
         -7.30880056733321/10^18, 8.376594318634389/10^17, 
    7.959982479649063/10^18, 
         -5.850425470324006/10^17, -7.563430648620345/10^17, 
    8.99610086221389/10^17, 
         8.047050888271066/10^17, 4.95873023031791/10^17}; 
Sigma = StandardDeviation[Hamerdif];
ir1 = Histogram[Hamerdif, {Sigma/2^6}, "PDF"]
POSTED BY: Gianluca Gorni

Strange. On my system (Mma 10.2 and Mac) I get a good histogram and no errors.

Attachments:
POSTED BY: Gianluca Gorni
Posted 10 years ago

I send you my values again. I think it is better to probe with the same "InputForm" values, Hamerdif = {-7.75205766163486^-17, -5.629097590588154^-17, -7.30880056733321^-18, 8.376594318634389^-17, 7.959982479649063^-18, -5.850425470324006^-17, -7.563430648620345^-17, 8.99610086221389^-17, 8.047050888271066^-17, 4.95873023031791^-17}; Sigma = StandardDeviation[Hamerdif]; ir1 = Histogram[Hamerdif, {Sigma/2^6}, "PDF"]

Posted 10 years ago

I get no errors on 10.2 running on Win 7.

enter image description here

POSTED BY: David Keith

What is Hamerdif? If it is a list of numbers I get no errors:

Hamerdif = {1, 2, 3, 4, 5};
Sigma = StandardDeviation[Hamerdif];
ir1 = Histogram[Hamerdif, {Sigma/2^6}, "PDF"]
POSTED BY: Gianluca Gorni
Posted 10 years ago

I get error for the next example: Hamerdif = {-7.7520610^-17, -5.629110^-17, -7.308810^-18, 8.3765910^-17, 7.9599810^-18, -5.8504310^-17, 7.5634310^-17, 8.996110^-17, 8.0470510^-17, 4.9587310^-17}; Sigma = StandardDeviation[Hamerdif]; ir1 = Histogram[Hamerdif, {Sigma/2^6}, "PDF"]

Posted 10 years ago

It's difficult to say without the data, but:

  1. The square brackets in the binspec should be deleted. In Mathematica they are for function arguments.
  2. The binspec calls for bin sizes of 1/2000000 * the standard deviation, which seems crowded.
  3. It is best to begin user symbol names with lower case to avoid conflict with reserved names, which Mathematica begins in upper case.

Best, David

POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract