Binning data then taking stats on each bin
compuchemgeek
I know the WaveStats command can calculate the standard deviation (among other things), and one can also set the X range of the wave using /R=[startP, endP]. Having never programmed in Igor before, I'm not sure how to go about this programmatically, but I'm thinking of a placing the WaveStat command within a loop. Any help would be appreciated!
Your description is a bit confusing. You cannot calculate a standard deviation for a bin, whose value consists of a single number. You can calculate statistics on the entire Histogram wave.
July 12, 2013 at 07:21 am - Permalink
Here is a solution:
Wave wIn
Variable segmentSize
String wOutName // Name for output wave
Variable numPoints = numpnts(wIn)
Variable numSegments = trunc(numPoints/segmentSize)
Make/O/D/N=(numSegments) $wOutName
Wave standardDeviations = $wOutName
Variable startPoint = 0, endPoint
Variable segment
for(segment=0; segment<numSegments; segment+=1)
endPoint = startPoint + segmentSize - 1
WaveStats /Q /M=2 /R=[startPoint,endPoint] wIn
standardDeviations[segment] = V_sdev
startPoint += segmentSize
endfor
End
Function Demo()
Make/O/D/N=7000 testData = gnoise(1)
StdDevBySegment(testData, 100, "standardDeviations")
Wave standardDeviations // Created by StdDevBySegment
DoWindow/F StdDevGraph
if (V_flag == 0)
Display/N=StdDevGraph standardDeviations
endif
End
There may be a faster way to get just the standard deviation but I could not identify it.
July 12, 2013 at 09:53 am - Permalink
Redimension/N=(M,N) eee // every column corresponds to a bin
MatrixOP/O varData=VarCols(eee)
A.G.
WaveMetrics, Inc.
July 12, 2013 at 10:44 am - Permalink
Regards,
Edward
July 17, 2013 at 09:05 am - Permalink