Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inverse transform sampler #71

Closed
wants to merge 660 commits into from

Conversation

Reneh107
Copy link
Contributor

A random sampler that uses an arbitrary CDF to generate the samples.

A uniform random sample is generated and the inverse CDF is used to generate the sample of the correct distribution.
The CDF is defined as a boost function and a root finder is used to obtain the inverse.

A unit test is included

magnific0 and others added 30 commits January 27, 2016 10:00
Add back optimization flags (were disabled to rule out problems). Space vs tab indentation.
Extra CMake modules for building boost within project.
Forcing code to use version of Boost that is automatically built.
Modifying tolerance of unit test to account for slightly larger numerical errors incurred during matrix inversion for certain compiler settings.
Tolerances updated for compatibility with MingW Tudat#10
Modification to address unit test failure Tudat#13 (comment)
With unit test fixes for Boost 1.60.
DominicDirkx and others added 23 commits September 5, 2016 14:30
…quadrature

Reneh107 add numerical quadrature
Fixed minor style issues in recently committed code
…y_distribution

Merging probability distribution code from Reneh107 and DominicDirkx into the repository. The Gaussian Cupola unit test is not ideal, but no better option has as yet been identified. A note has been added to the code to indicate this.
@Reneh107
Copy link
Contributor Author

Additional comment:

Sometimes you can get the following error:

unknown location(0): fatal error in "test_Inverse_Random_Sampler_2peaks": std::runtime_error: The Bisection algorithm requires that the values at the upper and lower bounds have a different sign, error during iteration.
C:\Tudat\tudatBundle_Reneh107\tudat\Tudat\Mathematics\Statistics\UnitTests\unitTestInverseTransformRandomSampler.cpp(170): last checkpoint

This mostly happens when you generate a large number of samples. I think that the reason is that the initial bounds of the root finder are too narrow, so the root lies outside the bounds. For example, for a Gaussian distribution this only happens in rare cases, because the probability is low that the sample has a value near the boundaries of the distribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants