## Return to Answer

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

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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 98, "mathjax_display_tex": 4, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9581085443496704, "perplexity_flag": "head"}