histogram_pdf_sample


histogram_pdf_sample, a MATLAB code which demonstrates how sampling can be done by starting with the formula for a PDF, creating a histogram, constructing a histogram for the CDF, and then sampling.

We would prefer to compute the CDF exactly by integration of the PDF, then invert the formula for the CDF to get a formula for random samples. But often the CDF is not invertible, and often it's not possible to get an exact formula for the CDF in any case. For such problems, the histogram approach may provide a relatively straightforward solution.

Licensing:

The computer code and data files described and made available on this web page are distributed under the MIT license

Languages:

histogram_pdf_sample is available in a Matlab version.

Related Data and Programs:

fem1d_sample, a MATLAB code which samples a scalar or vector finite element function of one variable, defined by FEM files, returning interpolated values at the sample points.

fem2d_sample, a MATLAB code which evaluates a finite element function defined on an order 3 or order 6 triangulation of a 2D region.

fem3d_sample, a MATLAB code which evaluates a finite element function defined on 3D tetrahedral mesh.

histogram_data_2d_sample, a MATLAB code which demonstrates how to construct a Probability Density Function (PDF) from a frequency table over a 2D domain, and then to use that PDF to create new samples.

histogram_pdf_sample_test

pdflib, a MATLAB code which evaluates Probability Density Functions (PDF's) and produces random samples from them, including beta, binomial, chi, exponential, gamma, inverse chi, inverse gamma, multinomial, normal, scaled inverse chi, and uniform.

prob, a MATLAB code which evaluates, samples, inverts, and characterizes a number of Probability Density Functions (PDF's) and Cumulative Density Functions (CDF's), including anglit, arcsin, benford, birthday, bernoulli, beta_binomial, beta, binomial, bradford, burr, cardiod, cauchy, chi, chi squared, circular, cosine, deranged, dipole, dirichlet mixture, discrete, empirical, english sentence and word length, error, exponential, extreme values, f, fisk, folded normal, frechet, gamma, generalized logistic, geometric, gompertz, gumbel, half normal, hypergeometric, inverse gaussian, laplace, levy, logistic, log normal, log series, log uniform, lorentz, maxwell, multinomial, nakagami, negative binomial, normal, pareto, planck, poisson, power, quasigeometric, rayleigh, reciprocal, runs, sech, semicircular, student t, triangle, uniform, von mises, weibull, zipf.

ranlib, a MATLAB code which produces random samples from Probability Density Functions (PDF's), including Beta, Chi-square Exponential, F, Gamma, Multivariate normal, Noncentral chi-square, Noncentral F, Univariate normal, random permutations, Real uniform, Binomial, Negative Binomial, Multinomial, Poisson and Integer uniform, by Barry Brown and James Lovato.

rejection_sample, a MATLAB code which demonstrates acceptance/rejection sampling.

walker_sample, a MATLAB code which efficiently samples a discrete probability vector using Walker sampling.

Source Code:


Last revised on 30 January 2019.