Champagnat Ferriere Méléard algorithm described in [Champagnat and Ferriere founding article](https://linkinghub.elsevier.com/retrieve/pii/S0040580905001632). This algorithm similar to Gillepsie algorithms, excepts that it runs much faster!

Indeed, at every time step, only the fitness of the individual picked at random is evaluated. Thus this algorithm is of order ``K`` times more efficient.

In order to use it, you need to feed to the dictionary parameters `p` a constant `Cbar<:Real` that is the upperbound of the maximum of the sum of the birth and death rates (cf article).

[**A general method for numerically simulating the stochastic time evolution of coupled chemical reactions**](https://www.sciencedirect.com/science/article/pii/0021999176900413?via%3Dihub)

### Update Rates

`` b_i `` and `` d_i `` represent respcetively birth and death rates of agents ``i``. The total rate is given by the sum of all individual rates

```math

R(t) = \left[ \sum_i b_i(t) + d_i(t) \right]

```

A particular event, birth or death, is chosen at random with a probability equal to the rate of this event divided by the total rate ``R``.

The Wright Fisher process is an individual based model where the number of agents is constant through time. It is helpful to visualize it through marbles in jar:

At each time step, ``N`` agents are picked up from previous generation to reproduce. Their number of offspring is proportional to their fitness, calculated as usual with **birth and death rates**.

It takes thus **only one time step to go trough one generation**. Thus it is more suit- able for numerical simulations. In practice, the Moran and Wright–Fisher models give qualitatively similar results, but genetic drift runs twice as fast in the Moran model.

From this perspective we can easily get that branches are less stable than in the Gillepsie scenario, for as as time goes to infinity the probability of going extinct is intuitively bigger than 0.

## Initial conditions

One need to construct the world as an array of agents, which will be the ancestors of the following

```julia

agents=[Agent([2e-1].*randn(1))foriin1:K0]

```

The function

is then called `p["tend"] -1` times.

## Scenarios

You have several options available concerning the resource implemented and competition:

-``` mode="std"``` is the standard mode

-``` mode="grad2D"``` corresponds to a an ecological gradient

>We are not sure whether this corresponds to the following two images

-``` mode="mountain"``` corresponds to a scenario where a mountain arises (with an ecological gradient)

-``` mode="split"``` corresponds to a scenario where the resource is splitted in two

-``` mode="graph"``` this guy is probably not working

## Parallelism

You can run your script in parallel, which makes sense for large populations. To do so:

A particular event, birth or death, is chosen at random with a probability equal to the rate of this event divided by the total rate ``R``.

# The original article by Gillsepie:

[**A general method for numerically simulating the stochastic time evolution of coupled chemical reactions**](https://www.sciencedirect.com/science/article/pii/0021999176900413?via%3Dihub)