# [Scipy-tickets] [SciPy] #86: Statistics Review: sem

SciPy scipy-tickets at scipy.net
Wed Nov 15 10:09:10 CST 2006

```#86: Statistics Review: sem
-------------------------+--------------------------------------------------
Reporter:  rkern        |        Owner:  rkern
Type:  review       |       Status:  assigned
Priority:  normal       |    Milestone:  Statistics Review Months
Component:  scipy.stats  |      Version:  devel
Severity:  normal       |   Resolution:
Keywords:               |
-------------------------+--------------------------------------------------
Comment (by smoerz):

> The function {{{sem}}} in file source:trunk/Lib/stats/stats.py needs
review.
>
below.

1.) The function is WRONG. It gives the same result as scipy.stats.stderr
(using N-1 and not N), whereas scipy.stats.tsem uses N and gives the
correct result.

def stderr(a, axis=0):
a, axis = _chk_asarray(a, axis)

return samplestd(a,axis) / sqrt(a.shape[axis])

the test should be changed to (stats/tests/test_stats.py):
"""sqrt(samplevar(testcase))/sqrt(4)"""
assert_approx_equal(y,0.5590169944)

2.) Docstring is ok.

The function should be unified with tsem, and maybe renamed/aliased to
"sampleerr" for consistency with "samplevar" and "samplestd". The unified
function should have argument "axis" as sem, and arguments "limits" and
"inclusive" as tsem, and maybe "ignorenans" (functionality similar to
nanstd). The algorithm should use the std method of numpy, as tsem does.
This unification should be done also for functions std, samplestd, var,
samplevar, mean, etc.

--
Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/86#comment:2>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.
```