Mode of a distribution

aperson
Posts: 7
Joined: 2008-05-12
Location: United States

I am trying to find the mode of various distributions contained in waves (as in, the most frequently occurring value). I don't see that there is an obvious command in Igor Pro 5.05A to find this but maybe I'm missing it. Is there any way to find the mode easily within Igor? Thanks!
ap


awirsing
Posts: 130
Joined: 2007-09-19
Location: Germany

Could you calculate a Histogram and then look for the maximum with WaveStats?
Beside the command line both operations can be accessed via Igor's Analysis menu.
A.


[ last edited August 20, 2010 - 07:07 ]
aperson
Posts: 7
Joined: 2008-05-12
Location: United States

I suppose that's a decent enough work around. Thanks!


RGerkin
RGerkin's picture
Posts: 123
Joined: 2008-02-22
Location: United States

A neat stats trick is to use something called the "shorth":
DF Andrews, “Robust Estimates of Location.” Princeton University Press (1972).

This can be implemented in Igor as follows:

function shorth(data,alpha)
	wave data
	variable alpha
 
	duplicate /free data,sorted
	sort data,sorted
	variable n=numpnts(data)
	alpha*=n
	make /o/n=(n/2) shorths=sorted[p+alpha]-sorted[p]
	wavestats /q/m=1 shorths
	variable meann=mean(sorted,v_minloc,v_minloc+n/2)
	return meann
end

Alpha=0.5 is the typical choice. This code then finds the mean of the data in the shortest interval that contains half the data. So it is robust against modes that are not the main mode. This does not return the mode per se, but it is an estimator that asymptotically approaches the mode, and summarizes the data a little bit more cleanly in my opinion.

Rick


aperson
Posts: 7
Joined: 2008-05-12
Location: United States

I will give this a shot too. Thank you.


Back to top