|
|
|
|
SynopsisCalculate several basic statistic values for a data array Syntaxsimple_stats(array); DescriptionThe simple_stats() routine calculates several simple statistics for the input data (the array argument), such as the mean, median, and standard deviation. For more control over the calculation use the statistics module. Loading the routineThe routine can be loaded into Sherpa by saying:
require ("ciao_utils");
Arguments
The return valueThe return value is an object with the following fields:
Example 1chips> x = [0, 1, 2, 3, 2, 3, 4, 2, 1, 5]; chips> s = simple_stats(x); The return value of s is an object which contains the calculated statistics of the array:
chips> print (s);
npts = 10
min = 0
max = 5
total = 23
mean = 2.3
median = 2.0
stddev = 1.41774468788
chips> vmessage("The mean is %g +- %g", s.mean, s.stddev);
The mean is 2.3 +- 1.41774
Example 2
chips> img = read_image("emap.fits");
chips> ivals = get_imagevals(img);
chips> ix = where(isinf(ivals) | isnan(ivals) == 0);
chips> simg = simple_stats(ivals[ix];Here we use the Crates read_image() and get_imagevals() to read in the contents of the image "emap.fits". Since it may contain "invalid" numbers, such as NaN and Infinity, we filter out these values before calculating the statistics (simg). See Also
|
![]() |
The Chandra X-Ray
Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA. Email: cxcweb@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2004. All rights reserved. |