How to sample from a reconstructed pdf

39 Views Asked by At

Suppose, that we have a process that generates events. Subsequently these events are recorded and stored in a histogram. Say we have a source that emits particles and subsequently a histogram is build based on each individual particle's energy. Suppose further, that the bins of the histogram have varying widths, some being wider and some narrower. Following this process one can construct a spectral density $\phi(e_i)$ by counting how many times a certain energy falls within a particular histogram energy interval corresponding to a bin $e_{i-1},e_i$ with a width $$ \Delta_i=e_{i}-e_{i-1}. $$ This histogram represents a discrete pdf. A discrete pdf with bins of uniform width can be sampled by inverting the cumulative cdf given by $$ F_E(e)=\sum_{e_i\le e} \phi(e_i), $$
with the associated inverse cdf $$ F^{-1}(x)=\inf\{e:F(e)\ge x\} $$ The question is how to sample if the histogram's bins have varying widths. Namely, since the widths $\Delta_i$ of the bins are non uniform, should one sample from $$ \phi(e_i) \text{ or from } \frac{\phi(e_i)}{\Delta_i}. $$ With the associated pdfs $$ F_E(e)=\sum_{e_i\le e} \phi(e_i) \text{ or } F_E(e)=\sum_{e_i\le e} \frac{\phi(e_i)}{\Delta_i}. $$ I would appreciate your help.

1

There are 1 best solutions below

15
On

Use the distribution function $F(x)$ directly. Generate a random number $R$ and find the interval where $F(e_{i-1})\lt R\le F(e_i)$.