comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Histogram
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Histogram [message #44556] Tue, 28 June 2005 09:24 Go to next message
James[1] is currently offline  James[1]
Messages: 9
Registered: August 2004
Junior Member
Hi guys !

I have a question regarding histograms in general. Is there a "right"
criteria (e.g. strict matmematical rule, etc..) of chosing the bin size ?
I'm playing with some data and obviously the histogram looks differently
with different bin sizes. Any help and references would be extremely
helpful !

Cheers,
James
Re: Histogram [message #44610 is a reply to message #44556] Fri, 01 July 2005 11:37 Go to previous messageGo to next message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"James" <adelante@bigmir.net> wrote in message
news:op.ss286rraljbjj6@pc008427.hq.eso.org...
> Hi guys !
>
> I have a question regarding histograms in general. Is there a "right"
> criteria (e.g. strict matmematical rule, etc..) of chosing the bin size ?
> I'm playing with some data and obviously the histogram looks differently
> with different bin sizes. Any help and references would be extremely
> helpful !
>
> Cheers,
> James


It depends on what question the histogram is supposed to answer.

Obviously larger bins will have a smoother appearance, but
perhaps normalizing the bins, so that it is a density rather than a
mere count would help it look more similar for different bin sizes.

(i.e. divide the count in each bin by the binsize)


Cheers,
bob
Re: histogram [message #67695 is a reply to message #44556] Wed, 12 August 2009 07:12 Go to previous messageGo to next message
rinceboy is currently offline  rinceboy
Messages: 5
Registered: March 2009
Junior Member
its just that when I change the max/min limits the histogram changes
shape. But I've realised that its to do with the binsize and thus
alignment with the bin boundaries

Thanks!

On Aug 12, 2:15 pm, James Kuyper <jameskuy...@verizon.net> wrote:
> rinceboy wrote:
>> Won't including a max and min unrealisticaly skew the histogram by
>> introducing false data? e.g. the first dataset ranges between (-50:22)
>> and the second between (-70:24). By using teh same max and min, say
>> -70 and 24 then you're biasing both histograms
>
> No. All it does is change the boundaries of the bins. Why do you think
> that would introduce a bias?
Re: histogram [message #67696 is a reply to message #44556] Wed, 12 August 2009 06:15 Go to previous messageGo to next message
jameskuyper is currently offline  jameskuyper
Messages: 79
Registered: October 2007
Member
rinceboy wrote:
> Won't including a max and min unrealisticaly skew the histogram by
> introducing false data? e.g. the first dataset ranges between (-50:22)
> and the second between (-70:24). By using teh same max and min, say
> -70 and 24 then you're biasing both histograms

No. All it does is change the boundaries of the bins. Why do you think
that would introduce a bias?
Re: histogram [message #67697 is a reply to message #44556] Wed, 12 August 2009 04:00 Go to previous messageGo to next message
rinceboy is currently offline  rinceboy
Messages: 5
Registered: March 2009
Junior Member
Won't including a max and min unrealisticaly skew the histogram by
introducing false data? e.g. the first dataset ranges between (-50:22)
and the second between (-70:24). By using teh same max and min, say
-70 and 24 then you're biasing both histograms


On Aug 11, 6:17 pm, David Fanning <n...@dfanning.com> wrote:
> rinceboy writes:
>> I'm using IDL to make and overplot histograms of temperature. I create
>> the first histogram from my first dataset and plot it. Then I overplot
>> another histogram from the second dataset. I use a common binsize of 5
>> degreesK for both. My problem is that the bin-bounds don't align e.g.
>> for my first histogram, say, a 5K bin is aligned between 20-25K,
>> however for the second dataset the 5K bin is aligned between 22-27K.
>
>> My question is: how to I have a common bin-alignment between the two
>> datasets?
>
> Set the MIN and MAX keywords on the two HISTOGRAM
> commands to the same values.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: histogram [message #67702 is a reply to message #44556] Tue, 11 August 2009 10:17 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rinceboy writes:

> I'm using IDL to make and overplot histograms of temperature. I create
> the first histogram from my first dataset and plot it. Then I overplot
> another histogram from the second dataset. I use a common binsize of 5
> degreesK for both. My problem is that the bin-bounds don't align e.g.
> for my first histogram, say, a 5K bin is aligned between 20-25K,
> however for the second dataset the 5K bin is aligned between 22-27K.
>
> My question is: how to I have a common bin-alignment between the two
> datasets?

Set the MIN and MAX keywords on the two HISTOGRAM
commands to the same values.

Cheers,

David

--
David Fanning, Ph.D.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: histogram [message #70219 is a reply to message #44556] Mon, 29 March 2010 03:08 Go to previous messageGo to next message
Maxwell Peck is currently offline  Maxwell Peck
Messages: 61
Registered: February 2010
Member
On Mar 25, 4:17 pm, afzu <afzal....@gmail.com> wrote:
> cud anybody help me implement Histogram Equalization using
> Neighborhood Metrics

I'm not exactly what you're doing but take a look at ADAPT_HIST_EQUAL.
From the help:

The ADAPT_HIST_EQUAL function performs adaptive histogram
equalization, a form of automatic image contrast enhancement. The
algorithm is described in Pizer et. al., "Adaptive Histogram
Equalization and its Variations.", Computer Vision, Graphics and Image
Processing, 39:355-368. Adaptive histogram equalization involves
applying contrast enhancement based on the local region surrounding
each pixel. Each pixel is mapped to an intensity proportional to its
rank within the surrounding neighborhood. This method of automatic
contrast enhancement has proven to be broadly applicable to a wide
range of images and to have demonstrated effectiveness.

Regards

Max
Re: Histogram [message #72826 is a reply to message #44556] Mon, 11 October 2010 07:16 Go to previous messageGo to next message
David Grier is currently offline  David Grier
Messages: 35
Registered: July 2010
Member
On 10/11/10 9:39 AM, silje wrote:
> Hey!
> I'm trying to get a grip of the Histogram function in IDL, but have
> run into a problem that I don't understand. As you can see from the
> code below I have created an array with six differend elements,but
> when I call HISTOGRAM with a binsize equal to 0.1 then it seems like
> 1.2 and 1.3 is put in the same bin. Why is this?
>
>
> IDL> arr = [1.1,1.2,1.3,1.4,1.5,1.6]
> IDL> print, HISTOGRAM(FLOAT(arr), binsize=0.1)
> 1 2 1 1 1
>
>
> Thanks!
> Best regards Silje

This question hinges on (1) where HISTOGRAM places the origin of
its bins and (2) the representation of floating point numbers.
If you explicitly specify where you want the bins to start, then
HISTOGRAM does what you were expecting:

IDL> print, HISTOGRAM(arr, binsize=0.1, min=1.05)
1 1 1 1 1 1

The command you tried automatically set the origin of the first bin
to 1.1. Each data point then falls right on the dividing line between
two bins. Which way they should fall is clear in decimal notation.
The answer can be different when the same numbers are represented at
finite numerical precision. Your example exercises this distinction.
Here's why:

IDL> print, 1.1 + 2.*0.1 - 1.3
1.19209e-7

which is not zero. Therefore, your third data point falls into the
second bin because of round-off error.

Doing the same calculation in double precision "solves" the problem
IDL> print, 1.1d + 2.d*0.1d - 1.3d
0.0000000

TTFN,

David
Re: Histogram [message #72827 is a reply to message #44556] Mon, 11 October 2010 06:51 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
silje writes:

> I'm trying to get a grip of the Histogram function in IDL, but have
> run into a problem that I don't understand. As you can see from the
> code below I have created an array with six differend elements,but
> when I call HISTOGRAM with a binsize equal to 0.1 then it seems like
> 1.2 and 1.3 is put in the same bin. Why is this?

Because your numbers are falling on the Razor's Edge:

http://www.dfanning.com/math_tips/razoredge.html

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: HISTOGRAM [message #82940 is a reply to message #44556] Wed, 23 January 2013 05:06 Go to previous message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Wednesday, January 23, 2013 3:44:27 AM UTC-8, Helder wrote:
> On Wednesday, January 23, 2013 12:12:54 PM UTC+1, dave poreh wrote:
>
>> Folks,
>
>>
>
>> HI,
>
>>
>
>> I am trying to plot:
>
>>
>
>> IDL> hist = HISTOGRAM(x(2,*),MIN = -400, MAX =100, BINSIZE = 4)
>
>>
>
>> % Program caused arithmetic error: Floating illegal operand
>
>>
>
>> Turns out, with cg's everything is ok.
>
>>
>
>> Can you please help me?
>
>>
>
>> Cheers,
>
>>
>
>> Dave
>
>
>
> I'm not a histogram expert, but I had problems for badly defined BINSIZEs.
>
> If you read cgHistoplot help/definition of binsize you will find:
>
> "I've tried to protect you from most of the bad things"
>
> And:
>
> "While it is pointed out in the HISTOGRAM documentation, it is extremely important that the BINSIZE be of the same data type as the data you are going to calculate the histogram of."
>
>
>
> You put in binsize 4. Are your data integers? If not you might have a look at that...
>
>
>
> Cheers,
>
> Helder

Thanks Helder,
It was data type problem, and now working:)
Cheers,
Dave
Re: HISTOGRAM [message #82943 is a reply to message #44556] Wed, 23 January 2013 03:44 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Wednesday, January 23, 2013 12:12:54 PM UTC+1, dave poreh wrote:
> Folks,
>
> HI,
>
> I am trying to plot:
>
> IDL> hist = HISTOGRAM(x(2,*),MIN = -400, MAX =100, BINSIZE = 4)
>
> % Program caused arithmetic error: Floating illegal operand
>
> Turns out, with cg's everything is ok.
>
> Can you please help me?
>
> Cheers,
>
> Dave

I'm not a histogram expert, but I had problems for badly defined BINSIZEs.
If you read cgHistoplot help/definition of binsize you will find:
"I've tried to protect you from most of the bad things"
And:
"While it is pointed out in the HISTOGRAM documentation, it is extremely important that the BINSIZE be of the same data type as the data you are going to calculate the histogram of."

You put in binsize 4. Are your data integers? If not you might have a look at that...

Cheers,
Helder
Re: HISTOGRAM [message #82944 is a reply to message #44556] Wed, 23 January 2013 03:26 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den onsdagen den 23:e januari 2013 kl. 12:12:54 UTC+1 skrev dave poreh:
> Folks,
>
> HI,
>
> I am trying to plot:
>
> IDL> hist = HISTOGRAM(x(2,*),MIN = -400, MAX =100, BINSIZE = 4)
>
> % Program caused arithmetic error: Floating illegal operand
>
> Turns out, with cg's everything is ok.
>
> Can you please help me?
>
> Cheers,
>
> Dave

If everything is ok, what do you need help for?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: convolution of vsini
Next Topic: Reading CDF files on a Mac

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:48:21 PDT 2025

Total time taken to generate the page: 0.00499 seconds