I have a problem.
I have to generate 10.000 random variables using the inverse method for Logistic distribution and Cauchy distribution.
I know their corresponding probability density functions and distribution functions, and I think I have to calculate with hand on paper the inverse of F(x) for each one, right? But I have no idea how to write it in Rstudio.
Please, help me!
I'm not sure about the context (e.g. is this homework?) For most common probability distributions, R has built-in functions for
p***, e.g.pnorm()d***, e.g.dnorm())q***, e.g.qnorm())r***, e.g.rnorm())You do have to know that the suffixes for Cauchy and logistic are
cauchyandlogis. If you ever need an exhaustive list of probability distribution implementations in R, you can see the probability distributions task view ...The random deviate generators usually have good/special purpose algorithms, which are often better (more efficient) than the inverse method. So the most efficient way to generate random deviates for the logistic and Cauchy distributions would be to use the
rlogis()andrcauchy()functions, respectively. But if you insist on using the inverse method,qlogis(runif(10000),...)orqcauchy(runif(10000),...)would do what you want (...would be optional parameter values: looking at?qlogis,?qcauchy, both distributions use location parameter 0 and scale parameter 1 by default).