Skip to main content
cite related question
Source Link
jcz
  • 1.4k
  • 10
  • 17

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

Motivation

Some use cases:

  • Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a "nice" transformation ($C^1$ diffeomorphism), and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$. Since we can sample $\mathbf{X}$, it's easy to sample $\mathbf{Y}$; draw an $\mathbf{X}$ and apply $\mathbf{g}$ to it. Furthermore, you can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that computation, and you want to check that you did it right. How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?
  • Say you are writing some software to implement a probability distribution (perhaps the one you derived above). So you want to write two functions: mydist_rand(...) for generating random draws, and mydist_pdf(...) for evaluating the pdf at a point. To test your software for errors, you want to check that the outputs of these two functions "agree." How can you do it?

(Update: Here is a related question with a great answer, but the proposed solutions seem applicable only to univariate random variables, and several assume that the CDF is easy to access, which I don't want to assume here.)

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

Motivation

Some use cases:

  • Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a "nice" transformation ($C^1$ diffeomorphism), and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$. Since we can sample $\mathbf{X}$, it's easy to sample $\mathbf{Y}$; draw an $\mathbf{X}$ and apply $\mathbf{g}$ to it. Furthermore, you can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that computation, and you want to check that you did it right. How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?
  • Say you are writing some software to implement a probability distribution (perhaps the one you derived above). So you want to write two functions: mydist_rand(...) for generating random draws, and mydist_pdf(...) for evaluating the pdf at a point. To test your software for errors, you want to check that the outputs of these two functions "agree." How can you do it?

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

Motivation

Some use cases:

  • Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a "nice" transformation ($C^1$ diffeomorphism), and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$. Since we can sample $\mathbf{X}$, it's easy to sample $\mathbf{Y}$; draw an $\mathbf{X}$ and apply $\mathbf{g}$ to it. Furthermore, you can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that computation, and you want to check that you did it right. How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?
  • Say you are writing some software to implement a probability distribution (perhaps the one you derived above). So you want to write two functions: mydist_rand(...) for generating random draws, and mydist_pdf(...) for evaluating the pdf at a point. To test your software for errors, you want to check that the outputs of these two functions "agree." How can you do it?

(Update: Here is a related question with a great answer, but the proposed solutions seem applicable only to univariate random variables, and several assume that the CDF is easy to access, which I don't want to assume here.)

describe another use case
Source Link
jcz
  • 1.4k
  • 10
  • 17

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

Motivation

Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a $C^1$ diffeomorphism, and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$.

You can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that, and you want to check that you did it right.

How can youSome use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?cases:

  • Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a "nice" transformation ($C^1$ diffeomorphism), and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$. Since we can sample $\mathbf{X}$, it's easy to sample $\mathbf{Y}$; draw an $\mathbf{X}$ and apply $\mathbf{g}$ to it. Furthermore, you can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that computation, and you want to check that you did it right. How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?
  • Say you are writing some software to implement a probability distribution (perhaps the one you derived above). So you want to write two functions: mydist_rand(...) for generating random draws, and mydist_pdf(...) for evaluating the pdf at a point. To test your software for errors, you want to check that the outputs of these two functions "agree." How can you do it?

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

Motivation

Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a $C^1$ diffeomorphism, and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$.

You can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that, and you want to check that you did it right.

How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

Motivation

Some use cases:

  • Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a "nice" transformation ($C^1$ diffeomorphism), and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$. Since we can sample $\mathbf{X}$, it's easy to sample $\mathbf{Y}$; draw an $\mathbf{X}$ and apply $\mathbf{g}$ to it. Furthermore, you can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that computation, and you want to check that you did it right. How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?
  • Say you are writing some software to implement a probability distribution (perhaps the one you derived above). So you want to write two functions: mydist_rand(...) for generating random draws, and mydist_pdf(...) for evaluating the pdf at a point. To test your software for errors, you want to check that the outputs of these two functions "agree." How can you do it?
depersonalize
Source Link
jcz
  • 1.4k
  • 10
  • 17

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

My MotivationMotivation

Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a $C^1$ diffeomorphism, and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$.

You can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that, and you want to check that you did it right.

How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

My Motivation

Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a $C^1$ diffeomorphism, and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$.

You can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that, and you want to check that you did it right.

How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?

General Question

If someone handed you a direct sampling algorithm and a density function, and they told you that the two corresponded to the same random variate, how would you check this?

Motivation

Let $\mathbf{X}\in E\subseteq\mathbb{R}^n$ be a random vector whose density is $f_{\mathbf{X}}$ and for which a direct sampler is known. Let $\mathbf{g}:E\to\mathbb{R}^n$ be a $C^1$ diffeomorphism, and define a new random vector $\mathbf{Y}=\mathbf{g}(\mathbf{X})$.

You can derive the density of $\mathbf{Y}$ by computing $$f_{\mathbf{Y}}(\mathbf{y}) = f_{\mathbf{X}}(\,\mathbf{g}^{-1}(\mathbf{y})\,)\cdot|\det\mathrm{J}_{\mathbf{g}^{-1}}(\mathbf{y})|.$$ So say you grind through that, and you want to check that you did it right.

How can you use the fact that you know how to sample $\mathbf{Y}$ to check that you correctly computed the density of $\mathbf{Y}$?

edited title
Link
jcz
  • 1.4k
  • 10
  • 17
Loading
Source Link
jcz
  • 1.4k
  • 10
  • 17
Loading