From defd97647a329109d020329c321bb75d712d91d2 Mon Sep 17 00:00:00 2001 From: Roger Labbe Date: Wed, 28 Jan 2015 13:12:05 -0800 Subject: [PATCH] Added documentation for functions in common. --- docs/common/common.rst | 43 ++++++++++++++++++++++++++++++++++++++++ filterpy/common/stats.py | 18 ++++++++--------- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/docs/common/common.rst b/docs/common/common.rst index 04488a1..4abe9d4 100644 --- a/docs/common/common.rst +++ b/docs/common/common.rst @@ -23,6 +23,49 @@ will find useful when you build your filters. .. autofunction:: linear_ode_discretation + +----- + +.. autofunction:: runge_kutta4 + + +----- + +.. autofunction:: gaussian + +----- + +.. autofunction:: mul + +----- + +.. autofunction:: add + +----- + +.. autofunction:: multivariate_gaussian + +----- + +.. autofunction:: plot_gaussian + + +----- + +.. autofunction:: covariance_ellipse + +----- + +.. autofunction:: plot_covariance_ellipse + +----- + +.. autofunction:: norm_cdf + +----- + +.. autofunction:: rand_student_t + ----- .. autofunction:: dot3 diff --git a/filterpy/common/stats.py b/filterpy/common/stats.py index ff69e88..9793659 100644 --- a/filterpy/common/stats.py +++ b/filterpy/common/stats.py @@ -381,6 +381,15 @@ def plot_std_vs_var(): plot_covariance_ellipse(x, P, variance=[1,2,3], facecolor='r', alpha=.5) +def rand_student_t(df, mu=0, std=1): + """return random number distributed by student's t distribution with + `df` degrees of freedom with the specified mean and standard deviation. + """ + x = random.gauss(0, std) + y = 2.0*random.gammavariate(0.5*df, 2.0) + return x / (math.sqrt(y/df)) + mu + + if __name__ == '__main__': plot_std_vs_var() plt.figure() @@ -411,12 +420,3 @@ def plot_std_vs_var(): plt.show() print("all tests passed") - - -def rand_student_t(df, mu=0, std=1): - """return random number distributed by student's t distribution with - `df` degrees of freedom with the specified mean and standard deviation. - """ - x = random.gauss(0, std) - y = 2.0*random.gammavariate(0.5*df, 2.0) - return x / (math.sqrt(y/df)) + mu \ No newline at end of file