@classmethod<EOL><INDENT>def cont_discr_kalman_filter(cls, F, L, Qc, p_H, p_R, P_inf, X, Y, index = None,<EOL>m_init=None, P_init=None,<EOL>p_kalman_filter_type='<STR_LIT>',<EOL>calc_log_likelihood=False,<EOL>calc_grad_log_likelihood=False,<EOL>grad_params_no=<NUM_LIT:0>, grad_calc_params=None):<DEDENT>
p_H = np.atleast_1d(p_H)<EOL>p_R = np.atleast_1d(p_R)<EOL>X.shape, old_X_shape  = cls._reshape_input_data(X.shape, <NUM_LIT:2>) <EOL>if (X.shape[<NUM_LIT:1>] != <NUM_LIT:1>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>Y.shape, old_Y_shape  = cls._reshape_input_data(Y.shape) <EOL>state_dim = F.shape[<NUM_LIT:0>]<EOL>measurement_dim = Y.shape[<NUM_LIT:1>]<EOL>time_series_no = Y.shape[<NUM_LIT:2>] <EOL>if  ((len(p_H.shape) == <NUM_LIT:3>) and (len(p_H.shape[<NUM_LIT:2>]) != <NUM_LIT:1>)) or((len(p_R.shape) == <NUM_LIT:3>) and (len(p_R.shape[<NUM_LIT:2>]) != <NUM_LIT:1>)):<EOL><INDENT>model_matrices_chage_with_time = True<EOL><DEDENT>else:<EOL><INDENT>model_matrices_chage_with_time = False<EOL><DEDENT>old_index_shape = None<EOL>if index is None:<EOL><INDENT>if (len(p_H.shape) == <NUM_LIT:3>) or (len(p_R.shape) == <NUM_LIT:3>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>else: <EOL><INDENT>index = np.zeros((<NUM_LIT:1>,Y.shape[<NUM_LIT:0>]))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if len(index.shape) == <NUM_LIT:1>:<EOL><INDENT>index.shape = (<NUM_LIT:1>,index.shape[<NUM_LIT:0>])<EOL>old_index_shape = (index.shape[<NUM_LIT:0>],)<EOL><DEDENT>if (index.shape[<NUM_LIT:1>] != Y.shape[<NUM_LIT:0>]):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>if (index.shape[<NUM_LIT:0>] == <NUM_LIT:1>):<EOL><INDENT>H_time_var_index = <NUM_LIT:0>; R_time_var_index = <NUM_LIT:0><EOL><DEDENT>elif (index.shape[<NUM_LIT:0>] == <NUM_LIT:4>):<EOL><INDENT>H_time_var_index = <NUM_LIT:0>; R_time_var_index = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>(p_H, old_H_shape) = cls._check_SS_matrix(p_H, state_dim, measurement_dim, which='<STR_LIT:H>')<EOL>(p_R, old_R_shape) = cls._check_SS_matrix(p_R, state_dim, measurement_dim, which='<STR_LIT:R>')<EOL>if m_init is None:<EOL><INDENT>m_init = np.zeros((state_dim, time_series_no))<EOL><DEDENT>else:<EOL><INDENT>m_init = np.atleast_2d(m_init).T<EOL><DEDENT>if P_init is None:<EOL><INDENT>P_init = P_inf.copy()<EOL><DEDENT>if p_kalman_filter_type not in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if calc_grad_log_likelihood:<EOL><INDENT>dF = cls._check_grad_state_matrices(grad_calc_params.get('<STR_LIT>'), state_dim, grad_params_no, which = '<STR_LIT>')<EOL>dQc = cls._check_grad_state_matrices(grad_calc_params.get('<STR_LIT>'), state_dim, grad_params_no, which = '<STR_LIT>')<EOL>dP_inf = cls._check_grad_state_matrices(grad_calc_params.get('<STR_LIT>'), state_dim, grad_params_no, which = '<STR_LIT>')<EOL>dH = cls._check_grad_measurement_matrices(grad_calc_params.get('<STR_LIT>'), state_dim, grad_params_no, measurement_dim, which = '<STR_LIT>')<EOL>dR = cls._check_grad_measurement_matrices(grad_calc_params.get('<STR_LIT>'), state_dim, grad_params_no, measurement_dim, which = '<STR_LIT>')<EOL>dm_init = grad_calc_params.get('<STR_LIT>') <EOL>if dm_init is None:<EOL><INDENT>dm_init = np.zeros( (state_dim, time_series_no, grad_params_no) )<EOL><DEDENT>dP_init = grad_calc_params.get('<STR_LIT>') <EOL>if dP_init is None:<EOL><INDENT>dP_init = dP_inf(<NUM_LIT:0>).copy() <EOL><DEDENT><DEDENT>else:<EOL><INDENT>dP_inf = None<EOL>dF = None<EOL>dQc = None<EOL>dH = None<EOL>dR = None<EOL>dm_init = None<EOL>dP_init = None<EOL><DEDENT>measurement_callables = Std_Measurement_Callables_Class(p_H, H_time_var_index, p_R, index, R_time_var_index, <NUM_LIT:20>, dH, dR)<EOL>dynamic_callables = cls._cont_to_discrete_object(X, F, L, Qc, compute_derivatives=calc_grad_log_likelihood,<EOL>grad_params_no=grad_params_no,<EOL>P_inf=P_inf, dP_inf=dP_inf, dF = dF, dQc=dQc)<EOL>if print_verbose:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>(M, P, log_likelihood, grad_log_likelihood, AQcomp) = cls._cont_discr_kalman_filter_raw(state_dim,<EOL>dynamic_callables, measurement_callables,<EOL>X, Y, m_init=m_init, P_init=P_init,<EOL>p_kalman_filter_type=p_kalman_filter_type,<EOL>calc_log_likelihood=calc_log_likelihood,<EOL>calc_grad_log_likelihood=calc_grad_log_likelihood, grad_params_no=grad_params_no,<EOL>dm_init=dm_init, dP_init=dP_init)<EOL>if old_index_shape is not None:<EOL><INDENT>index.shape = old_index_shape<EOL><DEDENT>if old_X_shape is not None:<EOL><INDENT>X.shape = old_X_shape<EOL><DEDENT>if old_Y_shape is not None:<EOL><INDENT>Y.shape = old_Y_shape<EOL><DEDENT>if old_H_shape is not None:<EOL><INDENT>p_H.shape = old_H_shape<EOL><DEDENT>if old_R_shape is not None:<EOL><INDENT>p_R.shape = old_R_shape<EOL><DEDENT>return (M, P, log_likelihood, grad_log_likelihood, AQcomp)<EOL>
This function implements the continuous-discrete Kalman Filter algorithm
These notations for the State-Space model are assumed:
    d/dt x(t) =  F * x(t) + L * w(t);         w(t) ~ N(0, Qc)
    y_{k} = H_{k} * x_{k} + r_{k};            r_{k-1} ~ N(0, R_{k})

Returns estimated filter distributions x_{k} ~ N(m_{k}, P(k))

Current Features:
----------------------------------------
1) The function generaly do not modify the passed parameters. If
it happens then it is an error. There are several exeprions: scalars
can be modified into a matrix, in some rare cases shapes of
the derivatives matrices may be changed, it is ignored for now.

2) Copies of F,L,Qc are created in memory because they may be used later
in smoother. References to copies are kept in "AQcomp" object
return parameter.

3) Function support "multiple time series mode" which means that exactly
the same State-Space model is used to filter several sets of measurements.
In this case third dimension of Y should include these state-space measurements
Log_likelihood and Grad_log_likelihood have the corresponding dimensions then.

4) Calculation of Grad_log_likelihood is not supported if matrices
H, or R changes overf time (with index k). (later may be changed)

5) Measurement may include missing values. In this case update step is
not done for this measurement. (later may be changed)

Input:
-----------------

F: (state_dim, state_dim) matrix
    F in the model.

L: (state_dim, noise_dim) matrix
    L in the model.

Qc: (noise_dim, noise_dim) matrix
    Q_c in the model.

p_H: scalar, matrix (measurement_dim, state_dim) , 3D array
    H_{k} in the model. If matrix then H_{k} = H - constant.
    If it is 3D array then H_{k} = p_Q[:,:, index[2,k]]

p_R: scalar, square symmetric matrix, 3D array
    R_{k} in the model. If matrix then R_{k} = R - constant.
    If it is 3D array then R_{k} = p_R[:,:, index[3,k]]

P_inf: (state_dim, state_dim) matrix
    State varince matrix on infinity.

X: 1D array
    Time points of measurements. Needed for converting continuos
    problem to the discrete one.

Y: matrix or vector or 3D array
    Data. If Y is matrix then samples are along 0-th dimension and
    features along the 1-st. If 3D array then third dimension
    correspond to "multiple time series mode".

index: vector
    Which indices (on 3-rd dimension) from arrays p_H, p_R to use
    on every time step. If this parameter is None then it is assumed
    that p_H, p_R do not change over time and indices are not needed.
    index[0,:] - correspond to H, index[1,:] - correspond to R
    If index.shape[0] == 1, it is assumed that indides for all matrices
    are the same.

m_init: vector or matrix
    Initial distribution mean. If None it is assumed to be zero.
    For "multiple time series mode" it is matrix, second dimension of
    which correspond to different time series. In regular case ("one
    time series mode") it is a vector.

P_init: square symmetric matrix or scalar
    Initial covariance of the states. If the parameter is scalar
    then it is assumed that initial covariance matrix is unit matrix
    multiplied by this scalar. If None the unit matrix is used instead.
    "multiple time series mode" does not affect it, since it does not
    affect anything related to state variaces.

p_kalman_filter_type: string, one of ('regular', 'svd')
    Which Kalman Filter is used. Regular or SVD. SVD is more numerically
    stable, in particular, Covariace matrices are guarantied to be
    positive semi-definite. However, 'svd' works slower, especially for
    small data due to SVD call overhead.

calc_log_likelihood: boolean
    Whether to calculate marginal likelihood of the state-space model.

calc_grad_log_likelihood: boolean
    Whether to calculate gradient of the marginal likelihood
    of the state-space model. If true then "grad_calc_params" parameter must
    provide the extra parameters for gradient calculation.

grad_params_no: int
    If previous parameter is true, then this parameters gives the
    total number of parameters in the gradient.

grad_calc_params: dictionary
    Dictionary with derivatives of model matrices with respect
    to parameters "dF", "dL", "dQc", "dH", "dR", "dm_init", "dP_init".
    They can be None, in this case zero matrices (no dependence on parameters)
    is assumed. If there is only one parameter then third dimension is
    automatically added.

Output:
--------------

M: (no_steps+1,state_dim) matrix or (no_steps+1,state_dim, time_series_no) 3D array
    Filter estimates of the state means. In the extra step the initial
    value is included. In the "multiple time series mode" third dimension
    correspond to different timeseries.

P: (no_steps+1, state_dim, state_dim) 3D array
    Filter estimates of the state covariances. In the extra step the initial
    value is included.

log_likelihood: double or (1, time_series_no) 3D array.

    If the parameter calc_log_likelihood was set to true, return
    logarithm of marginal likelihood of the state-space model. If
    the parameter was false, return None. In the "multiple time series mode" it is a vector
    providing log_likelihood for each time series.

grad_log_likelihood: column vector or (grad_params_no, time_series_no) matrix
    If calc_grad_log_likelihood is true, return gradient of log likelihood
    with respect to parameters. It returns it column wise, so in
    "multiple time series mode" gradients for each time series is in the
    corresponding column.

AQcomp: object
    Contains some pre-computed values for converting continuos model into
    discrete one. It can be used later in the smoothing pahse.