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

Home » Public Forums » archive » Re: Box-Whisker plots in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Box-Whisker plots in IDL [message #55390 is a reply to message #55389] Mon, 20 August 2007 16:47 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
jschwab@gmail.com writes:

> Pardon me if I'm mistaken, but I think these "quartiles with
> histogram" examples, including the one that's in JD's histogram
> tutorial are fundamentally incorrect.
>
> You are assuming "Equal bin widths" ==> "Equal #'s in each bin" !
>
> When HISTOGRAM splits a data list into N bins, it does so such that
> the *width* of the bins are equal. In no way does it somehow create a
> situation in which the *number of points* in each bin is equal (which
> is what would be required to find quartiles in such a manner).
>
> The given examples have only "worked" because you're either dealing
> with uniform distributions (in which case equal bin widths do imply
> equal numbers in each bin) or because the example data happens to be
> roughly uniform.
>
> If you want to convince yourself, try one of those codes with
> data = randomu(seed, 1000) * 100.
> and then with
> data2 = data * data
> The quartiles in the 2nd case should simply be the squares of the
> quartiles from the first.

Humm. Maybe you are right. (Isn't it odd that math types
never hit the SEND button until someone else has made
a fool of themselves?)

OK, how about this:

data=randomu(sd,100)*100
minVal = min(data)
maxVal = max(data)
medianVal = median(data,/even)

; Find the quartiles.
qtr_25th = Median(data[Where(data LE medianVal, countlowerhalf)])
qtr_75th = Median(data[Where(data GT medianVal, countupperhalf)])
void = Where(data LT qtr_25th, countlowerquarter)
void = Where(data GE qtr_75th, countupperquarter)

Print, minVal, maxVal, medianVal, qtr_25th, qtr_75th
Print, countlowerquarter, countlowerhalf-countlowerquarter, $
countupperhalf-countupperquarter, countupperquarter
END

Which gives me:

1.74060 99.8840 53.5631 31.7422 73.8378
25 25 25 25

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.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: MODIS spectral radiance
Next Topic: How to read ASTER in ENVI?

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

Current Time: Sat Oct 11 04:22:56 PDT 2025

Total time taken to generate the page: 1.59812 seconds