Skip to content

Stochastic processes

Stochastic process systems.

The package covers random walks, Markov sources, counting, urn, branching, and sample-space-reducing processes.

AgeingRandomWalkSystem(n_walkers=50, *, p=0.5, nu=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Ageing random walks.

The up steps become rarer the more of them a walker has taken.

After k up steps a walker steps up with probability p / (1 + k)^nu, so the walk is history dependent and, for nu > 0, its number of up steps grows as n^(1 / (1 + nu)) after n steps. The system has the group walkers.

Parameters:

Name Type Description Default
n_walkers int

The number of independent walkers, all started at 0.

50
p float

The probability of the first up step.

0.5
nu float

The exponent of the decay of the up probability.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import AgeingRandomWalkSystem
>>> AgeingRandomWalkSystem(5).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
631
632
633
634
635
636
637
638
639
640
641
642
643
644
def __init__(
    self,
    n_walkers: int = 50,
    *,
    p: float = 0.5,
    nu: float = 1.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.p = p
    self.nu = nu

AgeingStepInteraction(label, *, target='walkers', p=0.5, nu=1.0)

Bases: Interaction

Step of an ageing walker, up with the probability p / (1 + k)^nu after k up steps and down otherwise.

Every walker runs the rule once per step.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The walkers whose positions x and numbers ups of up steps the rule sets.

'walkers'
p float

The probability of the first up step.

0.5
nu float

The exponent of the decay of the up probability with the number of up steps.

1.0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import AgeingStepInteraction
>>> AgeingStepInteraction('step', nu=0.5).nu
0.5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
442
443
444
445
446
def __init__(self, label: str, *, target: Role = 'walkers', p: float = 0.5, nu: float = 1.0) -> None:
    super().__init__(label)
    self.target = target
    self.p = p
    self.nu = nu

AgeingWalkerElement(label, *, x=0.0, ups=0.0, size=None)

Bases: Element

Walkers on the integers, each with its position x and its number ups of up steps.

Parameters:

Name Type Description Default
label str

The label of the walkers.

required
x Annotated[object, ZZ]

The initial position, one per walker or shared.

0.0
ups Annotated[object, NN]

The initial number of up steps, one per walker or shared.

0.0
size int | None

The number of walkers, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import AgeingWalkerElement
>>> AgeingWalkerElement('walkers', ups=3.0, size=10).ups
3.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
402
403
404
405
406
407
408
409
410
411
412
def __init__(
    self,
    label: str,
    *,
    x: Annotated[object, ZZ] = 0.0,
    ups: Annotated[object, NN] = 0.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.x = x
    self.ups = ups

BallElement(label, *, level=10.0, size=None)

Bases: Element

Balls of a sample-space-reducing process, each at its state level.

Parameters:

Name Type Description Default
label str

The label of the balls.

required
level Annotated[object, NN]

The initial state, one per ball or shared.

10.0
size int | None

The number of balls, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import BallElement
>>> BallElement('balls', level=10.0, size=3).level
10.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
55
56
57
58
59
60
61
62
63
def __init__(
    self,
    label: str,
    *,
    level: Annotated[object, NN] = 10.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.level = level

BernoulliProcessSystem(n_sequences=20, *, p=0.5, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Independent Bernoulli processes, one success or failure per step.

Their success counts are binomial.

The system has the group trials of states outcome and successes.

Parameters:

Name Type Description Default
n_sequences int

The number of independent sequences of trials.

20
p float

The probability of a success.

0.5
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import BernoulliProcessSystem
>>> BernoulliProcessSystem(3).prepare().system_.elements[0].size
3
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_counting.py
208
209
210
211
212
213
214
215
216
217
218
219
def __init__(
    self,
    n_sequences: int = 20,
    *,
    p: float = 0.5,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_sequences = n_sequences
    self.p = p

BernoulliTrialElement(label, *, outcome=0.0, successes=0.0, size=None)

Bases: Element

Sequences of trials, each with the outcome outcome of its last trial and its number successes of successes.

Parameters:

Name Type Description Default
label str

The label of the sequences.

required
outcome Annotated[object, FiniteEnumeratedSet([0, 1])]

The initial outcome, 1 for a success and 0 for a failure, one per sequence or shared.

0.0
successes Annotated[object, NN]

The initial number of successes, one per sequence or shared.

0.0
size int | None

The number of sequences, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import BernoulliTrialElement
>>> BernoulliTrialElement('trials', successes=2.0, size=4).successes
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_counting.py
116
117
118
119
120
121
122
123
124
125
126
def __init__(
    self,
    label: str,
    *,
    outcome: Annotated[object, FiniteEnumeratedSet([0, 1])] = 0.0,
    successes: Annotated[object, NN] = 0.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.outcome = outcome
    self.successes = successes

BernoulliTrialInteraction(label, *, target='trials', p=0.5)

Bases: Interaction

A Bernoulli trial at every step, a success with the probability p, counted in successes.

Every sequence runs the rule once per step.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The sequences whose outcomes and numbers of successes the rule sets.

'trials'
p float

The probability of a success.

0.5

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import BernoulliTrialInteraction
>>> BernoulliTrialInteraction('trial', p=0.2).p
0.2
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_counting.py
153
154
155
156
def __init__(self, label: str, *, target: Role = 'trials', p: float = 0.5) -> None:
    super().__init__(label)
    self.target = target
    self.p = p

BirthDeathQueueSystem(n_queues=100, *, arrival_rate=0.5, service_rate=1.0, n=0.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Independent M/M/1 queues.

The queues are birth-death processes with constant arrival and service rates.

Customers arrive as a Poisson process of rate lambda and are served one at a time in exponential times of rate mu. For the load rho = lambda / mu < 1 the length of an unbounded queue reaches the stationary geometric distribution (1 - rho) rho^n, of mean rho / (1 - rho) and variance rho / (1 - rho)^2, and for rho > 1 it grows without bound. The system has the lengths queues.n.

Parameters:

Name Type Description Default
n_queues int

The number of independent queues.

100
arrival_rate float

The rate lambda of arrivals.

0.5
service_rate float

The rate mu of departures.

1.0
n float

The initial number of customers of every queue.

0.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import BirthDeathQueueSystem
>>> BirthDeathQueueSystem(5).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_queues.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
def __init__(
    self,
    n_queues: int = 100,
    *,
    arrival_rate: float = 0.5,
    service_rate: float = 1.0,
    n: float = 0.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_queues = n_queues
    self.arrival_rate = arrival_rate
    self.service_rate = service_rate
    self.n = n

BranchingInteraction(label, *, target='population', m=1.0)

Bases: Interaction

Replacement of every individual by a Poisson number of offspring of mean m at every step.

The offspring belong to the next generation and act from the next step on, so every step is one generation.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The individuals that reproduce and die.

'population'
m float

The mean number of offspring of an individual.

1.0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import BranchingInteraction
>>> BranchingInteraction('reproduction', m=1.5).m
1.5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_branching.py
85
86
87
88
def __init__(self, label: str, *, target: Role = 'population', m: float = 1.0) -> None:
    super().__init__(label)
    self.target = target
    self.m = m

BreakingInteraction(label, *, target='fragments', rate=0.5)

Bases: Interaction

Breaking of every fragment larger than 1 with the probability rate at a uniformly random whole point.

The fragment keeps the size left of the cut, and a new fragment takes the rest, so the total size stays the same.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The fragments that break.

'fragments'
rate float

The probability that a fragment larger than 1 breaks in a step.

0.5

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import BreakingInteraction
>>> BreakingInteraction('breaking', rate=0.2).rate
0.2
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
177
178
179
180
def __init__(self, label: str, *, target: Role = 'fragments', rate: float = 0.5) -> None:
    super().__init__(label)
    self.target = target
    self.rate = rate

CascadeInteraction(label, *, target='balls', mu=1.5)

Bases: Interaction

Cascade of balls that multiply by mu as they jump to lower states.

At every step a ball at state 1 leaves the cascade, and any other ball becomes floor(mu) balls, and one more with the probability of the rest, each at a state drawn uniformly below its own.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The balls of the cascade.

'balls'
mu float

The mean number of balls a ball becomes at every jump, the multiplication factor.

1.5

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import CascadeInteraction
>>> CascadeInteraction('cascade', mu=2.0).mu
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
91
92
93
94
def __init__(self, label: str, *, target: Role = 'balls', mu: float = 1.5) -> None:
    super().__init__(label)
    self.target = target
    self.mu = mu

CascadingSampleSpaceReducingSystem(n_cascades=100, *, n_states=100, mu=1.5, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Cascading sample-space-reducing processes.

Their visits follow the power law i^(-mu) for any mu.

Every cascade starts with one ball at the top state n_states. At every step each ball above state 1 jumps to a state drawn uniformly below its own and becomes mu balls there, floor(mu) and one more with the probability of the rest, and a ball at state 1 leaves the cascade. Every ball stays one step, so the states of the balls of all frames are the visits, distributed as i^(-mu) (Thurner et al. 2018, section 3.3.5.4). For mu < 1 balls are lost on the way, 1 - mu being the probability of a removal. With a conservation law that makes the states of the new balls sum to the state of their parent, the exponent is 2 whatever mu, the case of FragmentationSystem. The system has the group balls of state level.

Parameters:

Name Type Description Default
n_cascades int

The number of independent cascades, run together.

100
n_states int

The number of states.

100
mu float

The multiplication factor, the mean number of balls a ball becomes at every jump.

1.5
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import CascadingSampleSpaceReducingSystem
>>> CascadingSampleSpaceReducingSystem(4).prepare().system_.elements[0].size
4
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
421
422
423
424
425
426
427
428
429
430
431
432
433
434
def __init__(
    self,
    n_cascades: int = 100,
    *,
    n_states: int = 100,
    mu: float = 1.5,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_cascades = n_cascades
    self.n_states = n_states
    self.mu = mu

ExponentialGrowthAtRandomTimesSystem(n_samples=2000, *, mu=1.0, lam=1.5, x0=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Exponential growth observed at exponentially distributed times.

The observed values follow a power law.

Every sample grows as x0 exp(mu t) and is observed and restarted after a waiting time drawn from the exponential distribution of rate lam. The observed values, and the values of the samples at any later time, follow the power law p(x) ~ x^(-lam / mu - 1) (Thurner et al. 2018, section 3.3.6.1, after Reed and Hughes 2002). The system has the group samples of state x and the observations samples.observations.

Parameters:

Name Type Description Default
n_samples int

The number of independent samples.

2000
mu float

The growth rate.

1.0
lam float

The rate of the observation times.

1.5
x0 float

The value every growth starts from.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import ExponentialGrowthAtRandomTimesSystem
>>> ExponentialGrowthAtRandomTimesSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_power_laws.py
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
def __init__(
    self,
    n_samples: int = 2000,
    *,
    mu: float = 1.0,
    lam: float = 1.5,
    x0: float = 1.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_samples = n_samples
    self.mu = mu
    self.lam = lam
    self.x0 = x0

FragmentElement(label, *, length=1000.0, size=None)

Bases: Element

Fragments of integer sizes, each with its size length.

Parameters:

Name Type Description Default
label str

The label of the fragments.

required
length Annotated[object, open(0, oo)]

The initial size, one per fragment or shared.

1000.0
size int | None

The number of fragments, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import FragmentElement
>>> FragmentElement('fragments', length=100.0).length
100.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
142
143
144
145
146
147
148
149
150
def __init__(
    self,
    label: str,
    *,
    length: Annotated[object, RealSet.open(0, oo)] = 1000.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.length = length

FragmentationSystem(size=1000, *, rate=0.5, label='system', solver='auto', backend='auto')

Bases: BaseSystem

The random fragmentation of an object of integer size.

The fragments keep breaking into smaller ones.

The total size is conserved, and every fragment ends at size 1. The system has the group fragments of state length.

Parameters:

Name Type Description Default
size int

The size of the initial object.

1000
rate float

The probability that a fragment larger than 1 breaks in a step.

0.5
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import FragmentationSystem
>>> FragmentationSystem(50).prepare().system_.elements[0].size
1
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
355
356
357
358
359
360
361
362
363
364
365
366
def __init__(
    self,
    size: int = 1000,
    *,
    rate: float = 0.5,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.size = size
    self.rate = rate

GaltonWatsonSystem(n_individuals=10, *, m=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A Galton-Watson branching process with Poisson offspring.

Every step is one generation.

The mean size of generation n is n_individuals m^n. The process dies out with certainty for m <= 1, and survives with a positive probability for m > 1. The system has the group population, whose count is the size of the current generation.

Parameters:

Name Type Description Default
n_individuals int

The size of the first generation.

10
m float

The mean number of offspring of an individual.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import GaltonWatsonSystem
>>> GaltonWatsonSystem(5, m=1.2).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_branching.py
143
144
145
146
147
148
149
150
151
152
153
154
def __init__(
    self,
    n_individuals: int = 10,
    *,
    m: float = 1.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_individuals = n_individuals
    self.m = m

HiddenMarkovSourceElement(label, *, hidden=0, symbol=0)

Bases: Element

Source of symbols emitted from the states of a hidden Markov chain.

Parameters:

Name Type Description Default
label str

The label of the source.

required
hidden Annotated[float, NN]

The initial hidden state.

0
symbol Annotated[float, NN]

The initial symbol.

0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import HiddenMarkovSourceElement
>>> HiddenMarkovSourceElement('source', hidden=1).hidden
1
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_sources.py
46
47
48
49
def __init__(self, label: str, *, hidden: Annotated[float, NN] = 0, symbol: Annotated[float, NN] = 0) -> None:
    super().__init__(label)
    self.hidden = hidden
    self.symbol = symbol

HiddenMarkovSourceSystem(transition=CHAIN, emission=EMISSION, *, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A hidden Markov source.

Its symbols are emitted at random from the states of a hidden Markov chain.

The hidden state follows the transition matrix P, and in hidden state i the source emits symbol j with probability E_ij. The frequency of symbol j is Σ_i π_i E_ij for the stationary distribution π of the hidden chain, and the symbols alone are not a Markov chain of any finite order in general. The system has the hidden states source.hidden and the symbols source.symbol.

Parameters:

Name Type Description Default
transition Matrix

The transition matrix P of the hidden chain.

CHAIN
emission Matrix

The emission matrix E, one row per hidden state and one column per symbol.

EMISSION
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import HiddenMarkovSourceSystem
>>> HiddenMarkovSourceSystem().prepare().states_
('source.hidden', 'source.symbol')
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_sources.py
248
249
250
251
252
253
254
255
256
257
258
259
def __init__(
    self,
    transition: Matrix = CHAIN,
    emission: Matrix = EMISSION,
    *,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.transition = transition
    self.emission = emission

IndividualElement(label, *, generation=0.0, size=None)

Bases: Element

Individuals of a branching process, each with its generation generation.

Parameters:

Name Type Description Default
label str

The label of the individuals.

required
generation Annotated[object, NN]

The initial generation, one per individual or shared.

0.0
size int | None

The number of individuals, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import IndividualElement
>>> IndividualElement('population', size=10).size
10
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_branching.py
50
51
52
53
54
55
56
57
58
def __init__(
    self,
    label: str,
    *,
    generation: Annotated[object, NN] = 0.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.generation = generation

IntermittencyInteraction(label, *, target='variables', epsilon=0.0, D=0.5)

Bases: Interaction

The drive of a positive variable across the bifurcation at epsilon = 0 by a multiplicative noise.

The variable follows dx = (epsilon x - x³) dt + sqrt(2 D) x dW in the Stratonovich convention.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The variables the drive moves.

'variables'
epsilon float

The control parameter, the distance from the bifurcation.

0.0
D float

The noise intensity, positive.

0.5

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import IntermittencyInteraction
>>> IntermittencyInteraction('drift', target='variables', D=0.2).D
0.2
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_intermittency.py
82
83
84
85
86
def __init__(self, label: str, *, target: Role = 'variables', epsilon: float = 0.0, D: float = 0.5) -> None:
    super().__init__(label)
    self.target = target
    self.epsilon = epsilon
    self.D = D

IntermittentVariableElement(label, *, x=1.0, size=None)

Bases: Element

Positive variables x, one per realization.

Parameters:

Name Type Description Default
label str

The label of the variables.

required
x Annotated[float, open(0, oo)]

The initial value, positive, one per realization or shared.

1.0
size int | None

The number of realizations, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import IntermittentVariableElement
>>> IntermittentVariableElement('variable', x=0.2).x
0.2
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_intermittency.py
45
46
47
48
49
50
51
52
53
def __init__(
    self,
    label: str,
    *,
    x: Annotated[float, RealSet.open(0, oo)] = 1.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.x = x

MarkovChainInteraction(label, *, target='source', transition=CHAIN, emission=None, state='symbol', observed='symbol')

Bases: Interaction

A Markov chain that draws the next value of a discrete state from the row of a transition matrix.

The value after i is j with probability P_ij. With an emission matrix E, a second state, the symbol, is drawn in the same step from the row of E that the new value selects, as a hidden Markov chain emits its symbols.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The element that holds the state and, with an emission matrix, the symbol.

'source'
transition Matrix

The transition matrix P, one row and one column per value, with rows that sum to 1.

CHAIN
emission Matrix | None

The emission matrix E, one row per value of the state and one column per symbol, or None for none.

None
state str

The name of the state the chain moves.

'symbol'
observed str

The name of the symbol the emissions draw.

'symbol'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import MarkovChainInteraction
>>> MarkovChainInteraction('chain', target='source', transition=((0.5, 0.5), (0.1, 0.9))).state
'symbol'
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_sources.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
def __init__(
    self,
    label: str,
    *,
    target: Role = 'source',
    transition: Matrix = CHAIN,
    emission: Matrix | None = None,
    state: str = 'symbol',
    observed: str = 'symbol',
) -> None:
    super().__init__(label)
    self.target = target
    self.transition = transition
    self.emission = emission
    self.state = state
    self.observed = observed

MarkovSourceElement(label, *, symbol=0)

Bases: Element

Source of symbols 0 to n - 1.

Parameters:

Name Type Description Default
label str

The label of the source.

required
symbol Annotated[float, NN]

The initial symbol.

0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import MarkovSourceElement
>>> MarkovSourceElement('source', symbol=1).symbol
1
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_sources.py
68
69
70
def __init__(self, label: str, *, symbol: Annotated[float, NN] = 0) -> None:
    super().__init__(label)
    self.symbol = symbol

MarkovSourceSystem(transition=CHAIN, *, symbol=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A Markov source.

Each symbol of the sequence depends on the one before it.

The symbol after i is j with probability P_ij. The entropy rate of the source is h = -Σ_i π_i Σ_j P_ij log2 P_ij bits per symbol, where π is the stationary distribution of the chain, and the block entropies of the sequence approach it from above. The system has the symbols source.symbol.

Parameters:

Name Type Description Default
transition Matrix

The transition matrix P, one row and one column per symbol, with rows that sum to 1.

CHAIN
symbol int

The initial symbol.

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import MarkovSourceSystem
>>> MarkovSourceSystem().prepare().simulate(5, random_state=0).get_values('source.symbol').tolist()
[0.0, 1.0, 0.0, 0.0, 0.0, 0.0]
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_sources.py
187
188
189
190
191
192
193
194
195
196
197
198
def __init__(
    self,
    transition: Matrix = CHAIN,
    *,
    symbol: int = 0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.transition = transition
    self.symbol = symbol

MemoryStepInteraction(label, *, target='walkers', alpha=0.5, sigma=1.0)

Bases: Interaction

Step of a walk whose velocity is an autoregressive process, x <- x + v and v <- alpha v + xi.

The noise xi is normal with mean 0 and deviation sigma, drawn anew at every step for every walker.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The walkers whose positions x and velocities v the step sets.

'walkers'
alpha float

The memory of the velocity.

0.5
sigma float

The deviation of the noise of the velocity.

1.0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import MemoryStepInteraction
>>> MemoryStepInteraction('step', alpha=0.3).alpha
0.3
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
95
96
97
98
99
def __init__(self, label: str, *, target: Role = 'walkers', alpha: float = 0.5, sigma: float = 1.0) -> None:
    super().__init__(label)
    self.target = target
    self.alpha = alpha
    self.sigma = sigma

MemoryWalkerElement(label, *, x=0.0, v=0.0, size=None, space=None)

Bases: Element

Walkers on the real line, each with its position x and its velocity v.

Parameters:

Name Type Description Default
label str

The label of the walkers.

required
x object

The initial position, one per walker or shared.

0.0
v object

The initial velocity, one per walker or shared.

0.0
size int | None

The number of walkers, or None for one.

None
space BaseSpace | None

The line the walkers live on, whose axis x makes x their position, or None.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import MemoryWalkerElement
>>> MemoryWalkerElement('walker', v=0.3).v
0.3
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
54
55
56
57
58
59
60
61
62
63
64
65
def __init__(
    self,
    label: str,
    *,
    x: object = 0.0,
    v: object = 0.0,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, size=size, space=space)
    self.x = x
    self.v = v

ObservedGrowthElement(label, *, x=1.0, size=None)

Bases: Element

Quantities x that grow, one per sample.

Parameters:

Name Type Description Default
label str

The label of the samples.

required
x Annotated[float, open(0, oo)]

The initial value, positive, one per sample or shared.

1.0
size int | None

The number of samples, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import ObservedGrowthElement
>>> ObservedGrowthElement('growth', x=2.0).x
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_power_laws.py
46
47
48
def __init__(self, label: str, *, x: Annotated[float, RealSet.open(0, oo)] = 1.0, size: int | None = None) -> None:
    super().__init__(label, size=size)
    self.x = x

ObservedGrowthInteraction(label, *, target='samples', x0=1.0, mu=1.0, lam=1.5)

Bases: Interaction

The exponential growth of a quantity that is observed and restarted at exponentially distributed times.

The quantity follows x' = mu x from x0, and after a waiting time drawn from the exponential distribution of rate lam it is observed and starts again from x0.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The samples that grow.

'samples'
x0 float

The value every growth starts from.

1.0
mu float

The growth rate.

1.0
lam float

The rate of the observation times.

1.5

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import ObservedGrowthInteraction
>>> ObservedGrowthInteraction('growth', target='samples', lam=2.0).lam
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_power_laws.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def __init__(
    self,
    label: str,
    *,
    target: Role = 'samples',
    x0: float = 1.0,
    mu: float = 1.0,
    lam: float = 1.5,
) -> None:
    super().__init__(label)
    self.target = target
    self.x0 = x0
    self.mu = mu
    self.lam = lam

OnOffIntermittencySystem(n_realizations=20, *, epsilon=0.0, D=0.5, x=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Stochastic on-off intermittency, dx/dt = (epsilon + xi) x - x^3.

The noise xi is Stratonovich white noise.

The noise has the correlation <xi(t) xi(t')> = 2 D delta(t - t'). The variable y = ln x diffuses freely while x is small and is pushed back by -exp(2 y) once x grows, so near the bifurcation epsilon = 0 the variable rests close to 0 for long laminar phases, whose durations are distributed as tau^(-3/2), between bursts where x is of order 1. For epsilon > 0 the power law is cut off beyond durations of order D / epsilon^2. The system has the values variables.x.

Parameters:

Name Type Description Default
n_realizations int

The number of independent realizations.

20
epsilon float

The control parameter, the distance from the bifurcation.

0.0
D float

The noise intensity.

0.5
x float

The initial value of every realization.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import OnOffIntermittencySystem
>>> OnOffIntermittencySystem(5).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_intermittency.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
def __init__(
    self,
    n_realizations: int = 20,
    *,
    epsilon: float = 0.0,
    D: float = 0.5,
    x: float = 1.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_realizations = n_realizations
    self.epsilon = epsilon
    self.D = D
    self.x = x

PersistentRandomWalkSystem(n_walkers=2000, *, persistence=0.8, random_state=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Walkers on the integers that keep the direction of their last step.

A walker keeps the direction with a probability.

At every step a walker moves by its direction d = ±1, and keeps the direction with probability q and reverses it otherwise. Successive steps are correlated with rho = 2 q - 1, so the walk diffuses faster than a simple random walk for q > 1/2, with a mean squared displacement that grows as t (1 + rho) / (1 - rho) at long times. The system has the directions walkers.d and the positions walkers.x.

Parameters:

Name Type Description Default
n_walkers int

The number of independent walkers, all started at 0.

2000
persistence float

The probability q of keeping the direction.

0.8
random_state int | Generator | None

The seed or generator of the initial directions.

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PersistentRandomWalkSystem
>>> PersistentRandomWalkSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
695
696
697
698
699
700
701
702
703
704
705
706
707
708
def __init__(
    self,
    n_walkers: int = 2000,
    *,
    persistence: float = 0.8,
    random_state: int | np.random.Generator | None = 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.persistence = persistence
    self.random_state = random_state

PersistentStepInteraction(label, *, target='walkers', persistence=0.8)

Bases: Interaction

Step of a persistent walk, x <- x + d, whose direction d reverses with the probability 1 - persistence.

The reversal is drawn anew at every step for every walker.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The walkers whose directions d and positions x the step sets.

'walkers'
persistence float

The probability of keeping the direction at a step.

0.8

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PersistentStepInteraction
>>> PersistentStepInteraction('step', persistence=0.9).persistence
0.9
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
179
180
181
182
def __init__(self, label: str, *, target: Role = 'walkers', persistence: float = 0.8) -> None:
    super().__init__(label)
    self.target = target
    self.persistence = persistence

PersistentWalkerElement(label, *, d=1.0, x=0.0, size=None, space=None)

Bases: Element

Walkers on the integers, each with its direction d = ±1 and its position x.

Parameters:

Name Type Description Default
label str

The label of the walkers.

required
d Annotated[object, ZZ]

The initial direction, 1 or -1, one per walker or shared.

1.0
x Annotated[object, ZZ]

The initial position, one per walker or shared.

0.0
size int | None

The number of walkers, or None for one.

None
space BaseSpace | None

The line the walkers live on, whose axis x makes x their position, or None.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PersistentWalkerElement
>>> PersistentWalkerElement('walker', d=-1.0).d
-1.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
141
142
143
144
145
146
147
148
149
150
151
152
def __init__(
    self,
    label: str,
    *,
    d: Annotated[object, ZZ] = 1.0,
    x: Annotated[object, ZZ] = 0.0,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, size=size, space=space)
    self.d = d
    self.x = x

PoissonCounterElement(label, *, count=0.0, size=None)

Bases: Element

Counters of the events of Poisson processes, one count per process.

Parameters:

Name Type Description Default
label str

The label of the counters.

required
count Annotated[float, NN]

The initial number of events, one per counter or shared.

0.0
size int | None

The number of counters, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PoissonCounterElement
>>> PoissonCounterElement('counter', count=2.0).count
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_counting.py
43
44
45
def __init__(self, label: str, *, count: Annotated[float, NN] = 0.0, size: int | None = None) -> None:
    super().__init__(label, size=size)
    self.count = count

PoissonEventsInteraction(label, *, target='counters', rate=1.0)

Bases: Interaction

The events of a Poisson process, which add one to a count at the rate rate.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The counters whose counts the events add to.

'counters'
rate float

The rate of the events.

1.0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PoissonEventsInteraction
>>> PoissonEventsInteraction('events', target='counters', rate=2.0).rate
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_counting.py
69
70
71
72
def __init__(self, label: str, *, target: Role = 'counters', rate: float = 1.0) -> None:
    super().__init__(label)
    self.target = target
    self.rate = rate

PoissonProcessSystem(n_processes=20, *, rate=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Independent Poisson processes.

The counters grow by one at exponentially distributed waiting times.

The system has the counts counters.count.

Parameters:

Name Type Description Default
n_processes int

The number of independent counters.

20
rate float

The rate of events of a counter.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PoissonProcessSystem
>>> PoissonProcessSystem(5).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_counting.py
266
267
268
269
270
271
272
273
274
275
276
277
def __init__(
    self,
    n_processes: int = 20,
    *,
    rate: float = 1.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_processes = n_processes
    self.rate = rate

PolyaDrawInteraction(label, *, target='urns', added=1)

Bases: Interaction

The draws of Pólya's urn, where a drawn ball returns with added extra balls of its color.

The draws happen at rate 1, and a draw picks a color with probability proportional to its number of balls, so the sequence of draws is that of Pólya's urn in discrete time.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The urns whose balls the draws add to.

'urns'
added int

The number of balls of the drawn color added after every draw.

1

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PolyaDrawInteraction
>>> PolyaDrawInteraction('draws', target='urns', added=2).added
2
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_urns.py
81
82
83
84
def __init__(self, label: str, *, target: Role = 'urns', added: int = 1) -> None:
    super().__init__(label)
    self.target = target
    self.added = added

PolyaUrnElement(label, *, red=1.0, blue=1.0, size=None)

Bases: Element

Urns of red and blue balls, counted by color.

Parameters:

Name Type Description Default
label str

The label of the urns.

required
red Annotated[float, NN]

The initial number of red balls, one per urn or shared.

1.0
blue Annotated[float, NN]

The initial number of blue balls, one per urn or shared.

1.0
size int | None

The number of urns, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PolyaUrnElement
>>> PolyaUrnElement('urn', red=2.0).red
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_urns.py
44
45
46
47
48
49
50
51
52
53
54
def __init__(
    self,
    label: str,
    *,
    red: Annotated[float, NN] = 1.0,
    blue: Annotated[float, NN] = 1.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.red = red
    self.blue = blue

PolyaUrnSystem(n_urns=10, *, red=1, blue=1, added=1, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Independent Pólya urns.

The share of red balls converges to a random limit with a beta distribution.

The limit follows Beta(red / added, blue / added), uniform for one ball of each color and one added ball. The system has the states urns.red and urns.blue.

Parameters:

Name Type Description Default
n_urns int

The number of independent urns.

10
red int

The initial number of red balls.

1
blue int

The initial number of blue balls.

1
added int

The number of balls of the drawn color added after every draw.

1
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import PolyaUrnSystem
>>> PolyaUrnSystem(3).prepare().system_.elements[0].size
3
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_urns.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
def __init__(
    self,
    n_urns: int = 10,
    *,
    red: int = 1,
    blue: int = 1,
    added: int = 1,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_urns = n_urns
    self.red = red
    self.blue = blue
    self.added = added

QueueElement(label, *, n=0.0, size=None)

Bases: Element

Queues at desks, each holding the number n of customers waiting.

Parameters:

Name Type Description Default
label str

The label of the queues.

required
n Annotated[float, NN]

The initial number of customers, one per queue or shared.

0.0
size int | None

The number of queues, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import QueueElement
>>> QueueElement('desk', n=3.0).n
3.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_queues.py
45
46
47
def __init__(self, label: str, *, n: Annotated[float, NN] = 0.0, size: int | None = None) -> None:
    super().__init__(label, size=size)
    self.n = n

RandomBranchMapElement(label, *, x=0.5, size=None)

Bases: Element

Values x of a random interval map, one per orbit.

Parameters:

Name Type Description Default
label str

The label of the orbits.

required
x Annotated[object, closed(0, 1)]

The initial value, between 0 and 1, one per orbit or shared.

0.5
size int | None

The number of orbits, or None for one.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import RandomBranchMapElement
>>> RandomBranchMapElement('map', x=0.3).x
0.3
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_random_maps.py
43
44
45
46
47
48
49
50
51
def __init__(
    self,
    label: str,
    *,
    x: Annotated[object, RealSet.closed(0, 1)] = 0.5,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.x = x

RandomBranchMapInteraction(label, *, target='orbits', p1=0.5, mu=1.0)

Bases: Interaction

The random map that applies (1 + x) / 2 with probability p1 and mu x² otherwise.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The orbits whose values the map moves.

'orbits'
p1 float

The probability of the branch (1 + x) / 2.

0.5
mu float

The coefficient of the branch mu x², between 0 and 1.

1.0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import RandomBranchMapInteraction
>>> RandomBranchMapInteraction('map', target='orbits', p1=0.3).p1
0.3
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_random_maps.py
80
81
82
83
84
def __init__(self, label: str, *, target: Role = 'orbits', p1: float = 0.5, mu: float = 1.0) -> None:
    super().__init__(label)
    self.target = target
    self.p1 = p1
    self.mu = mu

RandomBranchMapSystem(n_orbits=200, *, p1=0.5, mu=1.0, random_state=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Orbits of a random map of [0, 1].

The map has the two branches (1 + x) / 2 and mu x².

At every step each orbit applies (1 + x) / 2 with probability p1 and mu x² otherwise (Dilão 2023, Exercise 5.10). The first branch pulls towards 1 and the second towards 0, so the orbits settle on a stationary distribution whose shape changes with p1 and mu. For mu = 0 the second branch resets the orbit to 0, and the stationary mean is p1 / (2 - p1). For mu = 1 both branches fix x = 1, which attracts the orbits once p1 > 1/2, since there the first branch halves the distance to 1 and the second doubles it.

The system has the group orbits of state x.

Parameters:

Name Type Description Default
n_orbits int

The number of independent orbits.

200
p1 float

The probability of the branch (1 + x) / 2.

0.5
mu float

The coefficient of the branch mu x², between 0 and 1.

1.0
random_state int | Generator | None

The seed or generator of the initial values, uniform on [0, 1].

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import RandomBranchMapSystem
>>> RandomBranchMapSystem(10, p1=0.3).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_random_maps.py
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
def __init__(
    self,
    n_orbits: int = 200,
    *,
    p1: float = 0.5,
    mu: float = 1.0,
    random_state: int | np.random.Generator | None = 0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_orbits = n_orbits
    self.p1 = p1
    self.mu = mu
    self.random_state = random_state

RandomStepInteraction(label, *, target='walkers', rate=1.0, bias=0.5)

Bases: Interaction

Steps of a walker on the integers at the rate rate, each up with the probability bias.

The walker steps up at the rate rate * bias and down at the rate rate * (1 - bias).

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The walkers whose positions x the steps change.

'walkers'
rate float

The rate of steps.

1.0
bias float

The probability that a step goes up.

0.5

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import RandomStepInteraction
>>> RandomStepInteraction('steps', bias=0.7).bias
0.7
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
259
260
261
262
263
def __init__(self, label: str, *, target: Role = 'walkers', rate: float = 1.0, bias: float = 0.5) -> None:
    super().__init__(label)
    self.target = target
    self.rate = rate
    self.bias = bias

RandomWalkSystem(n_walkers=100, *, rate=1.0, bias=0.5, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Independent walkers on the integers that step at random times.

This is a continuous-time random walk.

Every walker steps up at rate rate * bias and down at rate rate * (1 - bias), so its mean moves with velocity rate (2 bias - 1) and its variance grows as 4 rate bias (1 - bias) t. The system has the positions walkers.x.

Parameters:

Name Type Description Default
n_walkers int

The number of walkers.

100
rate float

The rate of steps of a walker.

1.0
bias float

The probability that a step goes up.

0.5
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import RandomWalkSystem
>>> RandomWalkSystem(20).prepare().system_.elements[0].size
20
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
504
505
506
507
508
509
510
511
512
513
514
515
516
517
def __init__(
    self,
    n_walkers: int = 100,
    *,
    rate: float = 1.0,
    bias: float = 0.5,
    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.rate = rate
    self.bias = bias

RandomWalkWithMemorySystem(n_walkers=2000, *, alpha=0.5, sigma=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Random walks whose velocity is an autoregressive process.

The walks follow x ← x + v and v ← alpha v + xi.

The noise xi is normal with mean 0 and deviation sigma, and the walks start from x = v = 0. The pair (x, v) is Markovian while the displacements are correlated, so the mean squared displacement grows as sigma² t / (1 - alpha)² at long times instead of sigma² t / (1 - alpha²) for uncorrelated steps of the same variance. The system has the positions walkers.x and the velocities walkers.v.

Parameters:

Name Type Description Default
n_walkers int

The number of independent walkers.

2000
alpha float

The memory alpha of the velocity, between 0 and 1.

0.5
sigma float

The deviation sigma of the noise.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import RandomWalkWithMemorySystem
>>> RandomWalkWithMemorySystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
760
761
762
763
764
765
766
767
768
769
770
771
772
773
def __init__(
    self,
    n_walkers: int = 2000,
    *,
    alpha: float = 0.5,
    sigma: float = 1.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.alpha = alpha
    self.sigma = sigma

RandomWalkerElement(label, *, x=0.0, size=None, space=None)

Bases: Element

Walkers on the integers, each with its position x.

Parameters:

Name Type Description Default
label str

The label of the walkers.

required
x Annotated[object, ZZ]

The initial position, one per walker or shared.

0.0
size int | None

The number of walkers, or None for one.

None
space BaseSpace | None

The line the walkers live on, whose axis x makes x their position, or None.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import RandomWalkerElement
>>> RandomWalkerElement('walker', x=2.0).x
2.0
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
221
222
223
224
225
226
227
228
229
230
def __init__(
    self,
    label: str,
    *,
    x: Annotated[object, ZZ] = 0.0,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, size=size, space=space)
    self.x = x

ReducingJumpInteraction(label, *, target='balls', n_states=10, lam=1.0)

Bases: Interaction

Jump of a ball of the sample-space-reducing process to a lower state, to any state, or back to the top state.

A ball at state 1 restarts from the top state n_states. Otherwise it jumps with probability lam uniformly to a state below its own, and else uniformly to any state, so the states are visited with probabilities proportional to i^(-lam).

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The balls that jump.

'balls'
n_states int

The number of states.

10
lam float

The probability of a reducing jump.

1.0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import ReducingJumpInteraction
>>> ReducingJumpInteraction('jump', n_states=20).n_states
20
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
230
231
232
233
234
def __init__(self, label: str, *, target: Role = 'balls', n_states: int = 10, lam: float = 1.0) -> None:
    super().__init__(label)
    self.target = target
    self.n_states = n_states
    self.lam = lam

SampleSpaceReducingSystem(n_balls=20, *, n_states=10, lam=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Sample-space-reducing processes.

Their state visits follow Zipf's law 1 / i for lam = 1.

The system has the group balls of state level.

Parameters:

Name Type Description Default
n_balls int

The number of independent balls, all started at the top state.

20
n_states int

The number of states.

10
lam float

The probability of a reducing jump, the exponent of the visiting distribution.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import SampleSpaceReducingSystem
>>> SampleSpaceReducingSystem(4).prepare().system_.elements[0].size
4
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_reducing.py
294
295
296
297
298
299
300
301
302
303
304
305
306
307
def __init__(
    self,
    n_balls: int = 20,
    *,
    n_states: int = 10,
    lam: float = 1.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_balls = n_balls
    self.n_states = n_states
    self.lam = lam

ServiceInteraction(label, *, target='queues', arrival_rate=0.5, service_rate=1.0)

Bases: Interaction

The arrivals and departures of an M/M/1 queue.

Customers arrive at rate arrival_rate and leave at rate service_rate while the queue is not empty.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The queues whose customers arrive and leave.

'queues'
arrival_rate float

The rate of arrivals.

0.5
service_rate float

The rate of departures from a queue that is not empty.

1.0

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import ServiceInteraction
>>> ServiceInteraction('service', target='queues', arrival_rate=0.8).arrival_rate
0.8
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_queues.py
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    label: str,
    *,
    target: Role = 'queues',
    arrival_rate: float = 0.5,
    service_rate: float = 1.0,
) -> None:
    super().__init__(label)
    self.target = target
    self.arrival_rate = arrival_rate
    self.service_rate = service_rate

WeakeningForceInteraction(label, *, target='particles', k=1.0, ell=1.0, D=0.25)

Bases: Interaction

Brownian motion in a restoring force that weakens with distance, dx = -k x / (1 + x²/ℓ²) dt + √(2D) dW.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The particles whose positions x the force and the noise move.

'particles'
k float

The stiffness of the force near the origin.

1.0
ell float

The distance where the force starts to weaken.

1.0
D float

The diffusion coefficient.

0.25

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import WeakeningForceInteraction
>>> WeakeningForceInteraction('force', D=0.5).D
0.5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
341
342
343
344
345
346
347
348
349
350
351
352
353
354
def __init__(
    self,
    label: str,
    *,
    target: Role = 'particles',
    k: float = 1.0,
    ell: float = 1.0,
    D: float = 0.25,
) -> None:
    super().__init__(label)
    self.target = target
    self.k = k
    self.ell = ell
    self.D = D

WeakeningOrnsteinUhlenbeckSystem(n_particles=200, *, k=1.0, ell=1.0, D=0.25, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Brownian particles held by a restoring force that weakens with distance.

The particles follow dx = -k x / (1 + x²/ℓ²) dt + √(2D) dW. Near the origin the force is that of an Ornstein-Uhlenbeck process, and far from it the force decays as 1 / x, so the stationary density (1 + x²/ℓ²)^(-k ℓ² / 2D) has power-law tails. The system has the positions particles.x.

Parameters:

Name Type Description Default
n_particles int

The number of independent particles, all started at the origin.

200
k float

The stiffness of the force near the origin.

1.0
ell float

The distance where the force starts to weaken.

1.0
D float

The diffusion coefficient.

0.25
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import WeakeningOrnsteinUhlenbeckSystem
>>> WeakeningOrnsteinUhlenbeckSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
def __init__(
    self,
    n_particles: int = 200,
    *,
    k: float = 1.0,
    ell: float = 1.0,
    D: float = 0.25,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_particles = n_particles
    self.k = k
    self.ell = ell
    self.D = D

WeakeningParticleElement(label, *, x=0.0, size=None, space=None)

Bases: Element

Particles on the real line, each with its position x.

Parameters:

Name Type Description Default
label str

The label of the particles.

required
x object

The initial position, one per particle or shared.

0.0
size int | None

The number of particles, or None for one.

None
space BaseSpace | None

The line the particles live on, whose axis x makes x their position, or None.

None

Examples:

>>> from skcomplex.systems.mathematics.stochastic_processes import WeakeningParticleElement
>>> WeakeningParticleElement('particle', x=0.5).x
0.5
Source code in src/skcomplex/systems/mathematics/stochastic_processes/_walks.py
302
303
304
305
306
307
308
309
310
311
def __init__(
    self,
    label: str,
    *,
    x: object = 0.0,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, size=size, space=space)
    self.x = x