## Nee and May's random process

### Description

When branch lengths in an ultrametric phylogenetic tree are expressed as divergence times, the total sum of branch lengths in that tree expresses the amount of evolutionary history. The function `randEH` calculates the amount of evolutionary history preserved when k random species out of n original species are saved.

### Usage

```randEH(phyl, nbofsp, nbrep = 10)
```

### Arguments

 `phyl` an object of class phylog `nbofsp` an integer indicating the number of species saved (k). `nbrep` an integer indicating the number of random sampling.

### Value

Returns a numeric vector

### Author(s)

Sandrine Pavoine pavoine@biomserv.univ-lyon1.fr

### References

Nee, S. and May, R.M. (1997) Extinction and the loss of evolutionary history. Science 278, 692–694.

Pavoine, S., Ollier, S. and Dufour, A.-B. (2005) Is the originality of a species measurable? Ecology Letters, 8, 579–586.

`optimEH`

### Examples

```data(carni70)
carni70.phy <- newick2phylog(carni70\$tre)
mean(randEH(carni70.phy, nbofsp = 7, nbrep = 1000))

## Not run:
# the folowing instructions can last about 2 minutes.
data(carni70)
carni70.phy <- newick2phylog(carni70\$tre)
percent <- c(0,0.04,0.07,seq(0.1,1,by=0.1))
pres <- round(percent*70)
topt <- sapply(pres, function(i) optimEH(carni70.phy, nbofsp = i, give = F))
topt <- topt / EH(carni70.phy)
tsam <- sapply(pres, function(i) mean(randEH(carni70.phy, nbofsp = i, nbrep = 1000)))
tsam <- tsam / EH(carni70.phy)
plot(pres, topt, xlab = "nb of species saved", ylab = "Evolutionary history saved", type = "l")
lines(pres, tsam)

## End(Not run)
```

### Worked out examples

```
> ### Name: randEH
> ### Title: Nee and May's random process
> ### Aliases: randEH
> ### Keywords: multivariate
>
> ### ** Examples
>
> data(carni70)
> carni70.phy <- newick2phylog(carni70\$tre)
> mean(randEH(carni70.phy, nbofsp = 7, nbrep = 1000))
[1] 204.7027
>
>
> # the folowing instructions can last about 2 minutes.
> data(carni70)
> carni70.phy <- newick2phylog(carni70\$tre)
> percent <- c(0,0.04,0.07,seq(0.1,1,by=0.1))
> pres <- round(percent*70)
> topt <- sapply(pres, function(i) optimEH(carni70.phy, nbofsp = i, give = F))
> topt <- topt / EH(carni70.phy)
> tsam <- sapply(pres, function(i) mean(randEH(carni70.phy, nbofsp = i, nbrep = 1000)))
> tsam <- tsam / EH(carni70.phy)
> plot(pres, topt, xlab = "nb of species saved", ylab = "Evolutionary history saved", type = "l")
```
```> lines(pres, tsam)
```
```>
>
>
>
>
```