Map from Normally distributed Variable to Gamma distributed Varaible [duplicate]

I need to find some function $$f:\mathbb{R} \rightarrow \mathbb{R}^+$$ such that

If $$\; \; x \sim \mathcal{N}(x; \mu, \sigma^2) \; \;$$ then $$\; \; f(x) \sim \mathcal{G}(y; \alpha, rate=\beta)$$

Where $$\mathcal{G}$$ is the Gamma probability density function.

I think it will have to do with the derivation of the distribution function of $$\sigma^2$$ from a normal distribution, and $$\alpha, \beta$$ will have to be functions of $$\mu, \sigma$$. But I am having trouble from here.

• The obvious one is to transform the normal to uniform $U=F(X)$ and the uniform to gamma $Y=G^{-1}(U)$ where F and G are the relevant cdfs. This composition of functions is discussed in many posts on site Commented Oct 15, 2023 at 5:52
• @Glen_b The idea of using an intermediary space then a composite function makes sense. However, I am a little confused on what you mean by the uniform though. Like a uniform distribution over [0, 1]? Commented Oct 15, 2023 at 6:08
• If you transform any continuous random variable by its cdf you get a uniform on the unit interval, yes. en.wikipedia.org//wiki/Probability_integral_transform ... also see en.wikipedia.org/wiki/Inverse_transform_sampling to transform a uniform to some other desired distribution ... As indicated in my earlier comment, $Y= G^{-1}(F(X))$ has the desired distribution. Commented Oct 15, 2023 at 7:44
• There's some discussion here: stats.stackexchange.com/questions/243151/… but the same idea crops up in multiple places Commented Oct 15, 2023 at 8:03