SAMPLE_PDF Name
SAMPLE_PDF Purpose
This function randomly samples a given probability density function.
Category
Statistics
Calling Sequence
Result = SAMPLE_PDF( Xpdf, Pdf, Nsample )
Input
Pdf: A vector of type floating point containing the probability density
function values.
Xpdf: A vector of type floating point containing the location of the
values in Pdf.
Nsample: A scalar of type integer containing the sampling size.
Keyword Parameters
-
Output
Result: A vector of type floating point containing the randomly sampled
locations.
Uses
pdf_to_cdf.pro
var_type.pro Procedure
This function randomly samples the quantiles of a given probability
density function.
Example
Define the PDF values and where they are.
pdf = [ 0.1, 0.25, 0.3, 0.25, 0.1 ]
xpdf = [ 0., 1., 2., 4., 5. ]
Sample from the PDF 1000 times.
result = sample_pdf( xpdf, pdf, 1000 )
The result should have sampled 0 about 0.1*1000 times, etc.
Modification History
Written by: Daithi Stone (stoned@atm.ox.ac.uk), 2003-09-25
Modified: DAS, 2011-04-13 (fixed bug by adding NORMALISE setting to call
to pdf_to_cdf.pro; modified documentation format)