rdCauchy: generate random variables from a Cauchy distribution using R.

Description Usage Arguments Value Examples

Description

Use the Metropolis-Hastings sampler to generate random variables from a Cauchy distribution.

Usage

1
rdCauchy(n, sigma, x0, u, lamada)

Arguments

n

length of the Markov chain(numeric)

sigma

standard error of the proposal distribution (numeric)

x0

initial value (numeric)

u

parameter of cauchy distribution. (numeric)

lamada

parameter of cauchy distribution. (numeric)

Value

the Markov chain and the number of refuse.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
n<-10000
cauchy<-rdCauchy(n,sigma=0.5,x0=0,u=0,lamada=1)
refuse.pr<-cauchy$k/n
refuse.pr
hist(cauchy$x[1001:n],freq=F,main="density of cauchy",breaks=60)
curve(dcauchy(x,0,1),add=TRUE)

## End(Not run)

YulieKing/StatComp18026 documentation built on May 29, 2019, 8:34 a.m.