Newest questions tagged accept-reject - Cross Validated most recent 30 from stats.stackexchange.com 2019-07-19T21:34:46Z https://stats.stackexchange.com/feeds/tag?tagnames=accept-reject&sort=newest http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://stats.stackexchange.com/q/415895 1 Devising an acceptance sampling plan for False Negative Rate st1led https://stats.stackexchange.com/users/146429 2019-07-03T15:44:16Z 2019-07-08T16:29:57Z <p>I need to evaluate a binary classifier that classifies inputs in positives and negatives. Since all predicted positives (PP) are assessed, I have complete data on the true positives (TP) and the false positives (FP). However, predicted negatives (PN) are sampled and I only have sample-based estimates on the false negatives (FN) and true negatives (TN).</p> <p>I'm looking for (or most likely, I have to devise) an acceptance sampling plan that ensures that the classifier FNR is below a certain threshold. This plan would have as parameters</p> <ul> <li>the lot (or population) size: in my case <span class="math-container">$PN=FN+TN$</span></li> <li>the target metric limit that has to be achieved: in my case <span class="math-container">$FNR &lt; 0.05$</span></li> <li>a sample size <span class="math-container">$n$</span></li> </ul> <p>and for those, it would define</p> <ul> <li>a cutoff threshold <span class="math-container">$c$</span> such that, said <span class="math-container">$x$</span> the number of false negatives in the sample, the lot is accepted if <span class="math-container">$x \leq c$</span> and rejected otherwise</li> </ul> <p>Ultimately, the sampling plan provides can estimate the probability that a certain lot is accepted (<span class="math-container">$x \leq c$</span>) while it should have been rejected (<span class="math-container">$FNR \geq 0.05$</span>). Typically, this conditional probability has to be below a certain threshold, in my case 10%:</p> <p><span class="math-container">$P(x \leq c ~|~ FNR \geq 0.05) &lt; 0.1$</span></p> <p>How can I find this value for <span class="math-container">$c$</span>? I've never seen sampling plans targeted at measuring machine learning metrics. I feel the answer lies along the lines of using the hypergeometric distribution to estimate this probability, but I can't see the math quite yet.</p> <hr> <p>Update: this is the furthest I managed to reach after some additional tinkering. From the theory, we know that a random variable <span class="math-container">$X$</span> following the hypergeometric distribution <span class="math-container">$X \sim H(N,K,n)$</span> models drawing <span class="math-container">$n$</span> items without replacement from a population of <span class="math-container">$N$</span>, where <span class="math-container">$K \leq N$</span> are of interest. In my case, <span class="math-container">$N=TN+FN$</span> (the whole population where to sample) and <span class="math-container">$K=FN$</span> (the whole number of items of interest in N).</p> <p>Given that <span class="math-container">$FNR=\frac{FN}{FN+TP}$</span>, we have that <span class="math-container">$FN=\frac{TP \cdot FNR}{1-FNR}$</span>. Note that I can calculate <span class="math-container">$FN$</span> if I assume <span class="math-container">$FNR = 0.05$</span>.</p> <p>Essentially, this means that I can use the hypergeometric distribution with parameters <span class="math-container">$N=PN=TN+FN$</span> and <span class="math-container">$K=FN=\frac{TP \cdot FNR}{1-FNR}$</span> to calculate some pairs <span class="math-container">$(n, c)$</span> for <span class="math-container">$P(X \leq c)$</span>, i.e., the probability of having less than <span class="math-container">$c$</span> out of <span class="math-container">$n$</span> false negatives when sampling among <span class="math-container">$N$</span> items with <span class="math-container">$K$</span> total false negatives (which contribute to have a 5% FNR).</p> <p>Is this logic going in the right direction?</p> https://stats.stackexchange.com/q/414508 0 How the conditional probability is being calculated in Rejection sampling user26264 https://stats.stackexchange.com/users/251826 2019-06-24T18:31:58Z 2019-06-24T18:31:58Z <p>In a class lecture, the "Acceptance-rejection algorithm" was presented as follows:</p> <blockquote> <p>To generate <span class="math-container">$𝑋 \sim 𝑓(𝑥)$</span>, Find density <span class="math-container">$g$</span> satisfying <span class="math-container">$\frac{f(t)}{g(t)}&lt;=c$</span> for some constant <span class="math-container">$c$</span> for all <span class="math-container">$t \in domain(f)$</span> with <span class="math-container">$f(t)&gt;0$</span> and from which rv's can be generated. For each rv required,</p> <ol> <li>Generate <span class="math-container">$Y \sim g$</span></li> <li>Generate <span class="math-container">$U \sim U(0,1)$</span></li> <li>If <span class="math-container">$U \leq \frac{f(t)}{cg(t)}$</span> accept Y and return <span class="math-container">$X = Y$</span> otherwise go back to step 1.</li> </ol> <p>In step 3, we see that <span class="math-container">$P(accept|Y=y)=P(U \leq \frac{f(y)}{cg(y)}|Y=y)=\frac{f(y)}{cg(y)})$</span></p> </blockquote> <p>I do not understand how can we derive the last staement:</p> <blockquote> <p><span class="math-container">$P(accept|Y=y)=P(U \leq \frac{f(y)}{cg(y)}|Y=y)=\frac{f(y)}{cg(y)})$</span></p> </blockquote> <p>I understand this is a very basic thing but I am stuck in it. From what I understand, <span class="math-container">$P(accept|Y=y)$</span> should be equal to <span class="math-container">$\frac{P(accept, Y=y)}{P(Y = y)}$</span> But how are we calculating the <span class="math-container">$P(accept, Y=y)$</span>? A break down of the derivation will be very helpful for my understanding.</p> https://stats.stackexchange.com/q/408995 2 Metropolis-Hastings - interpreting the transition kernel: alpha*proposal silly student https://stats.stackexchange.com/users/228809 2019-05-19T01:02:01Z 2019-05-20T09:48:01Z <p>I thought I had great intuition and mathematical understanding of the Metropolis-Hastings algorithm, until closer inspection... as I started compiling my notes, I realized I do not understand the rejection step of the algorithm.</p> <p>Here is what I understood:</p> <p>We have a target distribution <span class="math-container">$\pi(x)$</span>, and we construct a transition kernel <span class="math-container">$K(x' \mid x)$</span> such that the detailed balance equation holds. <span class="math-container">$$\pi(x)K(x' \mid x) = \pi(x') K(x \mid x')$$</span></p> <p>We can choose <span class="math-container">$$K(x, x') = \displaystyle \alpha(x, x')q(x \mid x')$$</span> Where <span class="math-container">$\alpha$</span> is the Metropolis-Hastings ratio, and <span class="math-container">$q$</span> is some proposal distribution. This particular construction of <span class="math-container">$\alpha$</span> helps correct the discrepancies in our detailed balance equation, thus providing us flexibility in choosing <span class="math-container">$q$</span>.</p> <p>Where I am having problems:</p> <ul> <li>How do I think about <span class="math-container">$K$</span> as a distribution (or even visualize)? In particular, what is <span class="math-container">$\alpha(x, x')$</span>? </li> <li>What's going on with the sampling step where we reject and stay at <span class="math-container">$x$</span>? Originally I thought of it as some correction function, but the rejection meant <span class="math-container">$X' := X$</span> and thus instinctively, I want think of <span class="math-container">$K(X, X')$</span> as a mixture of a <span class="math-container">$\delta_{\{X\}}(X')$</span> and <span class="math-container">$q(X'|X)$</span>, however, the mass associated with this dirac delta varies depending on <span class="math-container">$x'$</span>...? Not quite a mixture model. </li> <li><s> Should I be looking to interpret <span class="math-container">$\alpha$</span> as some form of accept-reject algorithm? </s></li> <li>How do I write <span class="math-container">$K$</span> as a density?</li> </ul> <p>Edit: Maybe this should be a question not a comment:</p> <p>With regards to the order of derivations (ie. motivation), is the following a reasonable thought process? </p> <ol> <li>We want to construct some transition kernel invariant to our target distribution. </li> <li>We select some proposal distribution, and notice it breaks detailed balance equation. </li> <li>we correct it with an acceptance-probability. </li> <li>Due to this correction probability, we need to have some action corresponding to the complement accepting the proposed state -> we remain at our current state. </li> </ol> <p>Question: Is this choice of "remain at current state" arbitrary?</p> https://stats.stackexchange.com/q/406361 3 Interpretation of the region of rejection in hypothesis testing in binomial distribution ecjb https://stats.stackexchange.com/users/198444 2019-05-03T04:50:56Z 2019-05-03T07:17:00Z <p>The pharmacy company Life Co. has developed a new drug against insomnia. To check the effectiveness, this drug was tested with n = 10 patients. At present, the standard medication can cure 30% of the treated patients.</p> <ul> <li>The treatment with the new drug was successful with exactly four patients. Perform a one-sided hypothesis test to decide if the new drug is better than the standard one (with a level of significance of 1%). Write down explicitly all six steps.:</li> <li><p><strong>Model</strong>: <span class="math-container">$X$</span> is the number of patients which were succesffully treated, <span class="math-container">$X\sim \text{Bin}(10, \pi)$</span></p></li> <li><p><strong>Null hypothesis</strong>: <span class="math-container">$H_0 : \pi = 0.3$</span>. <strong>Alternative hypothesis:</strong> <span class="math-container">$H_A: \pi &gt; 0.3$</span></p></li> <li><strong>Test statistic</strong>: <span class="math-container">$X$</span> - number of cured patients Distribution under <span class="math-container">$H_0 : X\sim \text{Bin}(10, 0.3)$</span></li> <li>Choose <strong>significance level</strong>: <span class="math-container">$\alpha = 1\% = 0.01$</span></li> <li><strong>Range of rejection</strong> (note: one-sided test): We look for set <span class="math-container">$K = \{...\}$</span> such that <span class="math-container">$P_{H_0}(X\in K)\leq \alpha$</span></li> </ul> <p><span class="math-container">$$\begin{array}{l|llllll} &amp;x = 5&amp;x = 6&amp;x = 7&amp;x = 8&amp;x = 9&amp;x = 10\\ \hline P(X \geq x)&amp;0.1503&amp;0.0473&amp;0.0106&amp;0.0016&amp;0.0001&amp;5.9\cdot 10^{-6}\\ \end{array}$$</span> Therefore the rejection range is <span class="math-container">$K = {8,9,10}$</span>. The probabilities listed in the table can be calculated in R in the following way</p> <pre><code> # R Code &gt; n=10 &gt; pi=0.3 &gt; 1-pbinom(4:9,n,pi)  0.1502683326 0.0473489874 0.0105920784 0.0015903864  0.0001436859 0.0000059049 </code></pre> <ul> <li><strong>Test decision</strong>: Since <span class="math-container">$4 \not \in K$</span>, <span class="math-container">$H_0$</span> cannot be rejected. Therefore, we cannot proof that the success rate of the new drug is better</li> </ul> <p><strong>HERE ARE MY QUESTIONS:</strong></p> <ol> <li>How do we find the number of the rejection range <span class="math-container">$K = 8,9,10$</span></li> <li>Where does the number 4:9 come from in the code <code>1-pbinom(4:9,n,pi)</code>?</li> </ol> https://stats.stackexchange.com/q/396704 3 How does the Metropolis Algorithm "get off the ground"? Ryker https://stats.stackexchange.com/users/19669 2019-03-10T17:42:21Z 2019-03-12T07:31:04Z <p>I'm thoroughly confused by the Metropolis Algorithm as defined in <a href="https://amzn.to/2tZTRta" rel="nofollow noreferrer">Casella and Berger's <em>Statistical Inference</em>.</a> Namely, here's the definition (p.254):</p> <p>Let <span class="math-container">$Y \sim f_Y(y)$</span> and <span class="math-container">$V \sim f_V(v)$</span>, where <span class="math-container">$f_Y$</span> and <span class="math-container">$f_V$</span> have common support. To generate <span class="math-container">$Y \sim f_Y(y):$</span></p> <ol> <li>Generate <span class="math-container">$V \sim f_V$</span>. Set <span class="math-container">$Z_0=V$</span>. </li> </ol> <p>Then for <span class="math-container">$i=1,2,...:$</span></p> <ol start="2"> <li><p>Generate <span class="math-container">$U_i \sim \text{uniform}(0,1)$</span>, <span class="math-container">$V_i \sim f_V$</span>, and calculate <span class="math-container">$\rho_i=\text{min}(\frac{f_Y(V_i)}{f_V(V_i)} \frac{f_V(Z_{i-1})}{f_Y(Z_{i-1})},1).$</span></p></li> <li><p>Set <span class="math-container">$$Z_i =\begin{cases} V_i &amp; \text{if }U_i\leq \rho_i \\ Z_{i-1} &amp; \text{if }U_i &gt; \rho_i \end{cases}.$$</span></p></li> </ol> <p>Then <span class="math-container">$Z_i \to Y$</span> in distribution as <span class="math-container">$i \to \infty$</span>.</p> <p>But with such a definition <span class="math-container">$\rho_1 = 1$</span> and <span class="math-container">$Z_1 = V$</span>, so that all <span class="math-container">$\rho_i=1$</span> and all <span class="math-container">$Z_i = V$</span>. Am missing something or is there an error in the definition?</p> <p>Is it that even though <span class="math-container">$V_1$</span> and <span class="math-container">$Z_0$</span> have the same distribution, you're drawing twice and then not necessarily <span class="math-container">$v_1 = z_0$</span>?</p> https://stats.stackexchange.com/q/393877 1 Acceptance-Rejection using Functional N00ber https://stats.stackexchange.com/users/218315 2019-02-22T17:14:59Z 2019-02-23T16:58:56Z <p><strong>Setup</strong> Let <span class="math-container">$X\in L^1(\Omega,\mathcal{F},\mathbb{P})$</span>.<br> As far as I've seen, Monte-Carlo methods generate <span class="math-container">$x_1,\dots,x_n$</span> from the distribution of <span class="math-container">$X$</span> and uses the Glivenko-Cantelli theorem to conclude that <span class="math-container">$$\frac1{n}\sum_{i=1}^N \delta_{x_i} \overset{D}{\rightarrow} Law(X).$$</span></p> <p>Acceptance\rejection sampling follows the same procedure, but given a function <span class="math-container">$f:\mathbb{R}\rightarrow \mathbb{R}$</span> and a threshold <span class="math-container">$M\in \mathbb{R}$</span>, it extends the above method to obtain <span class="math-container">$$\frac1{\sum_{i=1}^N I_{f(x_i)\leq M}}\sum_{i=1}^N \delta_{x_i}I_{f(x_i)\leq M} \overset{D}{\rightarrow} Law(X|f(X)\leq M),$$</span> (here I've assume that <span class="math-container">$N$</span> was large enought, and <span class="math-container">$f$</span> was nice enough so that we're not dividing by <span class="math-container">$0$</span>).</p> <p><strong>Question</strong> My question is, if <span class="math-container">$f$</span> is instead a continuous functional <span class="math-container">$f:\mathscr{P}(\Omega,\mathcal{F})\rightarrow \mathbb{R}$</span>, then can it be used to do the acceptance/rejection? </p> <p>Here, <span class="math-container">$\mathscr{P}(\Omega,\mathcal{F})$</span> is the set of probability measures on <span class="math-container">$(\Omega,\mathcal{F})$</span>. </p> https://stats.stackexchange.com/q/380253 1 Posterior of $\text{Normal}(\theta,1)$ with a Cauchy prior distribution shuvam agrawal https://stats.stackexchange.com/users/223879 2018-12-04T13:25:41Z 2018-12-10T21:49:24Z <p>If <span class="math-container">$X \sim N(\theta,1)$</span> with Cauchy as robust prior</p> <p><span class="math-container">$$\pi(\theta) = \frac{1}{\pi(1+\theta^2)} \qquad -\infty &lt; \theta &lt; \infty$$</span></p> <p>What will be the posterior distribution when Cauchy is <span class="math-container">$(-2 &lt; \theta &lt;2)$</span>. I tried when <span class="math-container">$C(0,1)$</span> </p> <p>(2) How to describe a rejection sampler to simulate samples of <span class="math-container">$\theta$</span> from <span class="math-container">$\pi$</span>(<span class="math-container">$\theta$</span>|x), with <span class="math-container">$\pi$</span>(<span class="math-container">$\theta$</span>) as the proposal distribution and same how to do it in R</p> <p>So please help to figure out.</p> https://stats.stackexchange.com/q/358369 1 Understanding the Delayed Rejection Metropolis algorithm (Mira, 2001a) wobertson https://stats.stackexchange.com/users/211819 2018-07-22T03:56:18Z 2018-07-25T05:13:59Z <p>I'm having trouble understanding the algorithm as briefly described <a href="http://helios.fmi.fi/~lainema/dram/" rel="nofollow noreferrer">here</a>, and I can't find the original paper by Mira since it seems to be from some obscure print journal (Metron Volume 59).</p> <p>The first stage is typical, $$\alpha_1(x,y) = \min\left(1,\frac{N_1}{D_1}\right)$$ Where, $$N_1 = \pi(y)q_1(y,x)$$ $$D_1 = \pi(x)q_1(x,y)$$ $$x = \textrm{current value}$$ $$y = \textrm{proposed value}$$ $$\pi = \textrm{target distribution}$$ $$q_1(x,\cdot) = \textrm{distribution from which y is drawn}$$</p> <p>The second stage is </p> <p>$$\alpha_2(x,y,z) = \min\left(1,\frac{N_2}{D_2}\right)$$</p> <p>Where $$N_2 = \pi(z)q_1(z,y)q_2(z,y,x)[1-\alpha_1(z,y)]$$ $$D_2 = \pi(x)q_1(x,y)q_2(x,y,z)[1-\alpha_1(x,y)]$$</p> <p>Thanks to @Xi'an, I realized that I have to pay attention to the distributions $q_1$ and $q_2$ even if I assume the proposals are symmetric, because $q_1(z,y)$ is likely not equal to $q_1(x,y)$. The second thing that I realized is that "the second stage candidate is computed so that reversibility of the Markov Chain...is preserved", so I still don't get the intuition but I understand how this form came about.</p> <h3>Questions:</h3> <p>If somebody has some intuition I would appreciate it. I'm playing around with toy distributions now, things like what if $z = x$ and what if $z = x\pm \epsilon$.</p> <p>Also is $q_2(z,y,x)$ also not necessarily equal to $q_2(x,y,z)$ if we assume $q_1 \neq q_2$? The paper uses a smaller covariance for the second stage proposal. Is it like $q_1(y|z)q_2(x|y)$ vs. $q_1(y|x)q_2(z|y)$?</p> https://stats.stackexchange.com/q/345291 1 Metropolis-Hastings acceptance ratio for truncated proposal user469216 https://stats.stackexchange.com/users/198299 2018-05-09T13:22:21Z 2018-05-11T12:05:19Z <p>I have a proposal distribution for one parameter <code>theta_guess</code></p> <pre><code>theta_guess = guessleft(theta_accept(1,r-1), 0.01,0) </code></pre> <p>which is a left truncated normal (and thus non-symmetric) with inputs and output given by:</p> <pre><code>[guess]=guessleft(mu,sigma,a) </code></pre> <p>where <code>mu</code> is the mean, <code>sigma</code> is the std. deviation and <code>a</code> is the lower bound. Moreover, <code>theta_accept(1,r-1)</code> is last period's accepted theta because <code>r</code> is the iteration counter and <code>theta_accept</code> is a 1 x R vector (where R is the number of iterations to run in the M-H loop). </p> <p>I want to create a correction factor for the acceptance ratio. I am not sure however how to do it. I've tried:</p> <pre><code>c=truncated_normal_a(theta_guess,theta_accept(1,r-1), 0.01,0)/... truncated_normal_a(theta_accept(1,r-1),theta_guess, 0.01,0) </code></pre> <p>which is of course one. My problem is that I have two parameters, <code>mu</code> and <code>sigma</code>. <code>sigma</code> is fixed, but <code>mu</code> is not in the proposal since it depends on the last period's accepted parameter. So I have no idea what to put in <code>mu's</code> place when creating my correction factor. </p> https://stats.stackexchange.com/q/326351 9 Exact Sampling from Improper Mixtures πr8 https://stats.stackexchange.com/users/193742 2018-02-01T21:28:48Z 2018-02-08T07:36:42Z <p>Suppose I want to sample from a continuous distribution $p(x)$. If I have an expression of $p$ in the form</p> <p>$$p(x) = \sum_{i=1}^\infty a_i f_i(x)$$</p> <p>where $a_i \geqslant 0, \sum_i a_i= 1$, and $f_i$ are distributions which can easily be sampled from, then I can easily generate samples from $p$ by:</p> <ol> <li>Sampling a label $i$ with probability $a_i$</li> <li>Sampling $X \sim f_i$</li> </ol> <p>Is it possible to generalise this procedure if the $a_i$ are occasionally negative? I suspect I've seen this done somewhere - possibly in a book, possibly for the Kolmogorov distribution - so I'd be perfectly happy to accept a reference as an answer.</p> <p>If a concrete toy example is helpful, let's say I'd like to sample from $$p(x,y) \propto \exp(-x-y-\alpha\sqrt{xy})\qquad x,y &gt; 0$$ I'll then take $\alpha \in (0, 2)$ for technical reasons which should not matter too much, in the grand scheme of things.</p> <p>In principle, I could then expand this as the following sum:</p> <p>$$p(x,y) \propto \sum_{n=0}^\infty \frac{(-1)^n \alpha^n \left( \frac{n}{2} \right)! \left( \frac{n}{2} \right)!}{n!} \left( \frac{x^{n/2} e^{-x}}{\left( \frac{n}{2} \right)!}\right) \left( \frac{y^{n/2} e^{-y}}{\left( \frac{n}{2} \right)!}\right) .$$</p> <p>The $(x,y)$-terms inside the sum can then be independently sampled from as Gamma random variates. My issue is evidently that the coefficients are "occasionally" negative.</p> <p><strong>Edit 1</strong>: I clarify that I am seeking to generate <em>exact samples</em> from $p$, rather than calculating expectations under $p$. For those interested, some procedures for doing so are alluded to in the comments. </p> <p><strong>Edit 2</strong>: I found the reference which includes a particular approach to this problem, in <a href="http://www.nrbook.com/devroye/" rel="nofollow noreferrer">Devroye's 'Non-Uniform Random Variate Generation'</a>. The algorithm is from <a href="https://academic.oup.com/imamat/article/8/1/80/656084" rel="nofollow noreferrer">'A Note on Sampling from Combinations of Distributions', of Bignami and de Matteis</a>. The method is effectively to bound the density from above by the positive terms of the sum, and then use rejection sampling based on this envelope. This corresponds to the method described in @Xi'an's answer.</p> https://stats.stackexchange.com/q/324878 2 Using a Random number Generator to draw samples from a Cumulative Distribution function Patrick https://stats.stackexchange.com/users/192693 2018-01-24T17:57:25Z 2018-02-06T12:16:00Z <p>I am given a Rayleigh, distribution function:$$f(x)=\frac{1}{5}x\exp\left(\frac{-x^2}{10}\right)$$ with $x&gt;0$ and asked to:</p> <p>Use an appropriate random number generator algorithm to draw 500 samples from F(x).</p> <p>What I thought on doing is using the Aceptance-rejection method :</p> <ol> <li><p>Generate a rv $Y$ distributed as $G$.</p></li> <li><p>Generate $U$ (independent from $Y$ ).</p></li> <li>If $U \leq \frac{f(Y)}{cg(Y)}$ , then set $X$ $=$ $Y$ (“accept”) ; otherwise go back to 1 (“reject”).</li> </ol> <p>I thought that I will use the $\chi^2$ distribution as my $g(Y)$ with $k=1$ degrees of freedom. I made that decision on the fact that both functions have the same domain, namely $x\in(0,\infty)$ and their CDFs look "similar". Therefore : $$g(x)=\frac{x^{-\frac{1}{2}}\cdot\exp\left(-\frac{x}{2}\right)}{\sqrt{2}\Gamma\left(\frac{1}{2}\right)}$$ Then $$\frac{f(x)}{g(x)}=\frac{\sqrt{2}\Gamma\left(\frac{1}{2}\right)}{5}\cdot x ^{\frac{3}{2}}\cdot\exp\left(\frac{x}{2}-\frac{x^2}{10}\right)$$ And I found out that this function has a maximum at $$x=\frac{5+\sqrt{145}}{4}$$ which is around $4.26$. Hence $$\frac{f(x)}{g(x)}\leq c=4.26$$. But I also read that $c$ value has to be as "close" to 1 as possible and I think 4.26 is not "close" Is my calculation correct? Is it entirely wrong? Should I use different method for drawing that random samples? Thanks for any method</p> https://stats.stackexchange.com/q/324512 0 Proof of Rejection Sampling tzu https://stats.stackexchange.com/users/106604 2018-01-22T21:29:38Z 2018-01-23T23:35:08Z <p>I'm trying to go through the proof of rejection sampling and I found a paper <a href="http://web.tecnico.ulisboa.pt/~mcasquilho/CD_Casquilho/MC_Flury_ar.pdf" rel="nofollow noreferrer">ACCEPTANCE-REJECTION SAMPLING MADE EASY</a> which provides several helpful explanations. For Lemma 2, the paper claims that if $Z$ has a uniform distribution $A$, and let $B \subset A$ and then the conditional distribution of $Z$ given $Z \in B$ is uniform in $B$. However, it does not provide proof. Can anyone help? Thanks.</p> https://stats.stackexchange.com/q/316314 6 Sampling from Skew Normal Distribution deemel https://stats.stackexchange.com/users/20221 2017-11-28T11:54:19Z 2018-11-28T10:38:54Z <p>I want to draw samples from a <a href="https://en.wikipedia.org/wiki/Skew_normal_distribution" rel="nofollow noreferrer">skew normal distribution</a> as part of a matlab project of mine. I already implemented the CDF and PDF of the distribution, but sampling from it still bothers me.<br> Sadly, the <a href="http://azzalini.stat.unipd.it/SN/faq-r.html" rel="nofollow noreferrer">description of this process from the documentation of an R package</a> is riddled with dead links, so I did some reading on the process.</p> <p>One way of sampling from the distribution would be <code>inverse transform sampling</code>, which uses a uniform random variable $U\sim Unif(0,1)$ and involves solving</p> <p>$F(F^{-1}(u)) = u$</p> <p>with $F(x)$ being the CDF of the distribution we want to sample from. Since I don't know how to find the inverse of $F(x)$ myself, I did some searching, finding this question asked several times but not answered.</p> <p>Edit: <strong>another method</strong> to sample from the distribution would be <a href="https://en.wikipedia.org/wiki/Rejection_sampling" rel="nofollow noreferrer">rejection sampling</a>, however for that I need to find a distribution that</p> <ol> <li>I can draw samples from</li> <li>Has a pdf "which is at least as high at every point as the distribution we want to sample from, so that the former completely encloses the latter." (from the rejection sampling wiki article)</li> </ol> <p>I've plotted the skew normal distribution with $\xi=1,\omega=1.5,\alpha=4$ and its truncated version (truncated to [0,2.5] here). </p> <p><a href="https://i.stack.imgur.com/asXAR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/asXAR.png" alt="unrestricted and truncated skew-normal distribution"></a></p> <p>In my application of this, I will always truncate the distribution to a certain interval, so I'd need to find a distribution that 'contains' the SN pdf for (hopefully) all parameters.</p> <p>Any ideas how I could go about sampling from such truncated skew-normal distributions?</p>