1

I am supposed to use rexp() in R to draw from an exponential distribution with mean 1, and then use those draws to generate 1000 draws from each of the following:

  1. a $\chi^2$ distribution with 4 degrees of freedom
  2. a $\text{Beta}(2,3)$ distribution.

I assume once the theory is understood this is a trivial task, but I might be wrong. I have been looking at the "Related Distributions" section of Wikipedia for the chi-squared, gamma, exponential and beta distributions and there are some interesting tidbits there that make me think this is doable, but I'm not sure how to put the pieces together.

Edit:

I have added the self-study tag. Regarding Glen_b's comment:

Various connections that seem potentially promising:

  1. If $X \sim \chi_2^2$, then $X \sim \text{Exp}(1/2)$. Seems close to being helpful, but the wrong parametrization. Could this be manipulated into something useful?

  2. Related to the above, if $X \sim \text{Exp}(\lambda)$, then $kX \sim \text{Exp}(\lambda/k)$. So if I let $k = 1/2$ and then applied this above, I could get an $\text{Exp}(1)$ random variable. But how would this affect the $\chi_2^2$ part?

  3. If $X \sim \text{Exp}(\lambda)$, then, then $e^{-X} \sim \text{Beta}(\lambda, 1)$. Again, something that looks like it could be handy, but wrong parametrization.

  4. $\sum_{i = 1}^n \text{Exp}(\lambda) \sim \frac{1}{2\lambda} \chi_{2n}^2$. So if I understand this correctly, if I generated 2000 draws from $\text{Exp}(1)$ and then added the first and second, third and fourth and so on, and then multiplied all of those 1000 sums by 2, then I'd have 1000 $\chi_4^2$ draws?

  5. If $X \sim \text{Gamma}(\alpha, \theta)$ and $Y \sim \text{Gamma}(\beta, \theta)$, and they're independent, then $\frac{X}{X + Y} \sim \text{Beta}(\alpha, \beta)$. Wrong parametrization again. Maybe if I drew 5000 times from $\text{Exp}(1)$ and added the first 2000 in pairs and the last 3000 in triples, and then computed 1000 quotients?

  6. If $X \sim \chi^2 (\alpha)$ and $Y \sim \chi^2 (\beta)$ are independent, then $\frac{X}{X + Y} \sim \text{Beta}(\alpha/2, \beta/2)$. Seems like 5 above might be a better bet? Not sure.

Edit 2:

To try to clarify a couple things, I need to do what I wrote at the top of this post. I can't use another method, as far as I know. Second, regarding "wrong parametrization", I might be mistaken but I meant that, for example, point 1 in the list above relates the exponential and chi-squared distributions, but I need to somehow turn $\text{Exp}(1)$ into $\chi_4^2$ (and into $\text{Beta}(2, 3)$, so some of what I've written above looks like "close but no cigar".

My current thinking is that points 4 and 5 in the list make the most sense. For point 4, I could draw 2000 times from $\text{Exp}(1)$ and then add the 2000 numbers in pairs, which would give me 1000 numbers from $\frac{1}{2}\chi_4^2$, so I just have to scale all the 1000 numbers by 2 and then that should be done.

For point 5, $\text{Exp}(1) = \text{Gamma}(1, 1)$, and if the exponential random variables are independent, then $\sum_{i = 1}^n \text{Exp}(1) \sim \text{Gamma}(n, 1)$. This means that by drawing 5000 times from $\text{Exp}(1)$, and making 1000 sums of 2 and 1000 sums of 3, I can make 1000 $\text{Gamma}(2)$ and 1000 $\text{Gamma}(3)$ random variables, and then applying 5. I can turn those into 1000 $\text{Beta}(2,3)$ random variables.

So unless I've misunderstood something, I've (we've) figured it out. Thanks.

Novice
  • 531
  • 2
  • 9
  • 3
    1. This is work for some subject? see https://stats.stackexchange.com/tags/self-study/info 2. the Wikipedia articles you link to have everything you need (mostly in the section you mention but you might need a fact from elsewhere in one or two articles if you don't already know it). What connections did you discover between (a) the exponential and the chi-square? (and what do you know about sums of independent chi-square r.v.s) and (b) the Beta and Gamma or Chi-squared distributions? What else would you need in order to simulate from the distributions you've been asked to? – Glen_b Jan 18 '22 at 22:58
  • 1
    These distributions don't need to be "related" in any way. Have you seen [our posts on the Probability Integral Transform](https://stats.stackexchange.com/search?tab=votes&q=%22probability%20integral%20transform%22)? That gives one general solution. @Glen_b's post at https://stats.stackexchange.com/a/234552/919 (the first hit) gives a good explanation applicable to your problem. (There are some neat, elegant ways to skip the PIT and generate the desired random variables *via* algebraic manipulations of Exponentially distributed variables, though.) – whuber Jan 18 '22 at 23:58
  • 2
    This is true (and worth mentioning) but given the phrasing I expect that the OP is meant to be using those relationships for an assignment. – Glen_b Jan 19 '22 at 00:10
  • Re the edits: could you explain what you mean by "wrong parameterization"? The solution to this problem doesn't depend on how you *name* the distributions--that's all the parameterization is--but on what you actually do with them. – whuber Jan 19 '22 at 00:10
  • @Novice Why would the parameterization matter? If you know what distribution you have and which one you need, you can work with any parameterizations you like, as long as you use the corresponding distribution. A chi-squared(2) is an exponential with mean 2 (scale parameter 2, rate parameter 1/2). What more do you need? – Glen_b Jan 19 '22 at 00:12
  • 2
    Your thinking looks like it's on the right track, suggesting you will benefit most from a little experimentation. To get you started, here's an example that compares a multiple of $X$ to a chi-squared distribution. It will help you settle point (1). `hist(2 * rexp(1e4), breaks=50, freq=FALSE); curve(dchisq(x, 2), add=TRUE, lwd=2) ` – whuber Jan 19 '22 at 00:27
  • 1
    In point 6., could you identify $\alpha$ and $\beta$ such that $\alpha/2=2$ and $\beta/2=3$? – Xi'an Jan 19 '22 at 05:48
  • 1
    @whuber: I think the OP is using `parameterization' in a non-standard way, meaning the set of parameters as in, e.g., a Beta$(\lambda,1)$ is a wrong parameterization for a Beta$(2,3)$... – Xi'an Jan 19 '22 at 05:51
  • 1
    Very nice start. From a few Wikipedia pgs you've gleaned all you need. And your ideas for putting the pieces together are on the right track (if not exactly right). @whuber's Comment is a nice clue toward getting it exactly right (along with a picture to show when you do get it right). Your try with (6) and Xi'an's note will get you to the right Beta dist'n. (Also, Xi'an notes that you mean parameter _values_ are not right; _parameterization_ has to do with how parameters are used; e.g., you can use either rate $\lambda$ or mean $\mu = 1/\lambda$ to _paramaterize_ an exponential dist'n. – BruceET Jan 19 '22 at 08:45
  • 1
    Re the edits: there's more than one way to succeed here. One solution is `U – whuber Jan 19 '22 at 15:43

0 Answers0