Module Expr Str ImportFrom alias Import alias identifier ImportFrom alias alias alias FunctionDef arguments args NameParam NameParam NameParam defaults Lambda arguments args NameParam defaults Num Num body Expr Str FunctionDef arguments args NameParam defaults body Return Call NameLoad NameLoad decorator_list Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Return Call AttributeLoad Call NameLoad NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults Lambda arguments args NameParam defaults Num Num NameLoad NameLoad NameLoad Num body Expr Str Assign NameStore SubscriptLoad AttributeLoad Call AttributeLoad NameLoad attr keyword Num attr Index Num If CompareIs NameLoad NameLoad body Assign NameStore BinOpMult UnaryOpUSub AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign NameStore BinOpMult AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad FunctionDef arguments args NameParam defaults body Return Call NameLoad NameLoad decorator_list Assign NameStore ListLoad Assign NameStore Num Assign NameStore Num While NameLoad body Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword Call NameLoad BinOpMult NameLoad NameLoad AugAssignAdd NameStore Call NameLoad BinOpMult NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index Call AttributeLoad BinOpBitAnd CompareGtE NameLoad NameLoad CompareLtE NameLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num Expr Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad NameLoad If CompareGtE NameLoad NameLoad body Break Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad AttributeLoad NameLoad attr Assert CompareEq NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num Assign NameStore Call AttributeLoad Call NameLoad NameLoad attr Num If NameLoad body Return NameLoad orelse Return BinOpMult NameLoad BinOpDiv BinOpMult NameLoad Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore NameLoad Assign TupleStore NameStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore BinOpDiv NameLoad BinOpMult NameLoad NameLoad Assign NameStore BinOpSub BinOpAdd BinOpDiv BinOpPow NameLoad Num BinOpPow NameLoad Num BinOpDiv BinOpPow NameLoad Num BinOpPow NameLoad Num BinOpDiv BinOpMult BinOpMult BinOpMult Num NameLoad NameLoad NameLoad BinOpMult NameLoad NameLoad Assign NameStore BinOpMult BinOpMult BinOpMult BinOpMult Num AttributeLoad NameLoad attr NameLoad NameLoad Call AttributeLoad NameLoad attr BinOpSub Num BinOpPow NameLoad Num Return BinOpDiv Call AttributeLoad NameLoad attr BinOpDiv UnaryOpUSub NameLoad BinOpMult Num BinOpSub Num BinOpPow NameLoad Num NameLoad decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign TupleStore AttributeStore NameLoad attr AttributeStore NameLoad attr NameStore AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Return Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Lambda arguments args NameParam defaults Num TupleLoad Num Num TupleLoad Num Num body FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Return BinOpMult Call NameLoad NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list ImportFrom alias Return Call NameLoad NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Lambda arguments args NameParam defaults SubscriptLoad NameLoad Index Num Lambda arguments args NameParam defaults SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Lambda arguments args NameParam defaults BinOpSub Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Num body Assign NameStore Lambda arguments args NameParam defaults BinOpSub Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Return Call AttributeLoad Call NameLoad NameLoad attr decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults vararg kwarg body Expr Str Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameStore Call NameLoad NameLoad If CompareEq AttributeLoad NameLoad attr TupleLoad body Assign AttributeStore NameLoad attr BinOpMult Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpDiv Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpDiv Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad orelse If BoolOpAnd CompareEq AttributeLoad NameLoad attr Num CompareEq Call NameLoad NameLoad NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr BinOpDiv Num NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr BinOpDiv Num Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore NameLoad attr AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr attr orelse Raise Call NameLoad Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults kwarg body Expr Str Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr BinOpSub NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr UnaryOpUSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return BinOpDiv BinOpSub NameLoad AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Assign NameStore BinOpDiv AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore ListComp Call NameLoad NameLoad NameLoad comprehension NameStore AttributeLoad NameLoad attr Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If NameLoad body Assign NameStore UnaryOpUSub AttributeLoad NameLoad attr orelse Assign NameStore BinOpMult AttributeLoad NameLoad attr BinOpSub BinOpDiv Num AttributeLoad NameLoad attr Num Return Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr BinOpDiv Num AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return BinOpDiv AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list NameLoad Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad ExtSlice Slice Index NameLoad NameLoad Assign NameStore ListComp Call NameLoad NameLoad NameLoad comprehension NameStore AttributeLoad NameLoad attr Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameStore Call NameLoad NameLoad If CompareEq AttributeLoad NameLoad attr TupleLoad body Assign AttributeStore NameLoad attr BinOpMult Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpDiv Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr BinOpDiv Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad orelse If BoolOpAnd CompareEq AttributeLoad NameLoad attr Num CompareEq Call NameLoad NameLoad NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr BinOpDiv Num NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr BinOpDiv Num Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore NameLoad attr AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr attr orelse Raise Call NameLoad Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Return Call AttributeLoad NameLoad attr NameLoad AttributeLoad AttributeLoad NameLoad attr attr orelse Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpSub NameLoad AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpPow NameLoad Num Num Assign NameStore UnaryOpUSub NameLoad AugAssignSub NameStore BinOpMult AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpMult Num AttributeLoad NameLoad attr AugAssignSub NameStore AttributeLoad NameLoad attr AugAssignMult NameStore Num Return NameLoad decorator_list Assign NameStore NameLoad decorator_list ClassDef bases NameLoad body Expr Str Expr CompareEq NameLoad Str FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpSub NameLoad AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpPow NameLoad Num Num Assign NameStore UnaryOpUSub NameLoad AugAssignSub NameStore BinOpMult AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpMult Num AttributeLoad NameLoad attr AugAssignSub NameStore AttributeLoad NameLoad attr AugAssignMult NameStore Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults kwarg body Expr Str Return Call NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore NameLoad Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListComp NameLoad comprehension NameStore Call NameLoad AttributeLoad NameLoad attr UnaryOpNot CompareIn NameLoad NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad ExtSlice Slice Index NameLoad NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad ExtSlice Slice Index NameLoad NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad ExtSlice Slice Index NameLoad NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad ExtSlice Slice Index NameLoad NameLoad Assign NameStore BinOpSub NameLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Assign NameStore BinOpAdd SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad BinOpSub NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Return Call NameLoad NameLoad NameLoad decorator_list decorator_list ImportFrom alias Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr ClassDef bases NameLoad body Expr CompareEq NameLoad Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr ListLoad Str Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str ImportFrom alias Return Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpSub NameLoad AttributeLoad NameLoad attr Assign NameStore BinOpMult UnaryOpUSub NameLoad Call NameLoad BinOpMult NameLoad NameLoad AugAssignSub NameStore AttributeLoad NameLoad attr AugAssignSub NameStore BinOpMult BinOpAdd NameLoad NameLoad Call NameLoad BinOpAdd Num BinOpDiv Call AttributeLoad NameLoad attr BinOpPow NameLoad Num Num NameLoad AugAssignMult NameStore Num AugAssignAdd NameStore BinOpSub Call NameLoad BinOpDiv BinOpAdd NameLoad NameLoad Num Call NameLoad BinOpDiv NameLoad Num Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults kwarg body Expr Str Assign NameStore BinOpMult UnaryOpUSub AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpDiv BinOpSub NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return Call NameLoad NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If CompareLtE AttributeLoad NameLoad attr Num body Return BinOpMult AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Return BinOpMult BinOpDiv AttributeLoad NameLoad attr BinOpSub AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore NameLoad If UnaryOpNot CompareEq AttributeLoad NameLoad attr TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr body If Call AttributeLoad CompareLtE Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Num attr body Raise Call NameLoad Str Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return Call NameLoad NameLoad NameLoad AttributeLoad NameLoad attr decorator_list decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Lambda arguments args NameParam defaults Num TupleLoad Num Num TupleLoad Num Num body FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Return Call NameLoad NameLoad decorator_list ImportFrom alias Return Call NameLoad NameLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num Lambda arguments args NameParam defaults SubscriptLoad NameLoad Index Num Lambda arguments args NameParam defaults SubscriptLoad NameLoad Index Num decorator_list If CompareEq NameLoad Str body ImportFrom alias alias Assign NameStore ListLoad Str Assign NameStore TupleLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr ListLoad ListLoad Num Num ListLoad Num Num Assign NameStore ListLoad Num Num Num Assign NameStore Call AttributeLoad NameLoad attr ListLoad ListLoad Num Num Num ListLoad Num Num Num ListLoad Num Num Num If CompareIn Str NameLoad body Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword Num Expr Call NameLoad Call AttributeLoad NameLoad attr Num Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad keyword Num Expr Call NameLoad Call AttributeLoad NameLoad attr Expr Call NameLoad Call AttributeLoad NameLoad attr ListLoad Num Num Assign NameStore Call NameLoad NameLoad Call AttributeLoad NameLoad attr Num Assign NameStore Call NameLoad NameLoad BinOpMult Num Call AttributeLoad NameLoad attr Num Assign NameStore Lambda arguments args NameParam defaults BinOpSub Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr ListLoad Num Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr TupleLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr ListLoad ListLoad Num Num Num ListLoad Num Num Num ListLoad Num Num Num Assign NameStore ListLoad Num Num Num Assign NameStore Call NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Num Expr Call AttributeLoad NameLoad attr TupleLoad Num Num Num Assign NameStore ListLoad Num Num Num Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad keyword Num Assign NameStore ListLoad Num Num Num Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad keyword Num Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr ListLoad Num Num Num NameLoad Assign NameStore ListLoad Num Num Num Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad keyword Num Assign NameStore Call NameLoad TupleLoad Num Num Num Num Assign NameStore Lambda arguments args NameParam defaults BinOpSub Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad keyword Num Assign NameStore Call NameLoad TupleLoad Num Num Num Num Expr Call NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Num keyword Num Expr Call NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Num keyword Num Expr BinOpSub Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Num Assign NameStore Call NameLoad TupleLoad Num Num Num Num Expr BinOpSub Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Num Assign NameStore Call AttributeLoad NameLoad attr Num Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad keyword Num AttributeLoad NameLoad attr keyword Num Assign NameStore Call NameLoad NameLoad NameLoad Num Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad ListLoad Num Num Num keyword Num Assign NameStore Call NameLoad NameLoad NameLoad Num Expr Call NameLoad Call AttributeLoad NameLoad attr NameLoad ListLoad Num Num Num keyword Num
N/A N/A Multivariate Normal and t distributions



Created on Sat May 28 15:38:23 2011

@author: Josef Perktold

TODO:
* renaming,
    - after adding t distribution, cov doesn't make sense for Sigma    DONE
    - should mean also be renamed to mu, if there will be distributions
      with mean != mu
* not sure about corner cases
    - behavior with (almost) singular sigma or transforms
    - df <= 2, is everything correct if variance is not finite or defined ?
* check to return possibly univariate distribution for marginals or conditional
    distributions, does univariate special case work? seems ok for conditional
* are all the extra transformation methods useful outside of testing ?
  - looks like I have some mixup in definitions of standardize, normalize
* new methods marginal, conditional, ... just added, typos ?
  - largely tested for MVNormal, not yet for MVT   DONE
* conditional: reusing, vectorizing, should we reuse a projection matrix or
  allow for a vectorized, conditional_mean similar to OLS.predict
* add additional things similar to LikelihoodModelResults? quadratic forms,
  F distribution, and others ???
* add Delta method for nonlinear functions here, current function is hidden
  somewhere in miscmodels
* raise ValueErrors for wrong input shapes, currently only partially checked

* quantile method (ppf for equal bounds for multiple testing) is missing
  http://svitsrv25.epfl.ch/R-doc/library/mvtnorm/html/qmvt.html seems to use
  just a root finder for inversion of cdf

* normalize has ambiguous definition, and mixing it up in different versions
  std from sigma or std from cov ?
  I would like to get what I need for mvt-cdf, or not
  univariate standard t distribution has scale=1 but std>1
  FIXED: add std_sigma, and normalize uses std_sigma

* more work: bivariate distributions,
  inherit from multivariate but overwrite some methods for better efficiency,
  e.g. cdf and expect

I kept the original MVNormal0 class as reference, can be deleted


See Also
--------
sandbox/examples/ex_mvelliptical.py

Examples
--------

Note, several parts of these examples are random and the numbers will not be
(exactly) the same.

>>> import numpy as np
>>> import statsmodels.sandbox.distributions.mv_normal as mvd
>>>
>>> from numpy.testing import assert_array_almost_equal
>>>
>>> cov3 = np.array([[ 1.  ,  0.5 ,  0.75],
...                    [ 0.5 ,  1.5 ,  0.6 ],
...                    [ 0.75,  0.6 ,  2.  ]])

>>> mu = np.array([-1, 0.0, 2.0])

multivariate normal distribution
--------------------------------

>>> mvn3 = mvd.MVNormal(mu, cov3)
>>> mvn3.rvs(size=3)
array([[-0.08559948, -1.0319881 ,  1.76073533],
       [ 0.30079522,  0.55859618,  4.16538667],
       [-1.36540091, -1.50152847,  3.87571161]])

>>> mvn3.std
array([ 1.        ,  1.22474487,  1.41421356])
>>> a = [0.0, 1.0, 1.5]
>>> mvn3.pdf(a)
0.013867410439318712
>>> mvn3.cdf(a)
0.31163181123730122

Monte Carlo integration

>>> mvn3.expect_mc(lambda x: (x<a).all(-1), size=100000)
0.30958999999999998
>>> mvn3.expect_mc(lambda x: (x<a).all(-1), size=1000000)
0.31197399999999997

multivariate t distribution
---------------------------

>>> mvt3 = mvd.MVT(mu, cov3, 4)
>>> mvt3.rvs(size=4)
array([[-0.94185437,  0.3933273 ,  2.40005487],
       [ 0.07563648,  0.06655433,  7.90752238],
       [ 1.06596474,  0.32701158,  2.03482886],
       [ 3.80529746,  7.0192967 ,  8.41899229]])

>>> mvt3.pdf(a)
0.010402959362646937
>>> mvt3.cdf(a)
0.30269483623249821
>>> mvt3.expect_mc(lambda x: (x<a).all(-1), size=1000000)
0.30271199999999998

>>> mvt3.cov
array([[ 2. ,  1. ,  1.5],
       [ 1. ,  3. ,  1.2],
       [ 1.5,  1.2,  4. ]])
>>> mvt3.corr
array([[ 1.        ,  0.40824829,  0.53033009],
       [ 0.40824829,  1.        ,  0.34641016],
       [ 0.53033009,  0.34641016,  1.        ]])

get normalized distribution

>>> mvt3n = mvt3.normalized()
>>> mvt3n.sigma
array([[ 1.        ,  0.40824829,  0.53033009],
       [ 0.40824829,  1.        ,  0.34641016],
       [ 0.53033009,  0.34641016,  1.        ]])
>>> mvt3n.cov
array([[ 2.        ,  0.81649658,  1.06066017],
       [ 0.81649658,  2.        ,  0.69282032],
       [ 1.06066017,  0.69282032,  2.        ]])

What's currently there?

>>> [i for i in dir(mvn3) if not i[0]=='_']
['affine_transformed', 'cdf', 'cholsigmainv', 'conditional', 'corr', 'cov',
'expect_mc', 'extra_args', 'logdetsigma', 'logpdf', 'marginal', 'mean',
'normalize', 'normalized', 'normalized2', 'nvars', 'pdf', 'rvs', 'sigma',
'sigmainv', 'standardize', 'standardized', 'std', 'std_sigma', 'whiten']

>>> [i for i in dir(mvt3) if not i[0]=='_']
['affine_transformed', 'cdf', 'cholsigmainv', 'corr', 'cov', 'df', 'expect_mc',
'extra_args', 'logdetsigma', 'logpdf', 'marginal', 'mean', 'normalize',
'normalized', 'normalized2', 'nvars', 'pdf', 'rvs', 'sigma', 'sigmainv',
'standardize', 'standardized', 'std', 'std_sigma', 'whiten']

 __future__ print_function N/A numpy np statsmodels.sandbox.distributions.multivariate mvstdtprob mvstdnormcdf mvnormcdf expect_mc N/A N/A dist func size N/A N/A N/A N/A x N/A 1 50000 N/A N/A calculate expected value of function by Monte Carlo integration

    Parameters
    ----------
    dist : distribution instance
        needs to have rvs defined as a method for drawing random numbers
    func : callable
        function for which expectation is calculated, this function needs to
        be vectorized, integration is over axis=0
    size : int
        number of random samples to use in the Monte Carlo integration,


    Notes
    -----
    this doesn't batch

    Returns
    -------
    expected value : ndarray
        return of function func integrated over axis=0 by MonteCarlo, this will
        have the same shape as the return of func without axis=0

    Examples
    --------

    integrate probability that both observations are negative

    >>> mvn = mve.MVNormal([0,0],2.)
    >>> mve.expect_mc(mvn, lambda x: (x<np.array([0,0])).all(-1), size=100000)
    0.25306000000000001

    get tail probabilities of marginal distribution (should be 0.1)

    >>> c = stats.norm.isf(0.05, scale=np.sqrt(2.))
    >>> expect_mc(mvn, lambda x: (np.abs(x)>np.array([c, c])), size=100000)
    array([ 0.09969,  0.0986 ])

    or calling the method

    >>> mvn.expect_mc(lambda x: (np.abs(x)>np.array([c, c])), size=100000)
    array([ 0.09937,  0.10075])


     fun N/A N/A x N/A N/A N/A N/A func x N/A N/A rvs N/A N/A dist rvs size size N/A N/A N/A N/A fun rvs mean 0 N/A expect_mc_bounds N/A N/A dist func size lower upper conditional overfact N/A N/A N/A N/A x N/A 1 50000 None None False 1.2 N/A N/A calculate expected value of function by Monte Carlo integration

    Parameters
    ----------
    dist : distribution instance
        needs to have rvs defined as a method for drawing random numbers
    func : callable
        function for which expectation is calculated, this function needs to
        be vectorized, integration is over axis=0
    size : int
        minimum number of random samples to use in the Monte Carlo integration,
        the actual number used can be larger because of oversampling.
    lower : None or array_like
        lower integration bounds, if None, then it is set to -inf
    upper : None or array_like
        upper integration bounds, if None, then it is set to +inf
    conditional : bool
        If true, then the expectation is conditional on being in within
        [lower, upper] bounds, otherwise it is unconditional
    overfact : float
        oversampling factor, the actual number of random variables drawn in
        each attempt are overfact * remaining draws. Extra draws are also
        used in the integration.


    Notes
    -----
    this doesn't batch

    Returns
    -------
    expected value : ndarray
        return of function func integrated over axis=0 by MonteCarlo, this will
        have the same shape as the return of func without axis=0

    Examples
    --------
    >>> mvn = mve.MVNormal([0,0],2.)
    >>> mve.expect_mc_bounds(mvn, lambda x: np.ones(x.shape[0]),
                                lower=[-10,-10],upper=[0,0])
    0.24990416666666668

    get 3 marginal moments with one integration

    >>> mvn = mve.MVNormal([0,0],1.)
    >>> mve.expect_mc_bounds(mvn, lambda x: np.dstack([x, x**2, x**3, x**4]),
        lower=[-np.inf,-np.inf], upper=[np.inf,np.inf])
    array([[  2.88629497e-03,   9.96706297e-01,  -2.51005344e-03,
              2.95240921e+00],
           [ -5.48020088e-03,   9.96004409e-01,  -2.23803072e-02,
              2.96289203e+00]])
    >>> from scipy import stats
    >>> [stats.norm.moment(i) for i in [1,2,3,4]]
    [0.0, 1.0, 0.0, 3.0]


     N/A rvsdim N/A N/A N/A N/A dist rvs size 1 shape N/A -1 N/A N/A lower None N/A N/A lower N/A N/A N/A np inf N/A N/A np ones rvsdim N/A N/A lower N/A N/A np asarray lower N/A N/A upper None N/A N/A upper N/A N/A np inf N/A N/A np ones rvsdim N/A N/A upper N/A N/A np asarray upper fun N/A N/A x N/A N/A N/A N/A func x N/A N/A rvsli N/A N/A used 0 N/A total 0 N/A True N/A N/A remain N/A size used N/A rvs N/A N/A dist rvs size N/A int N/A remain overfact N/A total N/A int N/A size overfact N/A rvsok N/A rvs N/A N/A N/A N/A N/A rvs lower N/A rvs upper all -1 N/A rvsok N/A N/A np atleast_2d rvsok N/A used N/A N/A rvsok shape N/A 0 N/A N/A N/A rvsli append rvsok N/A N/A print used N/A N/A used size N/A N/A N/A rvs N/A N/A np vstack rvsli N/A N/A print N/A rvs shape N/A N/A used N/A N/A rvs shape N/A 0 N/A mean_conditional N/A N/A N/A fun rvs mean 0 N/A conditional N/A N/A mean_conditional N/A N/A N/A mean_conditional N/A N/A used 1.0 total N/A bivariate_normal N/A N/A x mu cov N/A N/A N/A 
    Bivariate Gaussian distribution for equal shape *X*, *Y*.

    See `bivariate normal
    <http://mathworld.wolfram.com/BivariateNormalDistribution.html>`_
    at mathworld.
     N/A N/A X Y N/A N/A np transpose x N/A N/A mux muy mu N/A N/A sigmax sigmaxy tmp sigmay N/A N/A np ravel cov N/A N/A sigmax sigmay N/A N/A N/A np sqrt sigmax N/A N/A np sqrt sigmay N/A Xmu N/A X mux N/A Ymu N/A Y muy N/A rho N/A sigmaxy N/A sigmax sigmay N/A z N/A N/A N/A N/A Xmu 2 N/A sigmax 2 N/A N/A Ymu 2 N/A sigmay 2 N/A N/A N/A N/A 2 rho Xmu Ymu N/A sigmax sigmay N/A denom N/A N/A N/A N/A 2 N/A np pi sigmax sigmay N/A N/A np sqrt N/A 1 N/A rho 2 N/A N/A N/A N/A np exp N/A N/A z N/A 2 N/A 1 N/A rho 2 denom N/A BivariateNormal N/A object N/A __init__ N/A N/A self mean cov N/A N/A N/A N/A self mean mu N/A N/A self cov cov N/A N/A N/A self sigmax N/A self sigmaxy tmp N/A self sigmay N/A N/A np ravel cov N/A N/A self nvars 2 N/A rvs N/A N/A self size N/A 1 N/A N/A N/A N/A N/A np random multivariate_normal N/A self mean N/A self cov size size N/A pdf N/A N/A self x N/A N/A N/A N/A bivariate_normal x N/A self mean N/A self cov N/A logpdf N/A N/A self x N/A N/A N/A N/A N/A np log N/A N/A self pdf x N/A cdf N/A N/A self x N/A N/A N/A N/A N/A self expect upper x N/A expect N/A N/A self func lower upper N/A N/A N/A N/A x N/A 1 N/A -10 -10 N/A 10 10 N/A fun N/A N/A x y N/A N/A N/A x N/A N/A np column_stack N/A x y N/A N/A N/A func x N/A N/A self pdf x N/A scipy.integrate dblquad N/A N/A dblquad fun N/A lower N/A 0 N/A upper N/A 0 N/A N/A N/A y N/A N/A lower N/A 1 N/A N/A N/A y N/A N/A upper N/A 1 N/A kl N/A N/A self other N/A N/A N/A Kullback-Leibler divergence between this and another distribution

        int f(x) (log f(x) - log g(x)) dx

        where f is the pdf of self, and g is the pdf of other

        uses double integration with scipy.integrate.dblquad

        limits currently hardcoded

         N/A fun N/A N/A N/A x N/A N/A N/A N/A self logpdf x N/A N/A other logpdf x N/A N/A N/A self expect fun N/A kl_mc N/A N/A self other size N/A 500000 N/A N/A fun N/A N/A N/A x N/A N/A N/A N/A self logpdf x N/A N/A other logpdf x N/A rvs N/A N/A self rvs size size N/A N/A N/A N/A fun rvs mean N/A N/A MVElliptical N/A object N/A N/A Base Class for multivariate elliptical distributions, normal and t

    contains common initialization, and some common methods
    subclass needs to implement at least rvs and logpdf methods

     __init__ N/A N/A self mean sigma N/A args kwds N/A N/A initialize instance

        Parameters
        ----------
        mean : array_like
            parameter mu (might be renamed), for symmetric distributions this
            is the mean
        sigma : array_like, 2d
            dispersion matrix, covariance matrix in normal distribution, but
            only proportional to covariance matrix in t distribution
        args : list
            distribution specific arguments, e.g. df for t distribution
        kwds : dict
            currently not used

         N/A N/A self extra_args N/A N/A N/A self mean N/A N/A np asarray mean N/A N/A self sigma sigma N/A N/A np asarray sigma N/A sigma N/A N/A np squeeze sigma N/A N/A self nvars nvars N/A len mean N/A N/A N/A sigma shape N/A N/A N/A N/A self sigma N/A N/A N/A np eye nvars sigma N/A N/A self sigmainv N/A N/A N/A np eye nvars sigma N/A N/A self cholsigmainv N/A N/A N/A np eye nvars N/A N/A np sqrt sigma N/A N/A N/A N/A N/A sigma ndim 1 N/A N/A len sigma nvars N/A N/A N/A self sigma N/A N/A np diag sigma N/A N/A self sigmainv N/A N/A np diag N/A 1.0 sigma N/A N/A self cholsigmainv N/A N/A np diag N/A 1.0 N/A N/A np sqrt sigma N/A N/A N/A N/A sigma shape N/A nvars nvars N/A N/A N/A self sigmainv N/A N/A N/A np linalg pinv sigma N/A N/A self cholsigmainv N/A N/A N/A N/A np linalg cholesky N/A self sigmainv T N/A N/A N/A ValueError sigma has invalid shape N/A N/A self logdetsigma N/A N/A np log N/A N/A N/A np linalg det N/A self sigma N/A rvs N/A N/A self size N/A 1 N/A N/A random variable

        Parameters
        ----------
        size : int or tuple
            the number and shape of random variables to draw.

        Returns
        -------
        rvs : ndarray
            the returned random variables with shape given by size and the
            dimension of the multivariate random vector as additional last
            dimension


         N/A NotImplementedError N/A logpdf N/A N/A self x N/A N/A N/A logarithm of probability density function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector

        Returns
        -------
        logpdf : float or array
            probability density value of each random vector


        this should be made to work with 2d x,
        with multivariate normal vector in each row and iid across rows
        doesn't work now because of dot in whiten

         N/A NotImplementedError N/A cdf N/A N/A self x N/A kwds N/A N/A cumulative distribution function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector
        kwds : dict
            contains options for the numerical calculation of the cdf

        Returns
        -------
        cdf : float or array
            probability density value of each random vector

         N/A NotImplementedError N/A affine_transformed N/A N/A self shift scale_matrix N/A N/A N/A affine transformation define in subclass because of distribution
        specific restrictions N/A NotImplementedError N/A whiten N/A N/A self x N/A N/A N/A 
        whiten the data by linear transformation

        Parameters
        -----------
        x : array-like, 1d or 2d
            Data to be whitened, if 2d then each row contains an independent
            sample of the multivariate random vector

        Returns
        -------
        np.dot(x, self.cholsigmainv.T)

        Notes
        -----
        This only does rescaling, it doesn't subtract the mean, use standardize
        for this instead

        See Also
        --------
        standardize : subtract mean and rescale to standardized random variable.

         N/A x N/A N/A np asarray x N/A N/A N/A np dot x N/A N/A self cholsigmainv T N/A pdf N/A N/A self x N/A N/A N/A probability density function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector

        Returns
        -------
        pdf : float or array
            probability density value of each random vector

         N/A N/A N/A np exp N/A N/A self logpdf x N/A standardize N/A N/A self x N/A N/A N/A standardize the random variable, i.e. subtract mean and whiten

        Parameters
        -----------
        x : array-like, 1d or 2d
            Data to be whitened, if 2d then each row contains an independent
            sample of the multivariate random vector

        Returns
        -------
        np.dot(x - self.mean, self.cholsigmainv.T)

        Notes
        -----


        See Also
        --------
        whiten : rescale random variable, standardize without subtracting mean.


         N/A N/A N/A self whiten N/A x N/A self mean N/A standardized N/A N/A self N/A N/A N/A return new standardized MVNormal instance
         N/A N/A N/A self affine_transformed N/A N/A self mean N/A self cholsigmainv N/A normalize N/A N/A self x N/A N/A N/A normalize the random variable, i.e. subtract mean and rescale

        The distribution will have zero mean and sigma equal to correlation

        Parameters
        -----------
        x : array-like, 1d or 2d
            Data to be whitened, if 2d then each row contains an independent
            sample of the multivariate random vector

        Returns
        -------
        (x - self.mean)/std_sigma

        Notes
        -----


        See Also
        --------
        whiten : rescale random variable, standardize without subtracting mean.


         N/A std_ N/A N/A np atleast_2d N/A self std_sigma N/A N/A N/A x N/A self mean std_ N/A normalized N/A N/A self demeaned N/A True N/A N/A return a normalized distribution where sigma=corr

        if demeaned is True, then mean will be set to zero

         N/A demeaned N/A N/A mean_new N/A N/A np zeros_like N/A self mean N/A N/A mean_new N/A N/A self mean N/A self std_sigma N/A sigma_new N/A self corr N/A args N/A N/A getattr self ea N/A ea N/A self extra_args N/A N/A N/A self __class__ mean_new sigma_new args N/A normalized2 N/A N/A self demeaned N/A True N/A N/A return a normalized distribution where sigma=corr



        second implementation for testing affine transformation
         N/A demeaned N/A N/A shift N/A N/A self mean N/A N/A shift N/A N/A self mean N/A N/A 1.0 N/A self std_sigma 1.0 N/A N/A N/A self affine_transformed shift N/A N/A np diag N/A 1.0 N/A self std_sigma N/A std N/A N/A self N/A N/A N/A standard deviation, square root of diagonal elements of cov
         N/A N/A N/A np sqrt N/A N/A np diag N/A self cov N/A property std_sigma N/A N/A self N/A N/A N/A standard deviation, square root of diagonal elements of sigma
         N/A N/A N/A np sqrt N/A N/A np diag N/A self sigma N/A property corr N/A N/A self N/A N/A N/A correlation matrix N/A N/A N/A self cov N/A N/A np outer N/A self std N/A self std N/A property N/A expect_mc expect_mc marginal N/A N/A self indices N/A N/A N/A return marginal distribution for variables given by indices

        this should be correct for normal and t distribution

        Parameters
        ----------
        indices : array_like, int
            list of indices of variables in the marginal distribution

        Returns
        -------
        mvdist : instance
            new instance of the same multivariate distribution class that
            contains the marginal distribution of the variables given in
            indices

         N/A indices N/A N/A np asarray indices N/A mean_new N/A N/A self mean N/A indices N/A sigma_new N/A N/A self sigma N/A N/A N/A indices N/A N/A N/A None indices N/A args N/A N/A getattr self ea N/A ea N/A self extra_args N/A N/A N/A self __class__ mean_new sigma_new args N/A N/A MVNormal0 N/A object N/A N/A Class for Multivariate Normal Distribution

    original full version, kept for testing, new version inherits from
    MVElliptical

    uses Cholesky decomposition of covariance matrix for the transformation
    of the data

     __init__ N/A N/A self mean cov N/A N/A N/A N/A self mean mean N/A N/A self cov cov N/A N/A np asarray cov N/A cov N/A N/A np squeeze cov N/A N/A self nvars nvars N/A len mean N/A N/A N/A cov shape N/A N/A N/A N/A self cov N/A N/A N/A np eye nvars cov N/A N/A self covinv N/A N/A N/A np eye nvars cov N/A N/A self cholcovinv N/A N/A N/A np eye nvars N/A N/A np sqrt cov N/A N/A N/A N/A N/A cov ndim 1 N/A N/A len cov nvars N/A N/A N/A self cov N/A N/A np diag cov N/A N/A self covinv N/A N/A np diag N/A 1.0 cov N/A N/A self cholcovinv N/A N/A np diag N/A 1.0 N/A N/A np sqrt cov N/A N/A N/A N/A cov shape N/A nvars nvars N/A N/A N/A self covinv N/A N/A N/A np linalg pinv cov N/A N/A self cholcovinv N/A N/A N/A N/A np linalg cholesky N/A self covinv T N/A N/A N/A ValueError cov has invalid shape N/A N/A self logdetcov N/A N/A np log N/A N/A N/A np linalg det N/A self cov N/A whiten N/A N/A self x N/A N/A N/A 
        whiten the data by linear transformation

        Parameters
        -----------
        X : array-like, 1d or 2d
            Data to be whitened, if 2d then each row contains an independent
            sample of the multivariate random vector

        Returns
        -------
        np.dot(x, self.cholcovinv.T)

        Notes
        -----
        This only does rescaling, it doesn't subtract the mean, use standardize
        for this instead

        See Also
        --------
        standardize : subtract mean and rescale to standardized random variable.

         N/A x N/A N/A np asarray x N/A N/A N/A np any N/A self cov N/A N/A N/A N/A np dot x N/A N/A self cholcovinv T N/A N/A x N/A rvs N/A N/A self size N/A 1 N/A N/A random variable

        Parameters
        ----------
        size : int or tuple
            the number and shape of random variables to draw.

        Returns
        -------
        rvs : ndarray
            the returned random variables with shape given by size and the
            dimension of the multivariate random vector as additional last
            dimension

        Notes
        -----
        uses numpy.random.multivariate_normal directly

         N/A N/A N/A N/A np random multivariate_normal N/A self mean N/A self cov size size N/A pdf N/A N/A self x N/A N/A N/A probability density function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector

        Returns
        -------
        pdf : float or array
            probability density value of each random vector

         N/A N/A N/A np exp N/A N/A self logpdf x N/A logpdf N/A N/A self x N/A N/A N/A logarithm of probability density function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector

        Returns
        -------
        logpdf : float or array
            probability density value of each random vector


        this should be made to work with 2d x,
        with multivariate normal vector in each row and iid across rows
        doesn't work now because of dot in whiten

         N/A x N/A N/A np asarray x N/A x_whitened N/A N/A self whiten N/A x N/A self mean N/A SSR N/A N/A np sum N/A x_whitened 2 -1 N/A llf N/A SSR N/A llf N/A N/A self nvars N/A N/A np log N/A 2.0 N/A np pi N/A llf N/A self logdetcov N/A llf 0.5 N/A llf N/A N/A expect_mc expect_mc N/A MVNormal N/A MVElliptical N/A N/A Class for Multivariate Normal Distribution

    uses Cholesky decomposition of covariance matrix for the transformation
    of the data

     N/A N/A __name__ Multivariate Normal Distribution rvs N/A N/A self size N/A 1 N/A N/A random variable

        Parameters
        ----------
        size : int or tuple
            the number and shape of random variables to draw.

        Returns
        -------
        rvs : ndarray
            the returned random variables with shape given by size and the
            dimension of the multivariate random vector as additional last
            dimension

        Notes
        -----
        uses numpy.random.multivariate_normal directly

         N/A N/A N/A N/A np random multivariate_normal N/A self mean N/A self sigma size size N/A logpdf N/A N/A self x N/A N/A N/A logarithm of probability density function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector

        Returns
        -------
        logpdf : float or array
            probability density value of each random vector


        this should be made to work with 2d x,
        with multivariate normal vector in each row and iid across rows
        doesn't work now because of dot in whiten

         N/A x N/A N/A np asarray x N/A x_whitened N/A N/A self whiten N/A x N/A self mean N/A SSR N/A N/A np sum N/A x_whitened 2 -1 N/A llf N/A SSR N/A llf N/A N/A self nvars N/A N/A np log N/A 2.0 N/A np pi N/A llf N/A self logdetsigma N/A llf 0.5 N/A llf N/A cdf N/A N/A self x N/A kwds N/A N/A cumulative distribution function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector
        kwds : dict
            contains options for the numerical calculation of the cdf

        Returns
        -------
        cdf : float or array
            probability density value of each random vector

         N/A N/A mvnormcdf x N/A self mean N/A self cov kwds N/A cov N/A N/A self N/A N/A N/A covariance matrix N/A N/A self sigma N/A property affine_transformed N/A N/A self shift scale_matrix N/A N/A N/A return distribution of an affine transform

        for full rank scale_matrix only

        Parameters
        ----------
        shift : array_like
            shift of mean
        scale_matrix : array_like
            linear transformation matrix

        Returns
        -------
        mvt : instance of MVT
            instance of multivariate t distribution given by affine
            transformation


        Notes
        -----
        the affine transformation is defined by
        y = a + B x

        where a is shift,
        B is a scale matrix for the linear transformation

        Notes
        -----
        This should also work to select marginal distributions, but not
        tested for this case yet.

        currently only tested because it's called by standardized

         N/A B scale_matrix N/A mean_new N/A N/A N/A np dot B N/A self mean shift N/A sigma_new N/A N/A np dot N/A N/A np dot B N/A self sigma N/A B T N/A N/A MVNormal mean_new sigma_new N/A conditional N/A N/A self indices values N/A N/A N/A return conditional distribution

        indices are the variables to keep, the complement is the conditioning
        set
        values are the values of the conditioning variables

        ar{\mu} = \mu_1 + \Sigma_{12} \Sigma_{22}^{-1} \left( a - \mu_2 
ight)

        and covariance matrix

        \overline{\Sigma} = \Sigma_{11} - \Sigma_{12} \Sigma_{22}^{-1} \Sigma_{21}.T

        Parameters
        ----------
        indices : array_like, int
            list of indices of variables in the marginal distribution
        given : array_like
            values of the conditioning variables

        Returns
        -------
        mvn : instance of MVNormal
            new instance of the MVNormal class that contains the conditional
            distribution of the variables given in indices for given
             values of the excluded variables.


         N/A keep N/A N/A np asarray indices N/A given N/A N/A np asarray N/A i N/A i N/A range N/A self nvars N/A N/A i keep N/A sigmakk N/A N/A self sigma N/A N/A N/A keep N/A N/A N/A None keep N/A sigmagg N/A N/A self sigma N/A N/A N/A given N/A N/A N/A None given N/A sigmakg N/A N/A self sigma N/A N/A N/A keep N/A N/A N/A None given N/A sigmagk N/A N/A self sigma N/A N/A N/A given N/A N/A N/A None keep N/A sigma_new N/A sigmakk N/A N/A np dot sigmakg N/A N/A N/A np linalg solve sigmagg sigmagk N/A mean_new N/A N/A N/A self mean N/A keep N/A N/A np dot sigmakg N/A N/A N/A np linalg solve sigmagg N/A values N/A N/A self mean N/A given N/A N/A MVNormal mean_new sigma_new N/A N/A scipy special N/A np_log N/A np log N/A np_pi N/A np pi N/A sps_gamln N/A special gammaln MVT N/A MVElliptical N/A N/A N/A __name__ Multivariate Student T Distribution __init__ N/A N/A self mean sigma df N/A N/A N/A initialize instance

        Parameters
        ----------
        mean : array_like
            parameter mu (might be renamed), for symmetric distributions this
            is the mean
        sigma : array_like, 2d
            dispersion matrix, covariance matrix in normal distribution, but
            only proportional to covariance matrix in t distribution
        args : list
            distribution specific arguments, e.g. df for t distribution
        kwds : dict
            currently not used

         N/A N/A N/A N/A super MVT self __init__ mean sigma N/A N/A self extra_args N/A df N/A N/A self df df N/A rvs N/A N/A self size N/A 1 N/A N/A random variables with Student T distribution

        Parameters
        ----------
        size : int or tuple
            the number and shape of random variables to draw.

        Returns
        -------
        rvs : ndarray
            the returned random variables with shape given by size and the
            dimension of the multivariate random vector as additional last
            dimension
            - TODO: Not sure if this works for size tuples with len>1.

        Notes
        -----
        generated as a chi-square mixture of multivariate normal random
        variables.
        does this require df>2 ?


         multivariate multivariate_t_rvs N/A N/A multivariate_t_rvs N/A self mean N/A self sigma df N/A self df n size N/A logpdf N/A N/A self x N/A N/A N/A logarithm of probability density function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector

        Returns
        -------
        logpdf : float or array
            probability density value of each random vector

         N/A x N/A N/A np asarray x N/A df N/A self df N/A nvars N/A self nvars N/A x_whitened N/A N/A self whiten N/A x N/A self mean N/A llf N/A N/A nvars N/A np_log N/A df np_pi N/A llf N/A self logdetsigma N/A llf N/A N/A df nvars N/A np_log N/A 1 N/A N/A N/A np sum N/A x_whitened 2 -1 df N/A llf 0.5 N/A llf N/A N/A sps_gamln N/A N/A df nvars 2.0 N/A sps_gamln N/A df 2.0 N/A llf N/A cdf N/A N/A self x N/A kwds N/A N/A cumulative distribution function

        Parameters
        ----------
        x : array_like
            can be 1d or 2d, if 2d, then each row is taken as independent
            multivariate random vector
        kwds : dict
            contains options for the numerical calculation of the cdf

        Returns
        -------
        cdf : float or array
            probability density value of each random vector

         N/A lower N/A N/A N/A np inf N/A N/A np ones_like x N/A upper N/A N/A x N/A self mean N/A self std_sigma N/A N/A mvstdtprob lower upper N/A self corr N/A self df kwds N/A cov N/A N/A self N/A N/A N/A covariance matrix

        The covariance matrix for the t distribution does not exist for df<=2,
        and is equal to sigma * df/(df-2) for df>2

         N/A N/A N/A self df 2 N/A N/A N/A N/A np nan N/A N/A np ones_like N/A self sigma N/A N/A N/A N/A N/A self df N/A N/A self df 2.0 N/A self sigma N/A property affine_transformed N/A N/A self shift scale_matrix N/A N/A N/A return distribution of a full rank affine transform

        for full rank scale_matrix only

        Parameters
        ----------
        shift : array_like
            shift of mean
        scale_matrix : array_like
            linear transformation matrix

        Returns
        -------
        mvt : instance of MVT
            instance of multivariate t distribution given by affine
            transformation


        Notes
        -----

        This checks for eigvals<=0, so there are possible problems for cases
        with positive eigenvalues close to zero.

        see: http://www.statlect.com/mcdstu1.htm

        I'm not sure about general case, non-full rank transformation are not
        multivariate t distributed.

        y = a + B x

        where a is shift,
        B is full rank scale matrix with same dimension as sigma

         N/A B scale_matrix N/A N/A N/A N/A B shape N/A N/A self nvars N/A self nvars N/A N/A N/A N/A N/A N/A N/A N/A np linalg eigvals B 0 any N/A N/A N/A ValueError affine transform has to be full rank N/A mean_new N/A N/A N/A np dot B N/A self mean shift N/A sigma_new N/A N/A np dot N/A N/A np dot B N/A self sigma N/A B T N/A N/A MVT mean_new sigma_new N/A self df N/A N/A quad2d N/A N/A func lower upper N/A N/A N/A N/A x N/A 1 N/A -10 -10 N/A 10 10 N/A fun N/A N/A x y N/A N/A N/A x N/A N/A np column_stack N/A x y N/A N/A func x N/A scipy.integrate dblquad N/A N/A dblquad fun N/A lower N/A 0 N/A upper N/A 0 N/A N/A N/A y N/A N/A lower N/A 1 N/A N/A N/A y N/A N/A upper N/A 1 N/A N/A N/A __name__ __main__ N/A numpy.testing assert_almost_equal assert_array_almost_equal N/A examples N/A mvn N/A mu N/A 0 0 N/A covx N/A N/A np array N/A N/A 1.0 0.5 N/A 0.5 1.0 N/A mu3 N/A -1 0.0 2.0 N/A cov3 N/A N/A np array N/A N/A 1.0 0.5 0.75 N/A 0.5 1.5 0.6 N/A 0.75 0.6 2.0 N/A N/A mvn examples N/A N/A bvn N/A BivariateNormal mu covx N/A rvs N/A N/A bvn rvs size 1000 N/A N/A print N/A N/A rvs mean 0 N/A N/A print N/A N/A np cov rvs rowvar 0 N/A N/A print N/A N/A bvn expect N/A N/A print N/A N/A bvn cdf N/A 0 0 N/A bvn1 N/A BivariateNormal mu N/A N/A np eye 2 N/A bvn2 N/A BivariateNormal mu N/A 4 N/A N/A np eye 2 N/A fun N/A N/A N/A x N/A N/A N/A N/A np log N/A N/A bvn1 pdf x N/A N/A np log N/A N/A bvn pdf x N/A N/A print N/A N/A bvn1 expect fun N/A N/A print N/A N/A bvn1 kl bvn2 N/A N/A bvn1 kl_mc bvn2 N/A N/A print N/A N/A bvn2 kl bvn1 N/A N/A bvn2 kl_mc bvn1 N/A N/A print N/A N/A bvn1 kl bvn N/A N/A bvn1 kl_mc bvn N/A mvn N/A MVNormal mu covx N/A N/A N/A mvn pdf N/A 0 0 N/A N/A N/A mvn pdf N/A N/A np zeros N/A 2 2 N/A cov3 N/A N/A np array N/A N/A 1.0 0.5 0.75 N/A 0.5 1.5 0.6 N/A 0.75 0.6 2.0 N/A mu3 N/A -1 0.0 2.0 N/A mvn3 N/A MVNormal mu3 cov3 N/A N/A N/A mvn3 pdf N/A 0.0 2.0 3.0 N/A N/A N/A mvn3 logpdf N/A 0.0 2.0 3.0 N/A r_val N/A -7.6679775439 -6.9179775439 -5.1679775439 N/A N/A assert_array_almost_equal N/A N/A mvn3 logpdf cov3 r_val decimal 14 N/A r_val N/A 0.000467562492722 0.000989829804859 0.00569607724383 N/A N/A assert_array_almost_equal N/A N/A mvn3 pdf cov3 r_val decimal 17 N/A mvn3c N/A MVNormal N/A N/A np array N/A 0 0 0 cov3 N/A r_val N/A 0.029142697405 0.0226963555598 0.0176759394829 N/A N/A assert_array_almost_equal N/A N/A mvn3c pdf cov3 r_val decimal 16 N/A mvn3b N/A MVNormal N/A 0 0 0 1 N/A fun N/A N/A N/A x N/A N/A N/A N/A np log N/A N/A mvn3 pdf x N/A N/A np log N/A N/A mvn3b pdf x N/A N/A print N/A N/A mvn3 expect_mc fun N/A N/A print N/A N/A mvn3 expect_mc fun size 200000 N/A mvt N/A MVT N/A 0 0 1 5 N/A N/A assert_almost_equal N/A N/A mvt logpdf N/A N/A np array N/A 0.0 0.0 -1.83787706641 decimal 15 N/A N/A assert_almost_equal N/A N/A mvt pdf N/A N/A np array N/A 0.0 0.0 0.159154943092 decimal 15 N/A N/A N/A N/A mvt logpdf N/A N/A np array N/A 1.0 1.0 -3.01552989458 N/A mvt1 N/A MVT N/A 0 0 1 1 N/A N/A N/A N/A mvt1 logpdf N/A N/A np array N/A 1.0 1.0 -3.48579549941 N/A rvs N/A N/A mvt rvs 100000 N/A N/A assert_almost_equal N/A N/A np cov rvs rowvar 0 N/A mvt cov decimal 1 N/A mvt31 N/A MVT mu3 cov3 1 N/A N/A assert_almost_equal N/A N/A mvt31 pdf cov3 N/A 0.000727681869817 0.000998062518229 0.00276614220562 decimal 18 N/A mvt N/A MVT mu3 cov3 3 N/A N/A assert_almost_equal N/A N/A mvt pdf cov3 N/A 0.000863777424247 0.00127751078831 0.00415631427945 decimal 17