GenerateProbNumbers: Sample positions from a given probability density...

Description Usage Arguments Value Author(s) Examples

View source: R/GenerateProbNumbers.R

Description

this function randomly selects "times" positions in a vector according to a given distribution, either "power-law" or provided in the column "my.data$prob" It accepts a power-law distribution: y = c*x^k this parameterization is consistent with Hatton et al. 2015, who found a general scaling of k ~ 0.75 por prey and predator biomass across ecosystems globally hence the default k = 0.75. it also accepts a lognormal distribution with logmean and logsd and a gambin distribution with parameters gambin.alpha and gambin.maxoctave

Usage

1
2
3
GenerateProbNumbers(times, choice.length = 100, dist = "power-law", c = 1,
  k = 0.75, logmean = 0, logsd = 0.5, gambin.alpha = 2,
  gambin.maxoctave = 8, cum.sum = 0, my.data = NULL)

Arguments

times

number of positions to be selected

choice.length

length of the vector to select positions from

dist

either "uniform", "power-law", "lognormal" or "gambin"

c

for the power law parametrization

k

exponent of the power law

logmean

mean of the lognormal distribution

logsd

standard deviation of the lognormal distribution

gambin.alpha

alpha value of the gambin distribution

gambin.maxoctave

value of the maximum octave of the gambin distribution -TODO-

cum.sum

cumulative sum of the returning values

my.data

dataframe specifying the distribution to sample from, instead of dist. Of the form my.data$prob

Value

numeric vector of length times

Author(s)

David Garc<c3><ad>a-Callejas, david.garcia.callejas@gmail.com

Examples

1
2
3
4
5
6
7
t1 <- GenerateProbNumbers(100,c = 1, k = 0.75,cum.sum = 100)
hist(t1)
table(t1)
t2 <- GenerateProbNumbers(times = 2000, k = 0.25, cum.sum = 10000)
t3 <- GenerateProbNumbers(times = 80, choice.length = 100, dist = "gambin", gambin.alpha = 2, gambin.maxoctave = 8, cum.sum = 10000)
hist(t2)
hist(t3)

DavidGarciaCallejas/DGC documentation built on May 6, 2019, 1:54 p.m.