#7197: basic statistics functions
--------------------------+-------------------------------------------------
Reporter: amhou | Owner: amhou
Type: task | Status: needs_review
Priority: minor | Milestone: sage-4.3
Component: statistics | Keywords: statistics, mean, median, mode,
standard deviation
Work_issues: | Author: Andrew Hou
Reviewer: | Merged:
--------------------------+-------------------------------------------------
Comment(by was):
REPORT 2:
1. a little too spartan:
{{{
"""
Basic Statistics
This file contains basic descriptive functions.
AUTHOR:
- Andrew Hou (11/06/2009)
...
"""
}}}
2. Make sure there is a test that tests this code:
{{{
"""
if hasattr(v, 'mean'): return v.mean()
}}}
3. Same for mode:
{{{
if hasattr(v, 'mode'): return v.mode()
}}}
4. Same for this:
{{{
if hasattr(v, 'standard_deviation'): return
v.standard_deviation(bias=bias)
}}}
5. Type checking in python should always use isinstance:
{{{
if type(v) is numpy.ndarray:
if type(v) == numpy.ndarray:
}}}
should be
{{{
if isinstance(v, numpy.ndarray):
}}}
6. Test this:
{{{
if hasattr(v, 'variance'): return v.variance(bias = bias)
}}}
7. Change this:
{{{
if bias == True:
# population variance
if isinstance(x, (int,long)):
return x/ZZ(len(v))
return x/len(v)
elif bias == False:
}}}
to
{{{
if bias:
# population variance
if isinstance(x, (int,long)):
return x/ZZ(len(v))
return x/len(v)
else:
}}}
8. Make sure this is tested:
{{{
if hasattr(v, 'median'): return v.median()
}}}
9. Weird """ in moving_average:
{{{ 318
"""
319 x = []
}}}
10. Change
{{{
bin_size = len(v)/bins
}}}
to floor division:
{{{
bin_size = int(len(v)//bins)
}}}
11. You can do this at the very end of each docstring if you want...
{{{
AUTHOR:
- Andrew Hou (11/06/2009)
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7197#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---