mode of a wave?
igorisfun
I have a number of files that sometimes have varying amounts of data points, I would like to see what is the most common number of points.
I have a function that finds the numpnts() of the loaded waves and puts the numpnts in another wave. My current solution to find the mode is:
//wave with numpnts of loaded waves
wave loadedpnts = root:loadedpnts
//find maximum number in loaded pnts
wavestats/Q/M=1 loadedpnts
//make a wave for histogram output and call histogram function
make/d/N=(v_max+1) loadedpnts_hist
Histogram/B=(0,1,v_max+1) loadedpnts, loadedpnts_hist
//check for maxloc in histogram output
wavestats/q/m=1 loadedpnts_hist
variable loadedpnts_max = v_maxrowloc
wave loadedpnts = root:loadedpnts
//find maximum number in loaded pnts
wavestats/Q/M=1 loadedpnts
//make a wave for histogram output and call histogram function
make/d/N=(v_max+1) loadedpnts_hist
Histogram/B=(0,1,v_max+1) loadedpnts, loadedpnts_hist
//check for maxloc in histogram output
wavestats/q/m=1 loadedpnts_hist
variable loadedpnts_max = v_maxrowloc
this will obviously fail if there are equal numbers of waves loaded with 2 or more different points (e.g. 2 waves loaded with 500 points and 2 waves loaded with 450 points).
So 2 questions:
1) is there a better way to do this?
2) is there a way around the problem of non-unimodal points?
Thanks!
You could run FindLevels after you found the maximum value to check if it occurs more often.
September 26, 2019 at 08:18 am - Permalink
I think just running StatsQuantiles on your wave "loadedpnts" will return the mode in V_mode. If there's multiple modes, it will return the lowest value mode.
September 26, 2019 at 11:37 am - Permalink