Multiplicative
Levy and Solomon's multiplicative process.
- Class:
MultiplicativeProcessSystem - Import:
from skcomplex.systems.economics.finance import MultiplicativeProcessSystem - Field:
economics/finance - Topics:
multiplicative process,power law,agents - References:
- Caiani et al. 2016
- Thurner et al. 2018
- Levy and Solomon 1996
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.economics.finance import MultiplicativeProcessSystem
trajectory = MultiplicativeProcessSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n_firms |
200 |
x |
100.0 |
mu |
1.02 |
sigma |
0.05 |
c |
0.9 |
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 | none |
| Laws | update |
| Randomness | stochastic |
| Domains | real |
| Structure | variable membership |
Class
The source of the class shows how it builds its components from its model parameters.
class MultiplicativeProcessSystem(BaseSystem):
"""Levy and Solomon's multiplicative process.
Its floor at a fraction of the mean makes a power-law tail. Every size is multiplied by a normal growth factor and
then raised to `c` times the mean size of the step before if it fell below it. With `c = 0` the process is Gibrat's.
The system has the group `firms`, the mean size `mean_size`, and the largest size `max_size`.
Args:
n_firms:
The number of firms.
x:
The initial size of every firm.
mu:
The mean of the growth factor.
sigma:
The standard deviation of the growth factor.
c:
The fraction of the previous mean size below which no size falls.
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.economics.finance import MultiplicativeProcessSystem
>>> MultiplicativeProcessSystem(c=0.5).prepare().system_.interactions[-1].c
0.5
"""
field = 'economics/finance'
topics = ('multiplicative process', 'power law', 'agents')
references = ('Caiani et al. 2016', 'Thurner et al. 2018', 'Levy and Solomon 1996')
until = 100
observables = tuple(_get_size_observables())
def __init__(
self,
n_firms: int = 200,
*,
x: float = 100.0,
mu: float = 1.02,
sigma: float = 0.05,
c: float = 0.9,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.n_firms = n_firms
self.x = x
self.mu = mu
self.sigma = sigma
self.c = c
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the components built from the model parameters."""
super()._prepare(context)
firms = GibratFirmElement('firms', x=self.x, previous=self.x, mu=self.mu, sigma=self.sigma, size=self.n_firms)
self.system_ = System(
self.label,
elements=[firms],
interactions=[
GibratGrowthInteraction('growth', target='firms'),
ReflectingFloorInteraction('floor', target='firms', c=self.c),
],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
GibratFirmElement, fromElement
Interactions:
GibratGrowthInteraction, fromInteractionReflectingFloorInteraction, fromInteraction
class GibratFirmElement(Element):
"""Firm whose size is multiplied every step by a normal growth factor.
The factor is independent, `x = lambda x`.
Args:
label:
The label of the agent or group.
x:
The initial size.
previous:
The size before the last step.
mu:
The mean of the growth factor.
sigma:
The standard deviation of the growth factor.
size:
The number of members, or `None` for one.
Examples:
>>> from skcomplex.systems.economics.finance import GibratFirmElement
>>> GibratFirmElement('firms', mu=1.0, size=10).size
10
"""
draws = True
def __init__(
self,
label: str,
*,
x: object = 100.0,
previous: object = 100.0,
mu: object = 1.02,
sigma: Annotated[object, RealSet.closed_open(0, oo)] = 0.05,
size: int | None = None,
) -> None:
super().__init__(label, size=size)
self.x = x
self.previous = previous
self.mu = mu
self.sigma = sigma
class GibratGrowthInteraction(Interaction):
"""Growth of the sizes of firms by independent normal factors, `x = lambda x`.
Every step every firm first keeps its size as `previous`, and then multiplies it by a factor drawn from a normal
distribution of mean `mu` and deviation `sigma`, both values of the firm.
Args:
label:
The label of the interaction.
target:
The firms, with their sizes `x` and `previous` and their `mu` and `sigma`.
Examples:
>>> from skcomplex.systems.economics.finance import GibratGrowthInteraction
>>> GibratGrowthInteraction('growth').target
'firms'
"""
law_classes = (UpdateLaw,)
draws = True
def __init__(self, label: str, *, target: Role = 'firms') -> None:
super().__init__(label)
self.target = target
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the memory of the sizes and their growth as the rules of the system.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
self.laws_: list[BaseLaw] = [UpdateLaw(context, self._remember), UpdateLaw(context, self._grow)]
def _remember(self, system: SystemView) -> None:
"""Keep the size of every firm as its previous size."""
for firm in cast(list[GibratFirmView], system.get_agents('target')):
firm.previous = firm.x
def _grow(self, system: SystemView) -> None:
"""Multiply the size of every firm by a normal growth factor."""
firms = cast(list[GibratFirmView], system.get_agents('target'))
sizes = [firm.x * float(system.rng.normal(firm.mu, firm.sigma)) for firm in firms]
for firm, size in zip(firms, sizes, strict=True):
firm.x = size
class ReflectingFloorInteraction(Interaction):
"""Lower bound on the sizes of a group at a fraction of their mean.
The mean is taken before the step, `x = max(x, c <x_{t-1}>)`. It is a rule of the system that raises every size
below the floor to the floor, the mean of the values `previous` of the group times `c`.
Args:
label:
The label of the interaction.
target:
The path of the group of firms.
c:
The fraction of the previous mean size below which no size falls.
phase:
The phase of the step the floor acts in, or `None` for the default phase.
Examples:
>>> from skcomplex.systems.economics.finance import ReflectingFloorInteraction
>>> ReflectingFloorInteraction('floor', target='firms', c=0.5).c
0.5
"""
law_classes = (UpdateLaw,)
def __init__(
self,
label: str,
*,
target: Role,
c: Annotated[float, RealSet.closed_open(0, oo)] = 0.9,
phase: str | None = None,
) -> None:
super().__init__(label)
self.target = target
self.c = c
self.phase = phase
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the floor of the sizes as the rule of the system, in its phase.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
self.laws_: list[BaseLaw] = [UpdateLaw(context, self._raise, phase=self.phase)]
def _raise(self, system: SystemView) -> None:
"""Raise every size below `c` times the mean size of the group before the step to that floor."""
firms = cast(list[GibratFirmView], system.get_agents('target'))
floor = system.get_parameter('c') * float(np.mean([firm.previous for firm in firms]))
for firm in firms:
firm.x = max(firm.x, floor)
Equations
The equations are those that symbolic returns for the system with its default parameters.