-
Notifications
You must be signed in to change notification settings - Fork 1
Expected Values
MthwRobinson edited this page Dec 21, 2014
·
1 revision
APPLPy supports the computation of a variety of expected values, along with moment generating functions. Some of the expected value procedures have a cache
option that allows the result to be stored in memory. The next time the procedure is called, APPLPy will simply retrieve the result from memory, rather than recomputing it.
CoefOfVar(X,cache=False)
ExpectedValue(X,gX=x)
Kurtosis(X,cache=False)
Mean(X,cache=False)
MGF(X)
Skewness(X,cache=False)
Variance(X,cache=False)
In [65]: X=WeibullRV()
In [66]: CoefOfVar(X)
Out[66]:
________________________
╱ 2
╱ ⎛ 1⎞ ⎛ 2⎞
╱ - Γ⎜1 + ─⎟ + Γ⎜1 + ─⎟
╲╱ ⎝ κ⎠ ⎝ κ⎠
─────────────────────────────
⎛ 1⎞
Γ⎜1 + ─⎟
⎝ κ⎠
In [69]: X=NormalRV(2,2)
In [70]: ExpectedValue(X,x**2)
Out[70]: 8
In [71]: X=BetaRV(2,2)
In [72]: Kurtosis(X)
Out[72]: 15/7
In [73]: X=ExponentialRV()
In [74]: Mean(X)
Out[74]:
1
─
θ
In [76]: X=UniformRV()
In [77]: MGF(X)
Out[77]:
⎧ 1 for t⋅(a - b) = 0
⎪
⎪ a⋅t b⋅t
⎨ℯ - ℯ
⎪─────────── otherwise
⎪ t⋅(a - b)
⎩
In [78]: X=BetaRV(2,3)
In [79]: Skewness(X)
Out[79]: 2/7
In [80]: X=UniformRV()
In [81]: X=WeibullRV()
In [82]: %timeit Variance(X)
10 loops, best of 3: 125 ms per loop
In [83]: Variance(X,cache=True)
Out[83]:
2
⎛ 1⎞ ⎛ 2⎞
- Γ⎜1 + ─⎟ + Γ⎜1 + ─⎟
⎝ κ⎠ ⎝ κ⎠
──────────────────────
2
θ
In [84]: %timeit Variance(X)
1000000 loops, best of 3: 460 ns per loop