Skip to content

Commit

Permalink
Added documentation for functions in common.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlabbe committed Jan 28, 2015
1 parent 5e3ad2e commit defd976
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 9 deletions.
43 changes: 43 additions & 0 deletions docs/common/common.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions filterpy/common/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit defd976

Please sign in to comment.