mediansdev
The mediansdev function returns the median and standard deviation of a 1-dimensional array, CImage, or list of numbers. The median function returns only the median value. The array and list parameters must contain a mixture of numbers and strings that can be converted to numbers. This function is similar to the CStat:Median method but does not require calling new_stats() beforehand to create a CStats object.
Whereas this function operates on a pure (indexed) array, the slightly slower mediann and mediansdevn functions calculate the median and standard deviation for a general table that may be a multi-dimensional array or contain a mixture of numbers, strings, named keys, and sub-tables. Also see the median function which returns only the median.
nMedian, nStdDev = mediansdev( Data )
nMedian, nStdDev = mediansdev( n1, n2, n3, ... )
Data is a 1-dimensional array, list of numbers, or a CImage object.
n1, n2, n3, ... are numbers or string values that can be converted to numbers.
nMedian is the returned median of the data.
nStdDev is the standard deviation of the values.
The CImage class supports values ranging from byte to double plus other pixel types.
The following script returns the median of a table of 1 million random numbers.
|
-- create a table of numbers |
|
-- find the median and standard deviation |
|
-- list the result |
The next script returns the median value for pixels inside a rectangle at the corner of a CImage.
|
-- attach the topmost image window |
|
-- make sure an image window is on top |
|
-- rectangle for corner of image |
|
-- use the current image in the CImageView |
|
-- list the result |
The next example computes the median value of a list of numbers:
|
-- find the median value |
|
-- result: Median = 4 |
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.