Professional Documents
Culture Documents
Srihari
Sargur Srihari
srihari@cedar.buffalo.edu
1
Machine Learning
Srihari
Topics
1. Motivation
2. Ancestral Sampling
3. Basic Sampling Algorithms
4. Rejection Sampling
5. Importance Sampling
6. Sampling-Importance-Resampling
2
Machine Learning
Srihari
1. Motivation
• When exact inference is intractable, we need
some form of approximation
– True of probabilistic models of practical significance
• Inference methods based on numerical sampling
are known as Monte Carlo techniques
• Most situations will require evaluating
expectations of unobserved variables, e.g., to
make predictions
– Rather than the posterior distribution
3
Machine Learning
Srihari
Task
• Find expectation E[f] of some function f(z) wrt
distribution p(z)
– Components of z can be discrete, continuous or combination
– Function can be z, z2, etc
• We wish to evaluate
2. Ancestral Sampling
• If joint distribution is represented by a directed graph
with no observed variables
– a straightforward method exists
• Distribution is specified by
Logic Sampling
• Directed graph where some nodes are
instantiated with observed values
• Use ancestral sampling, except
– When sample is obtained for an observed value, if
they agree then sample value is retained and proceed
to next variable
– If they don’t agree, whole sample is discarded
• Samples correctly from posterior distribution
– However probability of accepting sample decreases
as no of variables increase and number of states that
variables can take increases
• This is a special case of Importance Sampling
– Rarely used in practice
7
Machine Learning
Srihari
Undirected Graphs
• No one-pass sampling strategy even for
case of no observed variables
• Computationally expensive methods such
as Gibbs sampling must be used
8
Machine Learning
Srihari
9
Machine Learning
Srihari
Geometry of Transformation
• Generating non-uniform random variables
where 0<y<oo
• In this case h(y)=1 - exp(-λy)
• If we transform using y = λ-1 ln (1 - z)
• Then y will have an exponential distribution
12
Machine Learning
Srihari
13
Machine Learning
Srihari
14
Machine Learning
Srihari
Generating a Gaussian
• For each pair z1,z2 evaluate the quantities
4. Rejection Sampling
• Transformation method depends on ability to
calculate and then invert indefinite integral
• Method feasible only for some standard
distributions
• More general strategy is needed
• Rejection sampling and importance sampling are
limited to univariate distributions
– Although not applicable to complex problems, they
are important components in more general strategies
• Allows sampling from complex distributions
16
Machine Learning
Srihari
17
Machine Learning
Srihari
20
Machine Learning
Srihari
22
Machine Learning
Srihari
5. Importance Sampling
• Evaluating expectation Proposal distribution
24
Machine Learning
Srihari
SIR Method
• Two stages
• Stage 1: L samples z(1),..,z(L) are drawn
from q(z)
• Stage 2: Weights w1,..,wL are constructed
– As in importance sampling
• Finally a second set of L samples are
drawn from the discrete distribution
{z(1),..,z(L) } with probabilities given by
{w1,..,wL}
25
Machine Learning
Srihari
Next Topic
• Markov Chain Monte Carlo (MCMC)
– Does not have limitation of Rejection sampling
and Importance Sampling in High
Dimensional Spaces
26