dmdodd Posted January 24, 2011 Share Posted January 24, 2011 Azeotech, Is there anyway you could write a sequence/function for doing a median average?? I have a signal from a mass flow meter that I'm "mean" averaging currently, but I still get horrific fluctuations. On wikipedia I saw about using Median Averaging instead (http://en.wikipedia.org/wiki/Moving_average) stating: From a statistical point of view, the moving average, when used to estimate the underlying trend in a time series, is susceptible to rare events such as rapid shocks or other anomalies. A more robust estimate of the trend is the simple moving median over n time points: SMM = Median( p_M, p_{M-1}, ..., p_{M-n+1} ) where the median is found by, for example, sorting the values inside the brackets and finding the value in the middle. Statistically, the moving average is optimal for recovering the underlying trend of the time series when the fluctuations about the trend are normally distributed. However, the normal distribution does not place high probability on very large deviations from the trend which explains why such deviations will have a disproportionately large effect on the trend estimate. It can be shown that if the fluctuations are instead assumed to be Laplace distributed, then the moving median is statistically optimal[12]. For a given variance, the Laplace distribution places higher probability on rare events than does the normal, which explains why the moving median tolerates shocks better than the moving mean. When the simple moving median above is central, the smoothing is identical to the median filter which has applications in, for example, image signal processing. Anyway, I noticed there isn't an pre-programmed Median function, like the Mean function that is present. Any chance you could write on? I wouldn't have a clue how to incorporate it. Thanks in advance, Daniel Link to comment Share on other sites More sharing options...

AzeoTech Posted October 7, 2015 Share Posted October 7, 2015 A quick followup: here's how to do it using existing functions: You need several lines of script. Let's say you have an array "X" that you want to find the median for: x.time = x global theMedian = sortTime(x)[numrows(x)/2] This is using a trick of putting the actual values as time and then sorting on time. Link to comment Share on other sites More sharing options...

## Recommended Posts

## Archived

This topic is now archived and is closed to further replies.