Skip to content

OlivierBinette/LipSample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LipSample

MATLAB code to generate random variates following arbitrary Lipschitz continuous densities on the interval.

Example

Sample from the normal distribution (Lipschitz constant 0.25) restricted to [-5, 5].

sample = lipsample(@normpdf, 0.25, [-5 5], 10000000);

Plot the result.

pretty_hist(sample, [-5 5]);

Usage and functionalities

sample = lipsample(@f, L, [a b], m); Draws a sample of size m from the probability density function f which is Lipschitz continuous of order L on [a,b].

Notes

The function f does not have to be a normalized density, but it should be scaled to be near 1 as to improve efficiency. L is the Lipschitz constant of f, not of its renormalization.

Below you can see the envelope that was automatically constructed for the acceptance-rejection sampling of a triangular density (lipsample(@triangular, 4, [0 1], 1000000, 'N', 9);).

About

MATLAB code to sample arbitrary Lipschitz continuous densities on the interval.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages