UQpy icon indicating copy to clipboard operation
UQpy copied to clipboard

Merge pull request #245 from SURGroup/Development

Open connor-krill opened this issue 1 year ago • 0 comments

Development

Distribution Speed Up

Implemented faster methods for PDF, CDF, and inverse CDF of the uniform and normal distributions

Description

The default SciPy implementations of these methods have a lot of overhead. Using the closed-form methods for PDF, CDF, and inverse CDF provides significant speed up. Profiling 10,000 calls to each of the methods shows 2-5X speed up for each method.

Motivation and Context

This was first discussed in relation to the FORM algorithm, which we found to be spending the bulk of its time on PDF and CDF calls to the underlying distribution. Speeding up these distribution calls is beneficial for all algorithms that require a large number of evaluations, such as FORM, InverseFORM, and many of the sampling algorithms.

How Has This Been Tested?

Extensive tests have been added for both distributions. Tests cover all different input types (int, float, numpy array) and return the same types that SciPy would. Additionally, tests cover not-a-number and infinity and match the behavior of SciPy. For example, the normal PDF of NaN returns NaN, but the normal pdf of infinity returns 0.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help!

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [x] I have added tests to cover my changes.
  • [x] All new and existing tests passed.

connor-krill avatar Oct 17 '24 01:10 connor-krill