-
Notifications
You must be signed in to change notification settings - Fork 1
Saving Random Variables
Matthew Robinson edited this page Aug 7, 2016
·
1 revision
APPLPy uses the Python pickle function to store random variables to disk as binary objects. This allows random variables that are computed during one session to be loaded into a later session without recomputing. Since many random variable operations are computationally expensive, this can save a lot of time.
Random variables can be saved using the save method. Although APPLPy does not require special formatting for random variable binary files, we suggest using .rv as a file extension.
X.save(filename)In [124]: X = ExponentialRV(Rational(1,3))
In [125]: Y = ExponentialRV(Rational(1,4))
In [126]: Z = X+Y
In [127]: Z.save('conv.rv')Saved random variables can be loaded into later sessions using the LoadRV function
LoadRV(filename)In [129]: X = LoadRV('conv.rv')
In [130]: X.display()
continuous pdf
for 0 <= x <= oo
---------------------------
-x -x
─── ───
3 4
- ℯ + ℯ
---------------------------