Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Markov Switching Multifractal model
Cython code """ from __future__ import absolute_import
from sage.misc.randstate cimport randstate, current_randstate
cdef extern from "math.h": double sqrt(double)
from .time_series cimport TimeSeries
double m0, double sigma, int kbar, gamma): """ Return k simulations of length n using the Markov switching multifractal model.
INPUT: n, k -- positive integers m0, sigma -- floats kbar -- integer gamma -- list of floats
OUTPUT: list of lists
EXAMPLES: sage: set_random_seed(0) sage: msm = finance.MarkovSwitchingMultifractal(8,1.4,1.0,0.95,3) sage: import sage.finance.markov_multifractal_cython sage: sage.finance.markov_multifractal_cython.simulations(5,2,1.278,0.262,8,msm.gamma()) [[0.0014, -0.0023, -0.0028, -0.0030, -0.0019], [0.0020, -0.0020, 0.0034, -0.0010, -0.0004]] """ cdef Py_ssize_t i, j, a, c cdef TimeSeries t, eps
# output list of simulations
# Initialize the model # n & 1 means "is odd"
# Generate n normally distributed random numbers with mean 0 # and variance 1.
# Compute next step in the simulation
# Now update the volatility state vector
|