Problem setup: estimate a normal tail probability
The worked example asks for when and . The method searches within Normal proposals for an importance-sampling density suitable for this rare-event probability.
Patrick Laub · YouTube · 6:00
This 150-second segment demonstrates the improved cross-entropy method on the concrete problem of estimating for . The notebook first defines the zero-variance density as the conditional law of given the rare event, then obtains samples from by rejection sampling standard-normal draws and retaining only 152 exceedances. Those retained samples are used to fit a Normal importance-sampling proposal via maximum likelihood, with set to the sample mean and to the square root of the sample second central moment. The final cell draws samples from the fitted proposal, computes likelihood ratios times the event indicator, averages them to form , and reports a symmetric interval using `1.96 * oHat / sqrt(R)`. The printed result is an ICE estimate of about with half-width about , compared against a theoretical value of about . This 150-second clip explains the original cross-entropy method as an adaptive alternative to direct rejection sampling for rare-event estimation. Using a Jupyter notebook example, it estimates for X~Normal(0,1). The speaker first argues that directly sampling from an ideal proposal is usually too slow, then walks through the cross-entropy loop: draw samples from the current proposal, compute the 95% elite threshold, stop if it reaches gamma, keep elite samples, weight them by likelihood ratios, and update the proposal parameters. After convergence, the video performs a final importance-sampling estimate from the learned proposal and compares the result to the exact normal survival probability. This 60-second clip shows a notebook-based explanation of a cross-entropy rare-event estimator and then shifts to visualizing the proposal distributions generated by the method. The opening seconds display code that samples from a normal proposal, forms likelihood ratios, weights them by the indicator `(normals > γ)`, and prints a CE estimate with confidence bounds plus a theoretical value. The remainder explains that the CE method stored parameter vectors in a list `vs`; by looping over `vs` and evaluating normal PDFs on a grid `xs`, one can plot the whole sequence of proposal densities. The speaker also constructs the target curve `gStar` on the tail region `` using the known normalizing constant `l = stats.norm.sf(γ)`. The final executed figure shows several colored bell-shaped proposal curves shifting rightward and narrowing, together with a gray dashed vertical line marking the threshold.
Use the learning inspector for key ideas and moments, or open the reading tabs for the complete notes.
Generated from the video's visuals and explanation; not verbatim speech.
The segment opens with a Jupyter notebook headed `Improved cross-entropy method`. The visible problem statement says to estimate where and , using importance-sampling distributions of the form . The narration matches this exactly: it introduces a simple rare-event example and says the goal is to find the best importance-sampling density inside the normal family.
The presenter briefly scrolls upward to earlier cells showing Python imports and package versions. This part contains no new mathematics; it only establishes the computational environment (`numpy`, `scipy`, `matplotlib`) used for the rest of the notebook.
Returning to the main example, the notebook states the key conceptual step: to sample from , one can sample many ordinary values and keep only those with . The narration calls the zero-variance density and explains that it is precisely the distribution of conditioned on the rare event. The corresponding code creates a seeded generator, sets `**8`, draws `Xs = rng.normal(size=R)`, and filters with `Xs = Xs[Xs > gamma]`. This is explicitly named rejection sampling in the audio.
After execution, the output shows `Number of g* samples: 152` and `Wall time: 12.6 s`. The narrator emphasizes the rarity of the event by noting that from five by ten to the eighth raw samples, only 152 were retained. Mathematically, this output is the empirical consequence of conditioning a standard normal variable on exceeding the high threshold 5.
The next cell fits the importance-sampling proposal to those retained samples. The code computes `mu = np.mean(Xs)` and `sigma = np.sqrt(np.mean((Xs-mu)**2))`, while the narration describes this as finding maximum likelihood estimates for and given the samples. In other words, the Normal proposal is centered at the empirical mean of the exceedance sample and given the empirical root second central moment as its scale.
The final cell carries out the actual importance-sampling estimate. It resets `**6`, draws `normals = rng.normal(mu, sigma, R)` from the fitted proposal, and computes likelihood ratios as `stats.norm.pdf(normals, 0, 1) / stats.norm.pdf(normals, mu, sigma)`. These ratios are multiplied by `(normals > gamma)` to form `ests`, then averaged into `lHat`. The narrator says the improved cross-entropy algorithm is now complete and has supplied a good proposal distribution, after which they proceed with a normal importance-sampling estimation and print the estimate and confidence intervals.
The output block gives the numerical conclusion: `ICE estimate: 2.8499557494141556e-07 (+/- 8.28267698086911e-10)`, `ICE low bound: 2.841672802433268e-07`, `ICE upp bound: 2.8582381563950423e-07`, and `Theoretical: 2.866515718791933e-07`. The code also computes `oHat = ests.std()` and `widthCI = 1.96 * oHat / np.sqrt(R)`, so the printed interval is symmetric around `lHat`. The narration summarizes this as a rare-event probability of about with interval width on the order of , calling the precision impressively small.
The clip opens by contrasting the present method with a previous example. The speaker says that earlier approach “kind of cheated,” because the rare event was not very rare, so one could sample directly from by rejection sampling. The mathematical point is that direct sampling from an ideal proposal is not generally scalable for rarer events.
To avoid that bottleneck, the video introduces the original cross-entropy method. The core idea is adaptive: instead of guessing one perfect proposal immediately, build a sequence of proposal distributions that improve step by step until one is good enough for the rare-event region.
The notebook notation is then clarified. The vector `u` stores the parameters of the original distribution, here the standard normal , while `v` stores the current proposal parameters and `vs` records the sequence of proposals over iterations. This establishes the distinction between the target law and the adaptive sampling law.
Inside the loop, the algorithm first draws samples from the current proposal . It then computes the iteration threshold as the empirical quantile, equivalently the -quantile with . If , the adaptation stops; otherwise the samples above are treated as elites.
For those elite samples, the code forms likelihood ratios , where is the original standard normal density and is the current proposal density. These weights are essential: the update is not a plain average of elites, but a likelihood-ratio-weighted refinement of the proposal parameters.
The proposal is then updated to , with computed as a weighted average of the elites and computed from a weighted second-moment expression. The speaker describes this as a maximum likelihood update from elite samples, although the displayed variance formula centers on `eliteXs.mean()` rather than `mu_i`; that distinction should be checked against the intended textbook derivation.
After the cross-entropy loop finishes, the method switches from adaptation to estimation. One million fresh samples are drawn from the final proposal, likelihood ratios are recomputed, and the rare-event probability is estimated by averaging . This is a standard importance-sampling estimator built on the proposal discovered by the cross-entropy search.
The printed result gives a CE estimate of about with an approximate half-width around , compared with the theoretical value from `stats.norm.sf(5)`. The speaker emphasizes that the estimate is close in magnitude to the truth, but the confidence interval width is relatively wide on the order of .
The clip opens on a notebook cell implementing a cross-entropy style estimator. The visible code draws `**6` samples from a normal proposal with parameters `v[0]` and `v[1]`, computes likelihood ratios between normal densities with parameters `u` and `v`, multiplies those ratios by the rare-event indicator `(normals > γ)`, and then averages the result to obtain `fHat`. A confidence half-width is formed as `widthCI = 1.96 * oHat / np.sqrt(R)`. The output block reports `CE estimate: 2.8433488092847927e-07 (+/- 1.1057152778688466e-08)` and `Theoretical: 2.866515718791933e-07`, so the numerical example directly compares the Monte Carlo estimate with a theoretical benchmark.
The page then scrolls down to a new code cell whose purpose is geometric rather than numerical. This transition signals that the discussion is moving from a single estimated probability to the shape and evolution of the proposal distributions used by the method.
The speaker says, “Let’s visualize the sequence of proposal distributions that the CE method constructed.” The code below creates a grid `xs = np.linspace(-2, 6.5, 500)` and allocates `ys = np.empty((len(xs), len(vs)))`. The key mathematical idea is that each stored parameter vector `v` defines one normal proposal density, and evaluating that density on a common x-grid makes the different proposals directly comparable in one plot.
The explanation continues that during the CE run, the algorithm stored the `v` vectors in a list named `vs`. Therefore `vs` is not just auxiliary bookkeeping; it is the record of the adaptive sequence of proposal laws. Looping over `vs` reconstructs the path taken by the method through parameter space.
Inside the loop, the code uses `for i, v in enumerate(vs): ys[:,i] = stats.norm.pdf(xs, v[0], v[1])`. Mathematically, column `i` of `ys` is the function sampled on the grid `xs`, where denotes the normal PDF with mean `v[0]` and standard deviation `v[1]`. Plotting all columns together therefore overlays the entire sequence of proposal densities.
The speaker explicitly clarifies the programming construct: `enumerate` returns both the index `i` and the element `v`. This matters here because the index labels which iteration of the CE method produced which proposal vector, allowing the visual sequence to be ordered correctly.
The final part of the code cell constructs the target curve for comparison. First the grid is restricted to the tail region with `xOverGamma = xs[xs > γ]`. Then the normalizing constant is set to `l = stats.norm.sf(γ)`, and the plotted target density is `gStar = stats.norm.pdf(xOverGamma) / l`. In words, the target shown in the figure is the standard normal density conditioned to the region above `γ` and renormalized so that it integrates to one on that tail domain.
When the cell is executed, a figure appears below the code. It contains several colored bell-shaped curves corresponding to successive proposal distributions, plus a gray dashed vertical line marking the threshold `γ`. Visually, the curves move rightward and become narrower as the sequence progresses, illustrating how the cross-entropy method adapts its proposals toward the rare-event region. The normalized target curve is plotted on the same tail region, enabling direct comparison between the learned proposals and the target density.
The worked example asks for when and . The method searches within Normal proposals for an importance-sampling density suitable for this rare-event probability.
The notebook defines the ideal density as , i.e. the conditional distribution of given that the rare event occurs. This is the density that would make the importance-sampling estimator have zero variance.
Because is just the original law conditioned on , the video samples many standard-normal variates and keeps only those exceeding the threshold. In code this is `Xs = rng.normal(size=R)` followed by `Xs = Xs[Xs > gamma]`, with .
The executed notebook reports that only 152 samples survived the filter from the raw draws. This tiny acceptance count illustrates why direct simulation is inefficient for such a rare event.
The retained samples are used to fit the proposal distribution. The code sets `mu = np.mean(Xs)` and `sigma = np.sqrt(np.mean((Xs-mu)**2))`, and the narration identifies these as maximum likelihood estimates for the Normal proposal parameters.
With the fitted proposal, the final cell draws samples from , computes likelihood ratios , multiplies by the indicator of the event , and averages the result to obtain `lHat`.
The code computes `oHat = ests.std()` and `widthCI = 1.96 * oHat / np.sqrt(R)`, then prints bounds as `lHat-widthCI` and `lHat+widthCI`. Thus `widthCI` is the half-width of a symmetric interval around the estimate.
The printed estimate is about with half-width about , while the theoretical standard-normal survival probability at 5 is about . The narration highlights the very small interval width as evidence of the method's efficiency.
The video begins by saying the earlier example “cheated” because the rare event was not very rare, allowing direct sampling from by rejection sampling. For genuinely rare events, that route would generally take too long, motivating an adaptive method instead.
The original cross-entropy method constructs a sequence of proposal distributions that improve iteratively. The process stops once a proposal is good enough for estimating the rare-event probability .
`u` stores the parameters of the original distribution, here for the standard normal. `v` stores the current proposal parameters, and `vs` accumulates the successive proposal vectors during the cross-entropy iterations.
At each iteration, draw samples from the current proposal . Compute as the empirical -quantile, with , so this is the 95% threshold. If , stop; otherwise keep the samples above as elites.
For elite samples, compute weights as the ratio of the original density to the current proposal density. The speaker explicitly warns that these likelihood ratios must be used when updating the proposal parameters.
The next proposal mean and scale are computed from weighted elite summaries. The mean is a weighted average of elites; the scale is a weighted standard-deviation-type quantity. The spoken description calls this a maximum likelihood update, while the displayed variance formula uses `eliteXs.mean()` inside the squared deviation.
Once the cross-entropy loop ends, the converged proposal is used for ordinary importance sampling. Draw fresh samples from the final proposal, multiply the rare-event indicators by likelihood ratios, and average to estimate the tail probability.
For and , the displayed estimate is about with an approximate confidence half-width around , compared with the theoretical value from the normal survival function.
The opening notebook cell implements a rare-event estimator by sampling from a normal proposal, computing likelihood ratios between two normal densities, and multiplying by the indicator of the event `normals > γ`. The estimate is the sample mean of these weighted indicators, and the code also reports an approximate confidence half-width using `1.96 * oHat / np.sqrt(R)`. The printed output compares the estimate with a theoretical value.
The visible output gives `CE estimate: 2.8433488092847927e-07 (+/- 1.1057152778688466e-08)` and `Theoretical: 2.866515718791933e-07`. This example shows both the stochastic estimate and a deterministic benchmark for the same rare-event probability.
The speaker explains that as the CE method ran, it stored the parameter vectors `v` in a list named `vs`. Each element of `vs` represents one proposal distribution in the adaptive sequence, so looping over `vs` reconstructs the method’s evolution over iterations.
To visualize the proposals, the code builds a grid `xs = np.linspace(-2, 6.5, 500)` and fills a matrix `ys` whose columns are the normal PDFs corresponding to each stored vector `v`. The loop `for i, v in enumerate(vs): ys[:,i] = stats.norm.pdf(xs, v[0], v[1])` therefore converts parameter history into comparable density curves.
The narration explicitly states that `enumerate` is a convenience function returning both the index `i` and the element `v`. In this context, the index identifies the position of a proposal in the stored sequence, while `v` supplies its normal-distribution parameters.
The target curve plotted in the figure is built only on the tail region ``. The code first selects `xOverGamma = xs[xs > γ]`, then computes `l = stats.norm.sf(γ)`, and finally defines `gStar = stats.norm.pdf(xOverGamma) / l`. The speaker identifies `l` as the known normalizing constant in this simple case.
After execution, the figure displays multiple colored bell-shaped proposal curves together with a gray dashed vertical line at the threshold. The visual pattern shows the proposals shifting rightward and narrowing, illustrating adaptation toward the rare-event region and enabling comparison with the target density on the same axes.
Explore conditions, steps and evidence. Supplementary explanations are labeled separately from content shown in the video.
The notebook text states `gamma = 5` and the problem statement uses `P(X > gamma)`.
The narrator says the example estimates when a standard normal variable exceeds a large threshold gamma.
Threshold defining the rare event .
Real number; in this example .
The notebook states `X ~ Normal(0, 1)`.
The narrator refers to a standard normal variable.
X
Random variable whose exceedance probability is being estimated.
.
The notebook writes `( | X > gamma)`.
The narrator calls it the zero-variance density and explains it as the distribution of conditioned on the rare event happening.
The displayed notation uses `P( | X > gamma)` for a continuous random variable; the video does not discuss this notational issue.
g^*
Zero-variance importance-sampling density, equal to the conditional distribution of given .
Density over .
The code computes `mu = np.mean(Xs)` under the comment about fitting the IS proposal distribution.
The narrator says the proposal density is created by finding maximum likelihood estimates for mu and sigma.
Mean parameter of the fitted Normal importance-sampling proposal distribution.
Real number estimated from the retained samples.
The code computes `sigma = np.sqrt(np.mean((Xs-mu)**2))`.
The narrator says the proposal density is created by finding maximum likelihood estimates for mu and sigma.
Standard deviation parameter of the fitted Normal importance-sampling proposal distribution.
Positive real number estimated from the retained samples.
The first simulation cell sets `**8` before drawing `rng.normal(size=R)`.
The narrator says they simulate five by ten to the eighth samples of X's.
R
Number of raw standard-normal draws used for rejection sampling to obtain samples.
In the first cell, .
The final estimation cell sets `**6` before drawing `normals = rng.normal(mu, sigma, R)`.
The same symbol name `R` is reused with a different value in a later cell.
R
Number of samples drawn from the fitted importance-sampling proposal distribution.
In the final cell, .
The code computes `lrs = stats.norm.pdf(normals, 0, 1) / stats.norm.pdf(normals, mu, sigma)`.
The narrator says they proceed with a normal importance sampling estimation.
lrs
Likelihood ratios (importance weights) evaluated at proposal samples.
Positive real values for each sampled `normals` point.
The code computes `ests = lrs * (normals > gamma)`.
ests
Weighted indicator estimates for the rare event, equal to the likelihood ratio when the proposal sample exceeds and zero otherwise.
Nonnegative real array.
The code computes `lHat = ests.mean()` and prints `ICE estimate`.
The narrator says they print out the probability estimate L hat.
Importance-sampling estimate of , computed as the sample mean of `ests`.
Real number; printed value is approximately .
The code computes `oHat = ests.std()`.
Sample standard deviation of the weighted estimator array `ests`, used to form the confidence-interval half-width.
Nonnegative real number.
The code computes `widthCI = 1.96 * oHat / np.sqrt(R)`.
The narrator says the estimate has a confidence interval width in the order of ten to the minus ten.
The code labels this quantity `widthCI`, but numerically it is the half-width of a symmetric interval because it is added to and subtracted from `lHat`.
widthCI
Half-width of the reported confidence interval for the importance-sampling estimate.
Positive real number; printed value is approximately .
The notebook heading reads `Improved cross-entropy method` and the text states `Use the improved cross-entropy method to estimate P(X > gamma) where X ~ Normal(0, 1) and gamma = 5. Consider importance sampling distributions of the form Normal(mu, sigma^2).`
The narrator introduces a simple example estimating the probability that a standard normal variable exceeds a large threshold gamma, and says they will find the best importance sampling density within the family of normal distributions.
The segment defines the target quantity as the exceedance probability for a standard normal random variable, with , and restricts the importance-sampling proposal family to Normal distributions parameterized by .
The original distribution is standard normal.
The rare event is .
The proposal family is restricted to Normal distributions.
The notebook text states `First, to sample from ( | X > gamma), just sample lots of X's and extract those X > gamma.`
The narrator says the first step is to sample from the zero-variance density , which is the distribution of conditioned on the rare event happening.
The displayed formula uses `P( | X > gamma)` for a continuous variable; the video does not clarify this notation.
The video identifies the ideal importance-sampling density as the conditional distribution of given that the rare event occurs, i.e. given . This is the density that would make the importance-sampling estimator have zero variance.
Applies to the rare-event probability .
is supported only on the event region .
The code cell performs `Xs = rng.normal(size=R)` followed by `Xs = Xs[Xs > gamma]`.
The narrator says they can sample lots of X's and just keep those which exceed the threshold, and explicitly names this procedure rejection sampling.
Because is the conditional law of given , the video obtains approximate samples by drawing many raw standard-normal variates and retaining only those larger than the threshold. The retained subset is then treated as samples from .
Requires direct sampling from the original distribution .
The acceptance rule is .
The retained samples are used to estimate the parameters of the proposal distribution.
The code computes `mu = np.mean(Xs)` and `sigma = np.sqrt(np.mean((Xs-mu)**2))` under the comment `# Fit our IS proposal distribution to these g* samples`.
The narrator says they create the importance sampling proposal density by finding the maximum likelihood estimates for mu and sigma given these samples.
After obtaining samples from , the video fits a Normal importance-sampling proposal by setting its mean to the sample mean and its standard deviation to the square root of the sample second central moment of those retained samples.
The fitted proposal family is Normal.
The data used for fitting are the retained samples satisfying .
The estimator for uses division by , matching the code `np.mean((Xs-mu)**2)` rather than an unbiased sample variance.
The code computes `lrs = stats.norm.pdf(normals, 0, 1) / stats.norm.pdf(normals, mu, sigma)`, then `ests = lrs * (normals > gamma)`, then `lHat = ests.mean()`.
The narrator says the improved cross-entropy algorithm is complete and supplies a good importance sampling proposal distribution, after which they proceed with a normal importance sampling estimation and print the probability estimate L hat.
Using the fitted proposal density, the video estimates the rare-event probability by averaging likelihood ratios times the rare-event indicator over samples drawn from the proposal. This is the standard importance-sampling estimator specialized to the indicator event .
is the standard normal density.
is the fitted Normal proposal density.
Samples are drawn from , not from .
The event indicator is .
The code computes `oHat = ests.std()` and `widthCI = 1.96 * oHat / np.sqrt(R)`, then prints low and upper bounds as `lHat-widthCI` and `lHat+widthCI`.
The video does not verbally justify the use of 1.96 or state the normal approximation assumption behind the interval.
The notebook reports a symmetric interval around the estimate using 1.96 times the sample standard deviation of the weighted estimator divided by the square root of the number of proposal samples. The printed bounds are therefore `widthCI`.
Uses the sample standard deviation of `ests`.
Uses the same as the number of proposal samples in the final cell.
The interval is presented as a numerical summary; the video does not derive its coverage properties.
The speaker introduces the original cross-entropy method as a way around the problem that direct rejection sampling would take too long.
Markdown heading reads `Cross-entropy method` and states `Use the cross-entropy method to estimate P(X > gamma) where X ~ Normal(0, 1) and gamma = 5`.
The video presents the original cross-entropy method as an adaptive Monte Carlo strategy for rare-event probability estimation. Instead of sampling directly from a target proposal distribution, it constructs a sequence of proposal distributions that improve iteratively until one is good enough for estimating .
Used when direct sampling from a good proposal distribution is impractical or too slow.
Applied here to estimate a tail probability for a normal random variable.
The speaker says the idea is to construct a sequence of proposal distributions which get better and better, and to stop when we get a proposal distribution which is good enough.
The cross-entropy method builds a sequence of proposal distributions rather than relying on one fixed proposal. Each iteration refines the parameters so the proposal becomes more effective for the rare-event region, and the process stops once the proposal is deemed sufficient.
Requires an update rule for proposal parameters.
Stopping criterion is based on whether the iteration threshold reaches the target rare-event level.
Markdown states `Use the cross-entropy method to estimate P(X > gamma) where X ~ Normal(0, 1) and gamma = 5`.
Code sets `` and compares against `stats.norm.sf(gamma)`.
The worked example estimates the upper-tail probability for . The original distribution is encoded by ``, and the theoretical benchmark is computed with `stats.norm.sf(gamma)`.
Original distribution is standard normal.
Target event is exceedance of a fixed threshold .
The speaker says once CE has finished, they take the proposal distribution it has found and run a normal important sampling estimation.
Second code cell samples `normals = rng.normal(v[0], v[1], R)` and computes `ests = lrs * (normals > gamma)`.
After the cross-entropy loop identifies a proposal distribution, the video performs a separate importance-sampling estimate from that proposal. Samples are drawn from the converged normal proposal, likelihood ratios relative to the original distribution are computed, and the indicator of the rare event is averaged with those weights.
Uses the final proposal parameters stored in `v` after the CE loop.
Requires computing likelihood ratios between original and proposal densities.
Visible code computes `lrs`, then `ests = lrs * (normals > γ)`, then `fHat = ests.mean()` and `widthCI = 1.96 * oHat / np.sqrt(R)`.
Output prints `CE estimate`, `CE low bound`, `CE upp bound`, and `Theoretical`.
This clip shows a Monte Carlo implementation in which samples are drawn from a normal proposal, likelihood ratios between two normal densities are computed, and those ratios are multiplied by the indicator of the rare event `normals > γ`. The estimator is the sample mean of these weighted indicators, and an approximate confidence interval is built from the sample standard deviation divided by `sqrt(R)` and multiplied by `1.96`.
Samples are drawn from a normal proposal with parameters `v[0]`, `v[1]`.
Likelihood ratios use normal densities with parameters `u` and `v`.
The rare event is defined by the threshold `γ`.
`R` is the number of samples.
Speaker says, 'Let's visualize the sequence of proposal distributions that the CE method constructed.'
Code loops over `vs` and assigns `ys[:,i] = stats.norm.pdf(xs, v[0], v[1])`.
A plot later displays multiple colored bell-shaped curves shifting rightward and narrowing.
The speaker explains that the cross-entropy method stores each parameter vector `v` in a list called `vs`. By looping through `vs` and evaluating `stats.norm.pdf(xs, v[0], v[1])` on a common grid `xs`, one can plot the entire sequence of proposal densities generated during the algorithm.
`vs` contains the stored proposal parameter vectors.
`xs` is a fixed grid of x-values.
The narrator says: `The improved cross entropy algorithm is now complete, and it has supplied us with a good importance sampling proposal distribution.`
The claim that the proposal is `good` is qualitative and not accompanied by a formal criterion in this clip.
After fitting to the retained samples, the improved cross-entropy procedure has produced the importance-sampling proposal distribution used for estimation.
The rare-event model is and the target is .
Samples from have been obtained by rejection sampling.
A Normal proposal has been fitted by maximum likelihood to those samples.
For the worked example in this notebook segment.
The output block prints `ICE estimate: 2.8499557494141556e-07 (+/- 8.28267698086911e-10)` and `Theoretical: 2.866515718791933e-07`.
The narrator says the rare event has probability two point eight by ten to the minus seven and the estimate has a confidence interval width in the order of ten to the minus ten.
The spoken `two point eight by ten to the minus seven` rounds the displayed value; the exact displayed estimate is visible on screen.
For this example, the importance-sampling estimate of the rare-event probability is about , with reported half-width about , and the theoretical benchmark is about .
.
The proposal was fitted as described in the notebook.
The final estimate uses proposal samples.
For the specific simulation shown in the output cells.
The speaker says that in the earlier example they kind of cheated because the rare event was not very rare, so they could sample from g star directly using rejection sampling, but in general this would take too long.
When the rare event is sufficiently rare, directly sampling from the ideal proposal distribution by rejection sampling is computationally impractical.
The target event is rare enough that direct acceptance from the ideal proposal is inefficient.
General practical claim stated verbally without formal proof.
The speaker says the threshold for this iteration is set to be the 95% threshold of the X samples, and if this is above the overall goal of gamma, they stop iterating.
Code shows `gamma_i = np.quantile(Xs, 1-p)` and `if gamma_i >= gamma: break` with ``.
In this implementation, the iteration stops when the empirical elite threshold is at least the target threshold .
Samples `Xs` are drawn from the current proposal.
``, so ``.
The target threshold is `gamma = 5`.
For each iteration , if , then break.
The speaker says they update the v parameters to be the maximum likelihood estimates of the elite samples, and must weight the samples by their likelihood ratios.
Code shows weighted averages for `mu_i` and `sigma_i` using `weights=eliteLRs`.
The spoken justification says maximum likelihood estimates, but the displayed variance formula centers on `eliteXs.mean()` rather than `mu_i`.
The next proposal parameters are obtained from the elite samples using likelihood-ratio weights, with the mean updated by a weighted average and the scale updated by a weighted standard-deviation-type expression.
Elite samples are those with values above .
Likelihood ratios are computed as original density divided by proposal density.
Applied at each cross-entropy iteration before updating `v`.
Speaker says, 'since in this very simple case we do know its normalizing constant l'.
Code sets `l = stats.norm.sf(γ)`.
For the target distribution plotted here, the normalizing constant is known and equals `l = stats.norm.sf(γ)`.
The example uses a standard normal baseline density.
The target is restricted to the tail region ``.
In this specific simple case.
The notebook text says `to sample from ( | X > gamma), just sample lots of X's and extract those X > gamma`.
The narrator explains that because is the distribution of conditioned on the rare event happening, one can sample many 's and keep only those exceeding the threshold.
Start from the definition of the zero-variance density as the conditional law of given the rare event.
Notebook text and narration identify .
Draw a large batch of unconditioned standard-normal samples .
This is implemented by `Xs = rng.normal(size=R)`.
Retain only the samples satisfying .
This is implemented by `Xs = Xs[Xs > gamma]` and described verbally as keeping those which exceed the threshold.
Treat the retained samples as samples from .
By definition, conditioning a random variable on the event yields exactly the distribution of accepted draws under this rejection rule.
Rejection sampling from the original standard normal law produces samples from the conditional density needed to fit the proposal.
The code first computes `mu = np.mean(Xs)` and `sigma = np.sqrt(np.mean((Xs-mu)**2))`, then samples `normals = rng.normal(mu, sigma, R)`, computes `lrs`, `ests`, `lHat`, `oHat`, and `widthCI`.
The narrator says the proposal density is created by maximum likelihood estimates for mu and sigma, then says they proceed with a normal importance sampling estimation and print the estimate and confidence intervals.
The video does not explicitly write the likelihood function being maximized; the MLE interpretation is inferred from the narration plus the sample-mean and sample-second-moment formulas.
Use the retained samples to estimate the Normal proposal parameters by sample mean and sample root second central moment.
The code implements `mu = np.mean(Xs)` and `sigma = np.sqrt(np.mean((Xs-mu)**2))`; the narration calls these maximum likelihood estimates.
Draw samples from the fitted Normal proposal .
Implemented by `normals = rng.normal(mu, sigma, R)`.
For each proposal sample, compute the likelihood ratio using the standard normal density in the numerator and the fitted normal density in the denominator.
Implemented by `lrs = stats.norm.pdf(normals, 0, 1) / stats.norm.pdf(normals, mu, sigma)`.
Multiply each likelihood ratio by the indicator that the sample exceeds the threshold, forming `ests = lrs * (normals > gamma)`.
This is the importance-sampling integrand for the event probability .
Average `ests` to obtain `lHat`, and use its sample standard deviation together with `1.96 / sqrt(R)` to form the reported interval half-width.
Implemented by `lHat = ests.mean()`, `oHat = ests.std()`, and `widthCI = 1.96 * oHat / np.sqrt(R)`.
The fitted proposal is then used in a standard importance-sampling estimator, and the notebook reports both the point estimate and a symmetric confidence interval.
The speaker walks through the loop: sample from the current proposal, compute the iteration threshold, stop if it exceeds gamma, otherwise extract elite samples, compute likelihood ratios, and update v.
Code block shows the full loop from `for i in range(maxIter):` through `vs.append(v)`.
At iteration , draw a batch of samples from the current proposal distribution parameterized by `v`.
Observed in code as `Xs = rng.normal(v[0], v[1], R)` and described verbally as sampling from the current proposal distribution.
Compute the iteration-specific threshold as the empirical -quantile of the sampled batch.
Observed in code as `gamma_i = np.quantile(Xs, 1-p)`; the speaker identifies this as the 95% threshold because ``.
If the elite threshold has reached or exceeded the target rare-event level, terminate the adaptation loop.
Observed in code as `if gamma_i >= gamma: break` and stated verbally as the stopping rule.
Otherwise, select the elite samples, namely those current samples lying above the iteration threshold.
Observed in code as `eliteXs = Xs[Xs > gamma_i]` and described verbally as pulling out the elite Xs above gamma i.
For each elite sample, compute the likelihood ratio between the original distribution and the current proposal distribution.
Observed in code as `eliteLRs = stats.norm.pdf(eliteXs, u[0], u[1]) / stats.norm.pdf(eliteXs, v[0], v[1])`; the speaker explicitly calls these likelihood ratios.
Update the proposal mean as the weighted average of elite samples.
Observed in code as `mu_i = np.average(eliteXs, weights=eliteLRs)` and justified verbally as a maximum likelihood estimate from elite samples.
Update the proposal scale from a weighted second moment of the elite samples.
Observed in code as `sigma_i = np.sqrt(np.average((eliteXs-eliteXs.mean())**2, weights=eliteLRs))`.
Replace the current proposal parameters by the updated pair and record the new parameter vector in the history list.
Observed in code as `v = (mu_i, sigma_i)` followed by `vs.append(v)`.
The displayed algorithm iteratively adapts a normal proposal toward the rare-event region by thresholding samples, weighting elite points by likelihood ratios, and updating the proposal parameters until the elite threshold reaches the target level.
The speaker says once CE has finished, they take the proposal distribution it has found and run a normal important sampling estimation.
Second code cell computes `normals`, `lrs`, `ests`, `fHat`, `oHat`, and `widthCI`, then prints them along with `stats.norm.sf(gamma)`.
After adaptation, draw a fresh sample batch from the final proposal distribution stored in `v`.
Observed in code as `normals = rng.normal(v[0], v[1], R)` and described verbally as running a normal important sampling estimation.
Compute likelihood ratios for the fresh samples under the original versus final proposal densities.
Observed in code as `lrs = stats.norm.pdf(normals, u[0], u[1]) / stats.norm.pdf(normals, v[0], v[1])`.
Form the weighted rare-event contributions by multiplying each likelihood ratio by the indicator that the sample exceeds the target threshold.
Observed in code as `ests = lrs * (normals > gamma)`.
Estimate the rare-event probability as the sample mean of the weighted indicators.
Observed in code as `fHat = ests.mean()`.
Report an approximate 95% confidence half-width using the sample standard deviation of the weighted terms.
Observed in code as `oHat = ests.std()` and `widthCI = 1.96 * oHat / np.sqrt(R)`.
Compare the Monte Carlo estimate against the exact survival function of the standard normal distribution.
Observed in code as `print(f"Theoretical:\t{stats.norm.sf(gamma)}")`.
The final numerical estimate is produced by ordinary importance sampling from the converged proposal, with an approximate confidence interval and a direct comparison to the theoretical tail probability.
Code lines show sampling, likelihood-ratio computation, weighting by `(normals > γ)`, averaging, standard deviation, and CI width.
Output lines show numerical values for `CE estimate`, bounds, and `Theoretical`.
Draw `R` samples from the proposal normal distribution with mean `v[0]` and standard deviation `v[1]`.
Directly shown in the code cell.
Compute the likelihood ratio between the normal density with parameters `u` and the proposal density with parameters `v` at each sampled point.
Directly shown in the code cell.
Multiply each likelihood ratio by the indicator of the rare event `normals > γ`.
Directly shown in the code cell.
Take the sample mean as the probability estimate, the sample standard deviation for variability, and form an approximate 95% confidence half-width.
Directly shown in the code cell.
The printed output gives the numerical estimate, interval half-width, and theoretical comparison value.
Directly visible in the output block.
The visible code implements a likelihood-ratio-weighted Monte Carlo estimator and reports both the estimate and a theoretical comparison value.
Speaker says, 'If we loop through this list, we can calculate the PDF of each proposal distribution over some grid of x values.'
Code shows `xs = np.linspace(-2, 6.5, 500)`, `ys = np.empty((len(xs), len(vs)))`, and `ys[:,i] = stats.norm.pdf(xs, v[0], v[1])`.
Create a fixed grid of 500 x-values spanning roughly -2 to 6.5.
Directly shown in the code cell.
Allocate a matrix to store one column of PDF values per proposal distribution.
Directly shown in the code cell.
For each stored parameter vector `v`, evaluate its normal PDF on the same grid and store the result in column `i`.
Directly shown in the code cell and explained in the audio.
Plot all stored columns against the common x-grid, producing multiple overlaid proposal curves.
Directly shown in the code cell.
The plot of proposal distributions is obtained by evaluating each stored normal density on a shared x-grid and drawing all curves together.
Code shows `xOverGamma = xs[xs > γ]`, `l = stats.norm.sf(γ)`, `gStar = stats.norm.pdf(xOverGamma) / l`, and `plt.plot(xOverGamma, gStar)`.
Speaker says they will plot the target distribution `g star` because its normalizing constant `l` is known.
Restrict the plotting grid to the tail region where ``.
Directly shown in the code cell.
Compute the normalizing constant as the standard normal survival function at `γ`.
Directly shown in the code cell and identified in the audio as the known normalizing constant.
Normalize the standard normal density on the tail region by dividing by `l`.
Directly shown in the code cell.
Plot the resulting normalized target density over the tail region.
Directly shown in the code cell.
The target curve shown in the figure is the standard normal density restricted to `` and normalized by `l = stats.norm.sf(γ)`.
The notebook states the full worked example: estimate `P(X > gamma)` where `X ~ Normal(0, 1)` and `gamma = 5`, using proposals of the form `Normal(mu, sigma^2)`.
The narrator introduces this as a very simple example demonstrating the improved cross-entropy method.
Estimate for with using the improved cross-entropy method and Normal importance-sampling proposals.
.
.
Proposal family is .
First rejection-sampling batch size is .
Final importance-sampling batch size is .
Obtain a numerical estimate of the rare-event probability and a confidence interval, and compare with the theoretical value.
Set the threshold to .
Shown in the notebook cell `gamma = 5`.
Generate standard-normal samples and keep only those greater than .
Implemented by `Xs = rng.normal(size=R)` and `Xs = Xs[Xs > gamma]`; the narrator calls this rejection sampling.
The retained sample count is 152.
Output line reads `Number of g* samples: 152`.
Fit a Normal proposal to those 152 retained samples using their sample mean and sample root second central moment.
Implemented by `mu = np.mean(Xs)` and `sigma = np.sqrt(np.mean((Xs-mu)**2))`; narration identifies this as maximum likelihood estimation.
Draw samples from the fitted Normal proposal.
Implemented by `**6` and `normals = rng.normal(mu, sigma, R)`.
Compute likelihood ratios and weighted indicators, then average them to get the estimate.
Implemented by `lrs = stats.norm.pdf(normals, 0, 1) / stats.norm.pdf(normals, mu, sigma)`, `ests = lrs * (normals > gamma)`, and `lHat = ests.mean()`.
Report the estimate, interval bounds, and theoretical benchmark.
Output lines show `ICE estimate`, `ICE low bound`, `ICE upp bound`, and `Theoretical`.
The notebook prints `ICE estimate: 2.8499557494141556e-07 (+/- 8.28267698086911e-10)`, `ICE low bound: 2.841672802433268e-07`, `ICE upp bound: 2.8582381563950423e-07`, and `Theoretical: 2.866515718791933e-07`.
The estimate is compared directly against the theoretical standard-normal survival probability printed in the same output block.
Markdown states the task: estimate `P(X > gamma)` where `X ~ Normal(0, 1)` and `gamma = 5`.
First code cell implements the cross-entropy loop with `**5`, ``, `maxIter = 50`, ``, and ``.
Second code cell performs final importance sampling with `**6` and prints the results.
The speaker explains the loop, the stopping rule, the likelihood ratios, the parameter update, and the final importance-sampling estimate.
The exact intermediate proposal parameters after convergence are not shown numerically in the visible output within this clip.
The displayed variance update uses `eliteXs.mean()` rather than `mu_i`, creating a small mismatch with the verbal description of maximum likelihood estimation.
Use the cross-entropy method to estimate the rare-event probability where and .
Original distribution parameters ``.
Initial proposal ``.
Cross-entropy loop sample size `**5`.
Elite fraction ``.
Maximum iterations `maxIter = 50`.
Final importance-sampling sample size `**6`.
Target threshold `gamma = 5`.
Compute a Monte Carlo estimate of , obtain an approximate confidence interval, and compare with the theoretical value.
Initialize the proposal distribution to the original standard normal distribution.
Observed in code as `` after ``.
Run up to 50 adaptive iterations.
Observed in code as `for i in range(maxIter):` with `maxIter = 50`.
Draw 100,000 samples from the current proposal at each iteration.
Observed in code as `Xs = rng.normal(v[0], v[1], R)` with `**5`.
Set the elite cutoff to the empirical 95th percentile of the current sample batch.
Observed in code as `gamma_i = np.quantile(Xs, 1-p)` with ``; the speaker calls this the 95% threshold.
Stop adapting once the elite cutoff reaches the target threshold.
Observed in code as `if gamma_i >= gamma: break`.
Keep only the elite samples above the iteration cutoff.
Observed in code as `eliteXs = Xs[Xs > gamma_i]`.
Compute likelihood ratios between the original standard normal density and the current proposal density on the elite samples.
Observed in code as `eliteLRs = stats.norm.pdf(eliteXs, u[0], u[1]) / stats.norm.pdf(eliteXs, v[0], v[1])`.
Update the proposal parameters from weighted elite-sample summaries and store the new pair in the history list.
Observed in code as `mu_i = np.average(...)`, `sigma_i = np.sqrt(np.average(...))`, `v = (mu_i, sigma_i)`, and `vs.append(v)`.
After convergence, draw one million fresh samples from the final proposal distribution.
Observed in the second code cell as `normals = rng.normal(v[0], v[1], R)` with `**6`.
Estimate the tail probability by averaging likelihood-ratio-weighted rare-event indicators.
Observed in code as `lrs = ...`, `ests = lrs * (normals > gamma)`, and `fHat = ests.mean()`.
Report an approximate 95% confidence half-width from the sample standard deviation of the weighted terms.
Observed in code as `oHat = ests.std()` and `widthCI = 1.96 * oHat / np.sqrt(R)`.
The visible printed result is `CE estimate: 2.8433488092847927e-07 (+/- 1.1057152778688466e-08)`, with bounds `2.732772014979008e-07` and `2.9539203370716776e-07`, compared to `Theoretical: 2.866515718791933e-07`.
The example is checked against the exact standard-normal survival probability `stats.norm.sf(5)`, which is printed as `2.866515718791933e-07`; the speaker also remarks that the estimate is about `2.8 by 10 to the minus 7` but the confidence interval width is much wider.
Output block shows `CE estimate: 2.8433488092847927e-07 (+/- 1.1057152778688466e-08)`, `CE low bound: 2.732772014979008e-07`, `CE upp bound: 2.953920337016776e-07`, and `Theoretical: 2.866515718791933e-07`.
Code above computes these quantities from `normals`, `lrs`, and `ests`.
Estimate the rare-event probability using the displayed cross-entropy/importance-sampling style code and compare it with the theoretical value.
`**6`
Proposal samples drawn from `rng.normal(v[0], v[1], R)`
Likelihood ratio uses `stats.norm.pdf(normals, u[0], u[1]) / stats.norm.pdf(normals, v[0], v[1])`
Rare-event indicator is `(normals > γ)`
Obtain the CE estimate, confidence bounds, and theoretical comparison.
Form weighted rare-event contributions.
Shown in the code cell.
Average the weighted contributions to get the estimate.
Shown in the code cell.
Compute the approximate confidence half-width.
Shown in the code cell.
Read the reported estimate and uncertainty from the output.
Visible in the output block.
Read the theoretical comparison value from the output.
Visible in the output block.
CE estimate = 2.8433488092847927e-07 with half-width 1.1057152778688466e-08; theoretical value = 2.866515718791933e-07.
The printed low and upper bounds match `fHat +/- widthCI` as shown in the output block.
The screen scrolls upward from the main example to earlier import cells and then back down.
The narrator says they will quickly scroll up to show the import statements and package versions.
Jupyter notebook cells
import statements
version output block
View moves upward from the `Improved cross-entropy method` section to earlier cells.
Version information becomes visible.
View returns to the main example.
The mathematical problem statement remains the same before and after scrolling.
This visual action only exposes software dependencies and does not alter the mathematical content of the example.
After execution, the first simulation cell displays `Number of g* samples: 152` and `Wall time: 12.6 s`.
Code cell
output text
The cell changes from unexecuted to executed.
The number of retained samples appears as 152.
The threshold remains and the raw draw count remains .
The output quantifies how few samples survive the rare-event filter, motivating the need for an importance-sampling proposal.
The final cell output shows the ICE estimate, low bound, upper bound, theoretical value, and wall time.
Code cell
numeric output lines
The estimate and interval values become visible.
The theoretical benchmark appears below the estimate.
The same fitted proposal parameters from the previous cell are used.
The visual output confirms the numerical result of the improved cross-entropy workflow and its closeness to the theoretical tail probability.
The screen recording scrolls through a Jupyter notebook showing markdown text, Python code cells, and printed outputs.
Markdown heading `Cross-entropy method`.
Problem statement `Use the cross-entropy method to estimate P(X > gamma) where X ~ Normal(0, 1) and gamma = 5`.
First code cell implementing the adaptive loop.
Second code cell implementing final importance sampling.
Printed numeric outputs including CE estimate, bounds, theoretical value, and wall time.
The view begins near the top of the first code cell.
It scrolls downward to reveal the loop body and parameter update lines.
It continues to the second code cell and its printed output.
The final visible state shows the numerical estimate and theoretical comparison.
The target remains the same throughout: estimating for a standard normal variable.
The original distribution parameters remain ``.
The target threshold remains `gamma = 5`.
The visual progression mirrors the algorithmic order: first define the adaptive cross-entropy search, then use the resulting proposal for a final importance-sampling estimate and compare with theory.
A Jupyter notebook cell with Python code is visible above an output block containing numerical results and `Wall time: 428 ms`.
Python code cell
Output text block
Mouse cursor
The screen remains static on the code and output during the opening seconds.
The displayed code and numerical output do not change within this interval.
This segment establishes the implemented estimator and its numerical result before the notebook scrolls to the visualization code.
The page scrolls downward from the first code/output cell to a new code cell beginning with `xs = np.linspace(-2, 6.5, 500)`.
Notebook page
New code cell
Heading `Compare to crude Monte Carlo`
The first output block moves upward out of view.
A new code cell for plotting proposal distributions comes into view.
The heading `Compare to crude Monte Carlo` becomes visible below.
The interface remains a notebook with code cells and text headings.
The visual transition marks a shift from numerical estimation to geometric inspection of the proposal distributions.
After execution, a plot appears below the code cell.
The figure shows several colored bell-shaped curves and a gray dashed vertical line near x≈4.5.
Exact colors of every curve are not fully stable across frames, but multiple distinct colored curves are clearly present.
Multiple colored normal-like curves
Gray dashed vertical line
Coordinate axes
Plot frame
A blank area below the code is replaced by a rendered figure.
Several proposal curves appear together on the same axes.
A vertical dashed line marks the threshold region.
All curves are drawn over the same horizontal axis range.
The dashed vertical line remains fixed at the threshold location.
The figure visualizes how the stored proposal distributions evolve across iterations and situates them relative to the threshold and target region.
The code names the quantity `widthCI = 1.96 * oHat / np.sqrt(R)` and then prints bounds as `lHat-widthCI` and `lHat+widthCI`.
One might read the variable name `widthCI` as the total width of the confidence interval.
In the displayed code, the printed lower and upper bounds subtract and add the same quantity to `lHat`, so `widthCI` functions as the half-width of a symmetric interval.
The first cell sets `**8`; the final cell resets `**6`.
A reader may assume `R` denotes one fixed sample size throughout the notebook.
In this segment, `R` first denotes the number of raw standard-normal draws for rejection sampling, and later denotes the number of proposal draws for the importance-sampling estimate.
The speaker says, `In the example above, we kind of cheated.` and explains that because the rare event was not very rare, they could sample from g star directly using rejection sampling, but in general this would take too long.
One may think it is acceptable to sample directly from the ideal proposal distribution whenever a rare-event problem is presented.
The video explicitly warns that this worked only because the earlier example's rare event was not very rare; in general, direct rejection sampling from such a proposal would take too long, motivating the adaptive cross-entropy method.
The speaker says, `Don't forget we must weight the samples by their likelihood ratios.`
One might update the proposal parameters using the elite samples as though they were drawn from the original distribution directly.
The video stresses that the elite samples must be weighted by their likelihood ratios when computing the updated parameters.
Speaker says, 'Note, enumerate is just a nice convenience function in Python which gives us each element v in our list as well as its index i.'
One might think the loop variable pair in `for i, v in enumerate(vs)` is arbitrary or mathematically meaningful beyond indexing.
The speaker explicitly explains that `enumerate` returns both the index `i` and the corresponding element `v` from the list `vs`.
The notebook explicitly writes `( | X > gamma)`.
The narrator says is the distribution of conditioned on the rare event happening.
The zero-variance density is the conditional version of the original model specialized to the rare-event region .
The text says to sample from by sampling lots of 's and extracting those .
The narrator names this procedure rejection sampling.
Rejection sampling is the practical method used in the video to generate samples from the conditional density .
The fitting cell operates on `Xs`, the retained samples from the previous cell.
The narrator says the proposal density is created from these samples by maximum likelihood estimation.
The Normal proposal fit depends on the retained samples produced by the rejection-sampling stage.
The final cell samples from `rng.normal(mu, sigma, R)` using the previously computed `mu` and `sigma`.
The narrator says the improved cross-entropy algorithm has supplied a good proposal distribution and then they proceed with normal importance sampling estimation.
The importance-sampling estimator is applied using the proposal parameters fitted in the preceding step.
`oHat` and `widthCI` are computed directly from `ests`, whose mean is `lHat`.
The confidence-interval calculation is a summary attached to the importance-sampling estimator output.
The speaker says once CE has finished, they take the proposal distribution it has found and run a normal important sampling estimation.
Second code cell uses the final `v` in `rng.normal(v[0], v[1], R)` and then computes importance weights.
The adaptive proposal produced by the cross-entropy iterations is applied as the sampling distribution in the final importance-sampling estimator.
The speaker introduces the original cross-entropy method and then explains the loop mechanics.
The code implements exactly the iterative procedure described.
The general purpose of the cross-entropy method is instantiated in the displayed iterative loop for constructing better proposal distributions.
The second code cell prints both the CE estimate and `Theoretical: stats.norm.sf(gamma)`.
The worked numerical example applies the normal tail-probability setup and validates the Monte Carlo result against the exact survival function.
Speaker says the CE method stored the `v` vectors inside a list named `vs`.
Visualization code loops over `vs`.
The proposal-sequence visualization depends on the earlier CE procedure having stored the parameter vectors `v` in `vs`.
`gStar = stats.norm.pdf(xOverGamma) / l` is plotted with `plt.plot(xOverGamma, gStar)`.
Speaker says they will plot the target distribution `g star` because its normalizing constant `l` is known.
The normalized target density construction is applied in the same plotting workflow that visualizes the proposal distributions.
Speaker states that in this simple case the normalizing constant `l` is known.
Code uses `l = stats.norm.sf(γ)` to define `gStar`.
The definition of `gStar` in this clip relies on the stated fact that the normalizing constant `l` is known for the example.
The notebook defines `( | X > gamma)`.
The narrator explains that because is the conditional distribution given the rare event, one can sample many 's and keep only those above the threshold.
The code computes `mu = np.mean(Xs)` and `sigma = np.sqrt(np.mean((Xs-mu)**2))`.
The code computes `lrs`, `ests`, and `lHat = ests.mean()`.
The code computes `widthCI = 1.96 * oHat / np.sqrt(R)` and prints bounds around `lHat`.
The output prints the ICE estimate, bounds, and theoretical value.
The speaker explains that direct sampling from g star via rejection sampling was possible only because the rare event was not very rare, and would generally take too long.
The speaker says the threshold for this iteration is the 95% threshold of the X samples and that iteration stops if it is above gamma.
Code shows `gamma_i = np.quantile(Xs, 1-p)` and `if gamma_i >= gamma: break`.
The speaker says likelihood ratios are calculated between the original and actual distributions, and that the samples must be weighted by their likelihood ratios.
Code shows `eliteLRs = stats.norm.pdf(eliteXs, u[0], u[1]) / stats.norm.pdf(eliteXs, v[0], v[1])` and weighted averages for `mu_i` and `sigma_i`.
The speaker says they take the proposal distribution found by CE and run a normal important sampling estimation.
Code shows `ests = lrs * (normals > gamma)`, `fHat = ests.mean()`, and `widthCI = 1.96 * oHat / np.sqrt(R)`.
The speaker says the estimate is about 2.8 by 10 to the minus 7 but the confidence interval width is much wider.
Output shows `CE estimate: 2.8433488092847927e-07 (+/- 1.1057152778688466e-08)` and `Theoretical: 2.866515718791933e-07`.
Code shows `fHat = ests.mean()` and output labels `CE estimate`.
Covered · Problem statement and goal are introduced in audio and notebook text.
Covered · Screen scrolls to imports and version information; no new mathematics beyond software setup.
Covered · Definition of and rejection-sampling implementation, ending with output `Number of g* samples: 152`.
Covered · Fitting the Normal proposal by sample mean and sample second central moment, described as maximum likelihood estimation.
Covered · Final importance-sampling estimate, confidence interval, theoretical comparison, and concluding narration.
Covered · Opening narration explains why direct rejection sampling from g star was only feasible in the previous example and motivates the original cross-entropy method.
Covered · The speaker defines the cross-entropy idea as building improving proposal distributions and identifies the roles of u, v, and vs in the notebook code.
Covered · The loop body is explained line by line: sampling from the current proposal, computing the 95% threshold, stopping if it exceeds gamma, extracting elite samples, forming likelihood ratios, and updating v with weighted estimates.
Covered · Brief pause and scrolling transition between the end of the cross-entropy loop and the final estimation cell; no new mathematical content beyond the already covered loop.
Covered · The final importance-sampling estimator is described, the printed numerical estimate and confidence interval are discussed, and the result is compared with the theoretical tail probability.
Covered · Static notebook view showing the CE/importance-sampling style code and its numerical output.
Covered · Page scroll transitions from the estimator output to the visualization code cell.
Covered · Speaker explains looping over stored proposal vectors and constructing the normalized target density while the code cell remains visible.
Covered · Executed plot appears, showing multiple proposal curves and a dashed vertical threshold line.
Reviewed subject paths
The parameters of the Normal proposal distribution are chosen using maximum likelihood estimation. The mean is set to the sample mean of the retained samples, and the standard deviation is set to the square root of the sample second central moment of those samples.
Conditions: The proposal family is restricted to Normal distributions.; The data used for fitting are the retained samples satisfying .
The zero-variance density is the conditional distribution of the random variable given that the rare event occurs. It is the ideal importance-sampling proposal that would make the estimator have zero variance.
Conditions: The target quantity is the rare-event probability .; is supported only on the region .
The elite samples are weighted by likelihood ratios because they are drawn from the current proposal distribution, not the original target distribution. The likelihood ratio corrects for this discrepancy, ensuring that the updated proposal parameters accurately reflect the maximum likelihood estimates under the original distribution.
Conditions: Elite samples are those with values above the iteration threshold .; The likelihood ratios are computed as the original density divided by the proposal density.
Rejection sampling is used because is exactly the conditional distribution of given . By drawing many samples from the original standard normal distribution and keeping only those that exceed the threshold , the retained samples are distributed according to .
Conditions: Direct sampling from the original distribution is possible.; The acceptance rule is .
The iteration threshold is defined as the empirical -quantile of the current batch of samples drawn from the proposal distribution. The loop stops when this threshold is greater than or equal to the target rare-event threshold .
Conditions: Samples are drawn from the current proposal distribution.; The elite fraction parameter is set to 0.05.; The target threshold is .
The video states that the earlier example 'cheated' because the rare event was not very rare, making direct rejection sampling from computationally feasible. In general, for truly rare events, direct rejection sampling would take too long, which motivates the use of the adaptive cross-entropy method.
Conditions: The context is comparing the improved cross-entropy method to the original cross-entropy method.; The rare event in the earlier example had a relatively high probability.
The confidence interval is constructed as a symmetric interval around the point estimate. The half-width is calculated by multiplying 1.96 by the sample standard deviation of the weighted estimator array, and then dividing by the square root of the number of proposal samples.
Conditions: Uses the sample standard deviation of the weighted estimates.; The interval is presented as a numerical summary based on a normal approximation.
The final estimator is the sample mean of the likelihood ratios multiplied by the rare-event indicator. It is computed by drawing samples from the fitted Normal proposal, calculating the ratio of the standard normal density to the proposal density, multiplying by the indicator that the sample exceeds , and averaging the results.
Conditions: Samples are drawn from the fitted Normal proposal, not the original distribution.; The event indicator is .