> For the complete documentation index, see [llms.txt](https://mc.hohoweiya.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mc.hohoweiya.xyz/genrv/mixture-exp.md).

# Minimum of Two Exponential

Suppose we want to simulate pseudo random numbers from the following distribution, which I came across in [r - Finding a way to simulate random numbers for this distribution - Cross Validated](https://stats.stackexchange.com/questions/391054/finding-a-way-to-simulate-random-numbers-for-this-distribution),

$$
F(x) = 1-\exp\left(-ax - \frac{b}{p+1}x^{p+1}\right),\quad x\ge 0
$$

where $$a, b>0$$ and $$p\in (0,1)$$.

[Xi'an](https://stats.stackexchange.com/users/7224/xian) provided a very elegant solution.

Note that

$$
(1-F(x))=\exp\left{-ax-\frac{b}{p+1}x^{p+1}\right}=\underbrace{\exp\left{-ax\right}}*{1-F\_1(x)}\underbrace{\exp\left{-\frac{b}{p+1}x^{p+1}\right}}*{1-F\_2(x)}
$$

the distribution $$F$$ is the distribution of

$$
X=\min{X\_1,X\_2}\qquad X\_1\sim F\_1,,X\_2\sim F\_2
$$

since

$$
F(x) = P(X\le x) = 1- P(X > x)  = 1-P(X\_1 > x)P(X\_2 > x) = 1-(1-F\_1(X))(1-F\_2(X)),.
$$

Thus, the R code to simulate is simple to be

```r
x = pmin(rexp(n, a), rexp(n, b/(p+1))^(1/(p+1)))
```

## References

* [Finding a way to simulate random numbers for this distribution](https://stats.stackexchange.com/questions/391054/finding-a-way-to-simulate-random-numbers-for-this-distribution)
* [simulation fodder for future exams](https://xianblog.wordpress.com/2019/02/20/simulation-fodder-for-future-exams/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mc.hohoweiya.xyz/genrv/mixture-exp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
