rexptr {RGeode}R Documentation

Random generator for a Truncated Exponential distribution.

Description

Simulate random number from a truncated Exponential distribution.

Usage

rexptr(n = 1, lambda = 1, range = NULL)

Arguments

n

int, optional
number of simulations.

lambda

double, optional
parameter of the distribution.

range

array_like, optional
domain of the distribution, where we truncate our Exponential. range(0) is the min of the range and range(1) is the max of the range.

Details

It provide a way to simulate from a truncated Exponential distribution with given pameter \lambda and the range range. This will be used during the posterior sampling in th Gibbs sampler.

Value

rexptr returns the simulated value of the distribution:

u

double
it is the simulated value of the truncated Exponential distribution. It will be a value in (range(0), range(1)).

Author(s)

L. Rimella, lorenzo.rimella@hotmail.it

References

Examples

#Simulate a truncated Exponential with parameters 0.5 in the range
#5,Inf.
#Set the range:
range<- c(1,Inf)

#Simulate the truncated Gamma
set.seed(123)
vars1<-rexptr(1000,0.5,range)

#Look at the histogram
hist(vars1,freq=FALSE,ylim=c(0,2),xlim = c(0,5))
lines(density(vars1))

#Compare with a non truncated Exponential
set.seed(123)
vars2<-rexp(1000,0.5)


#Compare the two results
lines(density(vars2),col='red')

#Observation: simulate without range is equivalent to simulate from
#rexp(1000,0.5)


[Package RGeode version 0.1.0 Index]