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

Home » Public Forums » archive » Re: MODE 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: MODE in IDL? [message #47105 is a reply to message #47104] Tue, 24 January 2006 19:04 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jonathan Greenberg writes:

> I can't seem to find the function to calculate the mode of an array -- how
> do I do this in IDL?

I'm trying to remember back to grade school or somewhere, but
isn't the mode the maximum of the frequency distribution. I
remember that the mode isn't unique, because two numbers
could have the same frequency in the sample (bimodal, I guess)
and it is theoretically possible to have no mode (all frequencies
are the same).

But saying all that, if you have an integer array, I would
think the mode is calculated like this:

array = [1, 1, 2 , 4, 1, 3, 3, 2, 4, 5, 3, 2, 2, 1, 2, 6]
h = Histogram(array, MIN=Min(array))
bigfreq = Max(h)
mode = Where(h EQ bigfreq) + Min(array)
Print, mode
2

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL Quiz and Essay Contest
Next Topic: Reading DICOM images

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

Current Time: Thu Oct 09 09:42:58 PDT 2025

Total time taken to generate the page: 0.88308 seconds