Description Usage Arguments Value Author(s) Examples
Rayleigh distribution is characterized by the following probability density function,
f(x;σ) = \frac{x}{σ^2} \exp( -x^2 / (2σ^2))
where the domain is nonnegative real number x \in [0,∞) with scale parameter σ > 0.
| 1 | 
| x | a length-n vector of nonnegative real numbers. | 
| weight | a length-n weight vector. If set as  | 
a named list containing (weighted) MLE of
scale parameter σ.
Kisung You
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #  generate data from exponential distribution with lambda=1
x = stats::rexp(100, rate=1)
#  fit unweighted
Rayleigh(x)
## Not run: 
# put random weights to see effect of weights
niter = 500
ndata = 200
# generate data and fit unweighted MLE
x    = stats::rexp(ndata, rate=1)
xmle = Rayleigh(x)
# iterate
vec.sigma = rep(0,niter)
for (i in 1:niter){
  # random weight
  ww = abs(stats::rnorm(ndata))
  MLE = Rayleigh(x, weight=ww)
  vec.sigma[i] = MLE$sigma
  if ((i%%10) == 0){
    print(paste0(" iteration ",i,"/",niter," complete.."))
  }
}
# distribution of weighted estimates + standard MLE
opar <- par(no.readonly=TRUE)
hist(vec.sigma, main="scale 'sigma'")
abline(v=xmle$sigma, lwd=3, col="red")
par(opar)
## End(Not run) 
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.