Skip to content

Commit

Permalink
Added stochasticity to coupled map lattice
Browse files Browse the repository at this point in the history
  • Loading branch information
djpasseyjr committed Jan 26, 2024
1 parent ee0ae52 commit 6057ae8
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 58 deletions.
2 changes: 1 addition & 1 deletion interfere/dynamics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from .base import OrdinaryDifferentialEquation, StochasticDifferentialEquation
from .coupled_map_lattice import (
coupled_logistic_map,
CoupledMapLattice,
StochasticCoupledMapLattice,
coupled_map_1dlattice_chaotic_brownian,
coupled_map_1dlattice_chaotic_traveling_wave,
coupled_map_1dlattice_defect_turbulence,
Expand Down
7 changes: 4 additions & 3 deletions interfere/dynamics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def simulate(
initial_condition: np.ndarray,
time_points: np.ndarray,
intervention: Optional[Callable[[np.ndarray, float], np.ndarray]]= None,
# TODO: Change measurement noise so it is a data member.
rng: np.random.mtrand.RandomState = DEFAULT_RANGE,
dW: Optional[np.ndarray] = None,
) -> np.ndarray:
Expand Down Expand Up @@ -282,7 +281,7 @@ def simulate(
X_do[i] = intervention(X_do[i], time_points[i])

# Compute next state
X_do[i+1] = self.step(X_do[i])
X_do[i+1] = self.step(X_do[i], rng)

# After the loop, apply interention to the last step
if intervention is not None:
Expand All @@ -291,11 +290,13 @@ def simulate(
return X_do

@abstractmethod
def step(self, x: np.ndarray):
def step(self, x: np.ndarray, rng: np.random.mtrand.RandomState):
"""Uses the current state to compute the next state of the system.
Args:
x (np.ndarray): The current state of the system.
rng (RandomState): A numpy random state for generating random
numbers.
Returns:
x_next (np.ndarray): The next state of the system.
Expand Down
Loading

0 comments on commit 6057ae8

Please sign in to comment.