Tips for Teachers: Week 1.7, Continuous Distributions

Book chapters here.

Location, shape and scale

In [4]:
import numpy as np
import matplotlib.pyplot as plt

from scipy import stats
from scipy.stats import norm, gumbel_r
In [9]:
loc = 28.167
scale = 13.097
print(gumbel_r.pdf(30, loc, scale))
print(gumbel_r.cdf(30, loc, scale))
print(gumbel_r.ppf(0.4192, loc, scale))

print(gumbel_r.ppf(1/773, loc, scale))
0.027827357842534345
0.4192043639942213
29.99984317624283
3.3526534870972142
In [10]:
dir(gumbel_r)
Out[10]:
['__call__',
 '__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getstate__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setstate__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_argcheck',
 '_argcheck_rvs',
 '_attach_argparser_methods',
 '_attach_methods',
 '_cdf',
 '_cdf_single',
 '_cdfvec',
 '_construct_argparser',
 '_construct_default_doc',
 '_construct_doc',
 '_ctor_param',
 '_delta_cdf',
 '_entropy',
 '_fit_loc_scale_support',
 '_fitstart',
 '_get_support',
 '_isf',
 '_logcdf',
 '_logpdf',
 '_logpxf',
 '_logsf',
 '_mom0_sc',
 '_mom1_sc',
 '_mom_integ0',
 '_mom_integ1',
 '_moment_error',
 '_munp',
 '_nlff_and_penalty',
 '_nnlf',
 '_nnlf_and_penalty',
 '_open_support_mask',
 '_param_info',
 '_parse_arg_template',
 '_parse_args',
 '_parse_args_rvs',
 '_parse_args_stats',
 '_pdf',
 '_penalized_nlpsf',
 '_penalized_nnlf',
 '_ppf',
 '_ppf_single',
 '_ppf_to_solve',
 '_ppfvec',
 '_random_state',
 '_reduce_func',
 '_rvs',
 '_sf',
 '_shape_info',
 '_stats',
 '_stats_has_moments',
 '_support_mask',
 '_unpack_loc_scale',
 '_updated_ctor_param',
 'a',
 'b',
 'badvalue',
 'cdf',
 'entropy',
 'expect',
 'fit',
 'fit_loc_scale',
 'freeze',
 'generic_moment',
 'interval',
 'isf',
 'logcdf',
 'logpdf',
 'logsf',
 'mean',
 'median',
 'moment',
 'moment_type',
 'name',
 'nnlf',
 'numargs',
 'pdf',
 'ppf',
 'random_state',
 'rvs',
 'sf',
 'shapes',
 'stats',
 'std',
 'support',
 'var',
 'vecentropy',
 'xtol']
In [2]:
print(1/773, 772/773)
0.00129366106080207 0.9987063389391979

Scipy.stats

Homepage

If you find yourself looking at documentation for something and there is no info, try the rv_continuous page

In [1]:
test = norm('m'=0, 'v'=1)
  Cell In[1], line 1
    test = norm('m'=0, 'v'=1)
                ^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?

End of notebook.

© Copyright 2024 MUDE TU Delft. This work is licensed under a CC BY 4.0 License.