# Ticket #7197: trac_7197_part8.patch

File trac_7197_part8.patch, 4.2 KB (added by amhou, 12 years ago)
• ## sage/stats/basic_stats.py

```# HG changeset patch
# User Andrew Hou <hou.andrew@gmail.com>
# Date 1258419548 28800
# Node ID b3ad60106bf5fa4cb2e98caee947b23ecc0db4d8
# Parent  faf0b8837f76ed1e651646126bfc09ec42909904
Fixed documentation

diff -r faf0b8837f76 -r b3ad60106bf5 sage/stats/basic_stats.py```
 a separating the higher half of a sample from the lower half. The ``mode`` returns the most common occuring member of a sample, plus the number of times it occurs. If entries occur equally common, a list of the most common  entries are returned. The ``moving average`` is a finite impulse response filter, are returned. The ``moving_average`` is a finite impulse response filter, creating a series of averages using a user-defined number of subsets of the full data set. The ``standard deviation`` and the ``variance`` return a measurement of how far data points tend to be from the arithmetic mean. def mean(v): """ Return the mean of the elements of ``v``. Return the mean of the elements of `v`. We define the mean of the empty list to be NaN, following the convention of MATLAB, Scipy, and R. INPUT: - ``v`` -- a list of numbers - `v` -- a list of numbers OUTPUT: def mode(v): """ Return the mode (most common) of the elements of ``v`` Return the mode (most common) of the elements of `v` If ``v`` is empty, we define the mode to be null. If `v` is empty, we define the mode to be null. If all elements occur only once, we define the mode to be null. If multiple elements occur at the same frequency, all will be displayed. INPUT: - ``v`` -- a list - `v` -- a list OUTPUT: def std(v, bias=False): """ Returns the standard deviation of the elements of ``v`` Returns the standard deviation of the elements of `v` We define the standard deviation of the empty list to be NaN, following the convention of MATLAB, Scipy, and R. INPUT: - ``v`` -- a list of numbers - `v` -- a list of numbers - ``bias`` -- bool (default: False); if False, divide by len(v) - 1 instead of len(v) def variance(v, bias=False): """ Returns the variance of the elements of ``v`` Returns the variance of the elements of `v` We define the variance of the empty list to be NaN, following the convention of MATLAB, Scipy, and R. INPUT: - ``v`` -- a list of numbers - `v` -- a list of numbers - ``bias`` -- bool (default: False); if False, divide by len(v) - 1 instead of len(v) def median(v): """ Return the median (middle value) of the elements of ``v`` Return the median (middle value) of the elements of `v` If ``v`` is empty, we define the median to be null. If ``v`` is comprised of strings, TypeError occurs. If `v` is empty, we define the median to be null. If `v` is comprised of strings, TypeError occurs. For elements other than numbers, the median is a result of ``sorted()`` INPUT: - ``v`` -- a list - `v` -- a list OUTPUT: - median element of ``v`` - median element of `v` EXAMPLES:: def moving_average(v, bins=1): """ Provides the moving average of a list Provides the moving average of a list `v` The moving average of a list is often used to smooth out noisy data. Given a selected number of bins, the original list will be cut up into that number of bins. Then, the mean of each bin is calculated, and appended into a new list. If ``v`` is empty, we define the entries of the moving average to be NaN. If `v` is empty, we define the entries of the moving average to be NaN. INPUT: - ``v`` -- a list - `v` -- a list - ``bins`` -- number of bins, default set to 1