make_logistic_map¶
- kooplearn.datasets.make_logistic_map(X0, n_steps=100, r=4.0, M=10, dt=1.0, random_state=None)[source]¶
Generate a trajectory from the logistic map with optional trigonometric noise Ostruszka et al. [1].
The logistic map is a discrete-time dynamical system defined by:
\[x_{t+1} = r x_t (1 - x_t) + \xi_t\]where \(\xi_t\) is drawn from a trigonometric noise distribution when
M > 0.The classic chaotic logistic map uses \(r = 4\). For this system with trigonometric noise, the eigenfunctions of the Koopman operator can be computed analytically using the basis:
\[\phi_i(x) = c_i \sin^{2M-i}(\pi x) \cos^i(\pi x)\]for \(i = 0, 1, \ldots, 2M\).
- Parameters:
X0 (
floatorarray-like,shape (1,)) – Initial condition. Must be in[0, 1]for standard logistic map.n_steps (
int, default100) – Number of time steps to simulate.r (
float, default4.0) – Growth rate parameter. The classic chaotic regime is atr = 4.M (
int, default10) – Order of the trigonometric noise distribution. HigherMmakes the noise distribution more peaked around zero. IfM <= 0, no noise is added.dt (
float, default1.0) – Time step size. For discrete-time systems, this is typically 1.0.random_state (
int,RandomState instanceorNone, defaultNone) – Controls the random number generation for the noise. Pass anintfor reproducible output across multiple function calls.
- Returns:
df – Trajectory of the logistic map with column
['x']andn_steps + 1samples. Has a MultiIndex with levels['step', 'time']. Metadata stored indf.attrsincludes:'generator':'make_logistic_map';'X0': initial condition;'params': dict of all parameters.
- Return type:
pandas.DataFrame
Examples
>>> import numpy as npClassic chaotic logistic map:
>>> df = make_logistic_map(X0=0.1, n_steps=100, r=4.0) >>> df.shape (101, 1) >>> df.columns.tolist() ['x']
With trigonometric noise:
>>> df_noisy = make_logistic_map( ... X0=0.1, ... n_steps=1000, ... r=4.0, ... M=10, ... random_state=42 ... )
Different growth rates:
>>> # Period-2 orbit (r ≈ 3.2) >>> df_period2 = make_logistic_map(X0=0.5, n_steps=100, r=3.2) >>> >>> # Chaotic (r = 4.0) >>> df_chaotic = make_logistic_map(X0=0.5, n_steps=100, r=4.0)
Access metadata:
>>> df.attrs['params']['M'] 10
Notes
The trigonometric noise distribution has PDF:
\[p(\xi) = \frac{\pi}{B(M+0.5, 0.5)} \cos^{2M}(\pi \xi)\]for \(\xi \in [-0.5, 0.5]\), where \(B\) is the beta function.
For the noisy logistic map with \(r = 4\), the Koopman operator has known eigenfunctions that can be computed using the companion function :func:
kooplearn.datasets.compute_logistic_map_eig.
Andrzej Ostruszka, Prot Pakoński, Wojciech Słomczyński, and Karol Życzkowski. Dynamical entropy for systems with stochastic perturbation. Physical Review E, 62(2):2018, 2000.