utils⚓︎
Utilities to help define hidden Markov models.
NamedFunc
⚓︎
Provides custom repr for functions.
Id_Obs(Nx)
⚓︎
Specify identity observations of entire state.
It is not a function of time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Nx
|
int
|
Length of state vector |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Obs |
dict
|
Observation operator including size of the observation space, observation operator/model and tangent linear observation operator |
Id_op()
⚓︎
Id operator (named). Returns first argument.
direct_obs_matrix(Nx, obs_inds)
⚓︎
Generate matrix that "picks" state elements obs_inds out of range(Nx).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Nx
|
int
|
Length of state vector |
required |
obs_inds
|
ndarray
|
Indices of elements of the state vector that are (directly) observed. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
H |
ndarray
|
The observation matrix for direct partial observations. |
ens_compatible(func)
⚓︎
Decorate to transpose before and after, i.e. func(input.T).T.
This is helpful to make functions compatible with both 1d and 2d ndarrays.
This is not the_way™
Other tricks (ref mods) are sometimes more practical.
Examples:
mods.Lorenz63.dxdt, mods.DoublePendulum.dxdt
See Also
np.atleast_2d, np.squeeze, np.vectorize
linear_model_setup(ModelMatrix, dt0)
⚓︎
Make the Dyn/Obs field of a HMM representing a linear model.
Let M be the model matrix. Then
i.e.
In typical use, dt0==dt (where dt is defined by the chronology).
Anyways, dt must be an integer multiple of dt0.
Returns:
| Type | Description |
|---|---|
A `dict` with keys: 'M', 'model', 'linear'.
|
|
linspace_int(Nx, Ny, periodic=True)
⚓︎
Provide a range of Ny equispaced integers between 0 and Nx-1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Nx
|
int
|
Range of integers |
required |
Ny
|
int
|
Number of integers |
required |
periodic
|
bool
|
Whether the vector is periodic.
Determines if |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
integers |
ndarray
|
The list of integers. |
Examples:
name_func(name)
⚓︎
Decorator for creating NamedFunc.
partial_Id_Obs(Nx, obs_inds)
⚓︎
Specify identity observations of a subset of obs. indices.
It is not a function of time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Nx
|
int
|
Length of state vector |
required |
obs_inds
|
ndarray
|
The observed indices. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Obs |
dict
|
Observation operator including size of the observation space, observation operator/model and tangent linear observation operator |