4 added 1 characters in body

It is possible to do that using the algorithm known as the Independent Metropolis-Hastings sampler without having to do any transformation and without having to compute the constant normalizing terms.

Assume you can sample from the density $q(x)\propto \exp(g(x))$ where $g(x)$ is a polynomial (say, you are sampling from the normal distribution) and your objective is to get a sample from the density $p(x)\propto \exp(f(x))$ where $f(x)$ is another polynomial (naturally both polynomials need to have negative leading term to insure those densities exist). Then the algorithm will produce a Markov process whose invariant distribution is $p(x)$. Starting from some arbitrary initial value, say $X^0$, let's say that you have already $M$ draws. To get a new sample draw $X^{M+1}$, draw a random variable from $q$. Let's call that draw $X'$. Then accept or rejet $X'$ with probability $$1 \wedge \exp[f(X')-f(X^M)+g(X^M)-g(X')]$$ If you have accepted then set $X^{M+1}=X'$ otherwise set $X^{M+1}=X^M$.

Eventually that Markov process would have converged and you could consider say the last $N$ draws as such a sample from the desired distribution.

A very good introduction to that algorithm is section 7.4 of this excellent book

Edit As indicated by the author of the question in a comment below, if the question is to transform a sample from one continuous distribution having density $q(x)$ into a sample from another continuous distribution having density $p(x)$, then this could be achieved in the following way.

Let $Q$ and $P$ be respectively the CDF's with associated with $q$ and $p$. p$respectively. Assume we have an i.i.d. sample from$X_1$,...,$X_n$from$q$, then$P^{-1}(Q(X_1))$,...,$P^{-1}(Q(X_n))$is an i.i.d. sample from$p$. (this is straightforward to prove). Now, the issue in your case is that$P$or and the quantile function$P^{-1}$may not be known in closed-form (even the normalizing constant of the density associated with it$P$may be not be known in closed form.) However, numerical integration and interpolation could work here. 3 edited body; deleted 23 characters in body; added 66 characters in body It is possible to do that using the algorithm known as the Independent Metropolis-Hastings sampler without having to do any transformation and without having to compute the constant normalizing terms. Assume you can sample from the density$q(x)\propto \exp(g(x))$where$g(x)$is a polynomial (say, you are sampling from the normal distribution) and your objective is to get a sample from the density$p(x)\propto \exp(f(x))$where$f(x)$is another polynomial (naturally both polynomials need to have negative leading term to insure those densities exist). Then the algorithm will produce a Markov process whose invariant distribution is$p(x)$. Starting from some arbitrary initial value, say$X^0$, let's say that you have already$M$draws. To get a new sample draw$X^{M+1}$, draw a random variable from$q$. Let's call that draw$X'$. Then accept or rejet$X'$with probability $$1 \wedge \exp[f(X')-f(X^M)+g(X^M)-g(X')]$$ If you have accepted then set$X^{M+1}=X'$otherwise set$X^{M+1}=X^M$. Eventually that Markov process would have converged and you could consider say the last$N$draws as such a sample from the desired distribution. A very good introduction to that algorithm is section 7.4 of this excellent book Edit As indicated by the author of the question in a comment below, if the question is to transform a sample from one continuous distribution having density$q(x)$into a sample from another continuous distribution having density$p(x)$, then this could be achieved in the following way. Let$Q$and$P$be respectively the CDF's with associated with$q$and$p$. Assume we have an i.i.d. sample from$X_1$,...,$X_n$from$q$, then$P(Q^{-1}(X_1))$,...,$P(Q^{-1}(X_n))$P^{-1}(Q(X_1))$,...,$P^{-1}(Q(X_n))$ is an i.i.d. sample from $p$. (this is straightforward to prove).

Now, the issue in your case is that $P$ or the quantile function may not be known in closed-form (even the normalizing constant of the density associated with it may be not be known in closed form.) However, numerical integration and interpolation could work here.

2 added 786 characters in body

It is possible to do that using the algorithm known as the Independent Metropolis-Hastings sampler without having to do any transformation and without having to compute the constant normalizing terms.

Assume you can sample from the density $q(x)\propto \exp(g(x))$ where $g(x)$ is a polynomial (say, you are sampling from the normal distribution) and your objective is to get a sample from the density $p(x)\propto \exp(f(x))$ where $f(x)$ is another polynomial (naturally both polynomials need to have negative leading term to insure those densities exist). Then the algorithm will produce a Markov process whose invariant distribution is $p(x)$. Starting from some arbitrary initial value, say $X^0$, let's say that you have already $M$ draws. To get a new sample draw $X^{M+1}$, draw a random variable from $q$. Let's call that draw $X'$. Then accept or rejet $X'$ with probability $$1 \wedge \exp[f(X')-f(X^M)+g(X^M)-g(X')]$$ If you have accepted then set $X^{M+1}=X'$ otherwise set $X^{M+1}=X^M$.

Eventually that Markov process would have converged and you could consider say the last $N$ draws as such a sample from the desired distribution.

A very good introduction to that algorithm is section 7.4 of this excellent book

Edit As indicated by the author of the question in a comment below, if the question is to transform a sample from one continuous distribution having density $q(x)$ into a sample from another continuous distribution having density $p(x)$, then this could be achieved in the following way.

Let $Q$ and $P$ be respectively the CDF's with associated with $q$ and $p$. Assume we have an i.i.d. sample from $X_1$,...,$X_n$ from $q$, then $P(Q^{-1}(X_1))$,...,$P(Q^{-1}(X_n))$ is an i.i.d. sample from $p$. (this is straightforward to prove).

Now, the issue in your case is that $P$ may not be known in closed-form (even the normalizing constant of the density associated with it may be not be known in closed form.) However, numerical integration could work here.

1