# gillespie { #tvbo.adapters.gillespie }

`adapters.gillespie`

Gillespie SSA backend — a finite-size stochastic realization of a mean-field rate model.

Runs a relaxation-type rate model as a finite birth-death process (Gillespie 1977). The model must have one *activity* state variable ``X`` obeying a relaxation equation ``tau*X' = -X + F(state)`` (a leak ``-X`` toward a gain ``F``); any remaining state variables are treated as slow internal variables that evolve deterministically between events. The activity becomes a discrete count ``n ≈ Omega*X`` where ``Omega`` is the van Kampen system size (``execution.system_size``): the number of discrete units per unit of ``X``. The rate equation is read as

    birth propensity  a+ = Omega * F / tau        (the gain term)
    death propensity  a- = n / tau                (the leak term, since a- = Omega*X/tau)

and the slow variables integrate deterministically over each inter-event interval. Finite ``Omega`` is the sole source of noise; the deterministic mean field is recovered as ``Omega -> infinity``. Applicable to any single-activity Wilson-Cowan / Tsodyks-Markram type rate model — the birth/death split and the between-event ODEs are derived from the model's own equations, so nothing here is model-specific.

Reference: Cortes et al. (2013) PNAS 110(41):16610, SI §2 (Eq. S10/S11) and Fig 5.

## Classes

| Name | Description |
| --- | --- |
| [GillespieAdapter](#tvbo.adapters.gillespie.GillespieAdapter) | Run a mean-field rate `SimulationExperiment` as a finite-N birth-death process. |

### GillespieAdapter { #tvbo.adapters.gillespie.GillespieAdapter }

```python
adapters.gillespie.GillespieAdapter(experiment)
```

Run a mean-field rate `SimulationExperiment` as a finite-N birth-death process.

#### Methods

| Name | Description |
| --- | --- |
| [run](#tvbo.adapters.gillespie.GillespieAdapter.run) | Integrate the experiment with the Gillespie SSA and return the trajectory as an :class:`ExperimentResult`. |

##### run { #tvbo.adapters.gillespie.GillespieAdapter.run }

```python
adapters.gillespie.GillespieAdapter.run(**kwargs)
```

Integrate the experiment with the Gillespie SSA and return the trajectory as an :class:`ExperimentResult`.