Cubic chaotic map and its chaotic walk
Bertin's cubic chaotic map and the chaotic walk it drives.
- Class:
CubicChaoticMapSystem - Import:
from skcomplex.systems.mathematics.dynamical_systems import CubicChaoticMapSystem - Field:
mathematics/dynamical_systems - Topics:
chaos,discrete map,random walk,diffusion - References:
- Bertin 2021
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.mathematics.dynamical_systems import CubicChaoticMapSystem
trajectory = CubicChaoticMapSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_walkers |
100 |
lam |
15.0 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | discrete |
| Space | continuous |
| Laws | update |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class CubicChaoticMapSystem(BaseSystem):
"""Bertin's cubic chaotic map and the chaotic walk it drives.
The walk spreads like a random walk.
Every walker follows the map `u' = λ u (u - 1/2)(u - 1) + u` on the unit interval and moves by the step `x' = x + 2u
- 1`. The fixed point `u = 1/2` is stable for `λ < 8`, a period-two cycle follows, and the map is chaotic at `λ =
15`. The walkers start at `x = 0` with values of `u` spread regularly over the unit interval, so the mean position
stays near 0 while the mean square position grows linearly in time, and the invariant density of `u` is not uniform.
The system has the states `walkers.u` and `walkers.x` and the observables `displacement`, the mean position, and
`square_displacement`, the mean square position.
Args:
n_walkers:
The number of walkers of the ensemble.
lam:
The parameter `λ` of the map, between 0 and 16.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.mathematics.dynamical_systems import CubicChaoticMapSystem
>>> CubicChaoticMapSystem(4, lam=10.0).prepare().system_.elements[0].size
4
"""
field = 'mathematics/dynamical_systems'
topics = ('chaos', 'discrete map', 'random walk', 'diffusion')
references = ('Bertin 2021',)
until = 200
dt = 1
observables = (
Observable('displacement', group='walkers', variable='x'),
Observable('square_displacement', _get_square_displacement, group='walkers'),
)
def __init__(
self,
n_walkers: int = 100,
*,
lam: float = 15.0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.n_walkers = n_walkers
self.lam = lam
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the walkers on a line and the map that drives them."""
super()._prepare(context)
start = (np.arange(self.n_walkers) + 1 / 4) / self.n_walkers
walkers = CubicWalkElement('walkers', u=start, size=self.n_walkers, space=ContinuousSpace(n_dim=1))
self.system_ = System(
self.label,
elements=[walkers],
interactions=[CubicWalkInteraction('walk', target='walkers', lam=self.lam)],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
CubicWalkElement, fromElement
Interactions:
CubicWalkInteraction, fromInteraction
class CubicWalkElement(Element):
"""Walkers driven by a chaotic map, each with the value `u` of its map and its position `x`.
Args:
label:
The label of the walkers.
u:
The initial value of the map, between 0 and 1, one per walker or shared.
x:
The initial position, one per walker or shared.
size:
The number of walkers, or `None` for one.
space:
The line the walkers live on, whose axis `x` makes `x` their position, or `None`.
Examples:
>>> from skcomplex.systems.mathematics.dynamical_systems import CubicWalkElement
>>> CubicWalkElement('walker', u=0.4).u
0.4
"""
visual = VisualSpec('points', {'position': 'x', 'states': ()})
def __init__(
self,
label: str,
*,
u: object = 0.3,
x: object = 0.0,
size: int | None = None,
space: BaseSpace | None = None,
) -> None:
super().__init__(label, size=size, space=space)
self.u = u
self.x = x
class CubicWalkInteraction(Interaction):
"""Bertin's cubic chaotic map `u' = lam u (u - 1/2)(u - 1) + u` and the step `x' = x + 2 u - 1` it drives.
Args:
label:
The label of the interaction.
target:
The walkers whose values `u` and positions `x` the map moves.
lam:
The nonlinearity of the map.
Examples:
>>> from skcomplex.systems.mathematics.dynamical_systems import CubicWalkInteraction
>>> CubicWalkInteraction('walk', lam=8.0).lam
8.0
"""
law_classes = (UpdateLaw,)
def __init__(self, label: str, *, target: Role = 'walkers', lam: float = 15.0) -> None:
super().__init__(label)
self.target = target
self.lam = lam
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the next value of the map and the next position as the laws.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
u, x = context.target.u, context.target.x
self.laws_: list[BaseLaw] = [
UpdateLaw(u, context.lam * u * (u - 1 / 2) * (u - 1) + u),
UpdateLaw(x, x + 2 * u - 1),
]