PyFPT is Python/Cython package to run first-passage time (FPT) simulations using importance sampling. An FPT problem is about finding the time taken to cross some threshold during a stochastic process.
This package will let you numerically investigate the tail of the probability density for first passage times for a general 1D Langevin equation.
The tail of the probability density is investigated using the method of importance sampling, where a bias increases the probability of large FPTs, resulting in a sample distribution, which are then weighted to reproduce the rare events of the target distribution. This allows very rare events (normally needing supercomputers) to be simulated efficiently with just your laptop!
Note, it was originally developed to find the local number of e-folds in slow-roll stochastic inflation. As such, analytical functionality is also included for this particular problem in the analytics module.
You can find the latest documentation on PyFPT's ReadTheDocs page.
As PyFPT uses Cython to optimise the stochastic simulations, a C-compilier is required for installation. Therefore, PyFPT does not currently run (future releases hope to address this issue) on Windows directly. Windows uses can either install PyFPT on a virtual machine or use a cloud-based service such as SciServer.
Mac and Linux user should be able to directly install PyFPT, as these operating systems have a C-compiler. Do feel free to raise an issue or contact us if you have any problems.
The following packages are required to run PyFPT
Many of which are included in common Python distributions like Anaconda. You can check which packages you already have installed with pip list
.
The documentation contains a user guide, whose code you can run yourself as interactive Jupyter notebook by downloading them.
The package can be installed by using the following command
pip install PyFPT
in the command line wherever you have Python installed.
You can also clone the PyFPT repository
git clone https://github.com/Jacks0nJ/PyFPT.git
to work on it locally. This would require compiling the Cython code (the .pyx
files) locally as well.
The PyFPT package can be used to investigate far into the tail of the probability density (down to 10^-34 and beyond!)
Or even deviations from Gaussianity!
In the above images `N' is the first-passage time in stochastic inflation.
See the user guides for details on how you can make these figures yourself!
PyFPT uses the unittest module to maintain the code. Almost all functions have some form of basic unit testing, which hopefully will be further developed as the project continues. The tests can all be found in the tests folder.
If unittest is installed, then the tests can be run locally using
pytest -v
This tests the functions which have been installed using pip. The easiest way to run the test suite on any modified functions is to upload to your branch to the repo, as (the uploaded) tests run every commit on the code uploaded.
See the open issues for a full list of known issues.
As different contributors continue to development the code, they will do so in several different branches. Therefore, it cannot be guaranteed that any branch, other than the main, will be fully functional at any one time. The main branch will be the correct release of the code available on PyPI and what you will install using pip.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)And we will review your request!
This is the initial release of PyFPT, so it is expected there will be some minor bugs. Feel free to either report by raising an Issue on Github, emailing joseph.jackson@port.ac.uk or fork the repository with your fix.
Your feedback is very much appreciated!
Distributed under an Apache-2.0 License. See LICENSE.txt
for more information.
Joe Jackson - joseph.jackson@port.ac.uk
Project Link: https://github.com/Jacks0nJ/PyFPT
We would like the following contributors to PyFPT, be it through physical understanding of first-passage time processes or help developing the package
The following resoucres were instrumental in developing the project into a package usable by the community: