lintsampler

lintsampler: Easy random sampling via linear interpolation - Published in JOSS (2024)

https://github.com/aneeshnaik/lintsampler

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

low-discrepancy-sequence numpy python random-generation random-sampling statistics
Last synced: 6 months ago · JSON representation

Repository

Efficient random sampling via linear interpolation.

Basic Info
Statistics
  • Stars: 12
  • Watchers: 3
  • Forks: 2
  • Open Issues: 1
  • Releases: 6
Topics
low-discrepancy-sequence numpy python random-generation random-sampling statistics
Created about 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md

lintsampler

Animation showing 'lintsampler' rendered in points.

Efficient random sampling via linear interpolation.

Test Coverage Status Documentation Status License: MIT status

When you have a density function, but you would like to create a set of sample points from that density function, you can use linear interpolate sampling. Using the evaluation of the density at the two endpoints of 1D interval, or the four corners of a 2D rectangle, or generally the $2^k$ vertices of a $k$-dimensional hyperbox (or a series of such hyperboxes, e.g., the cells of a $k$-dimensional grid), linear interpolant sampling is a technique to draw random samples within the hyperbox. lintsampler provides a Python implementation of this.

See the documentation for further details.

This package was also reviewed for the Journal of Open Source Software (JOSS). See the paper here and the review thread here.

Installation

Three ways of installing lintsampler:

  • pip: pip install lintsampler

  • conda: conda install -c conda-forge lintsampler

  • Simply cloning this repository.

Quickstart Example

If you have a density function, such as this multi-modal 1d pdf with the bulk of the density between -7 and 7,

```python import numpy as np from scipy.stats import norm

def gmm_pdf(x): mu = np.array([-3.0, 0.5, 2.5]) sig = np.array([1.0, 0.25, 0.75]) w = np.array([0.4, 0.25, 0.35]) return np.sum([w[i] * norm.pdf(x, mu[i], sig[i]) for i in range(3)], axis=0) ```

lintsampler can efficiently draw samples from it on some defined interval (here a 100-point grid between -7 and 7):

```python from lintsampler import LintSampler

grid = np.linspace(-7,7,100) samples = LintSampler(grid,pdf=gmm_pdf).sample(N=10000) ```

Making a histogram of the resulting samples and comparing to the input density function shows good agreement -- and we can do even better by increasing the resolution. Example 1d pdf with comparative histogram of sampled points.

See this page of the documentation for a more detailed explanation of this example.

Documentation

Complete documentation, including more example notebooks, is available at lintsampler.readthedocs.io/.

Contributing

The lintsampler maintainers welcome contributions to software, examples, and documentation. The maintainers are actively monitoring pull requests and would be happy to collaborate on contributions or ideas. If you have any requests for additional information or find any bugs, please open an issue directly.

Attribution

If using lintsampler for a research publication, please cite our paper.

License

lintsampler is available under the MIT license. See the LICENSE file for specifics.

Owner

  • Name: Aneesh Naik
  • Login: aneeshnaik
  • Kind: user

JOSS Publication

lintsampler: Easy random sampling via linear interpolation
Published
October 01, 2024
Volume 9, Issue 102, Page 6906
Authors
Aneesh P. Naik ORCID
Institute for Astronomy, University of Edinburgh, UK
Michael S. Petersen ORCID
Institute for Astronomy, University of Edinburgh, UK
Editor
Mehmet Hakan Satman ORCID
Tags
statistics numpy random variates random sampling low discrepancy sequence

GitHub Events

Total
  • Issues event: 3
  • Watch event: 8
  • Issue comment event: 3
  • Fork event: 1
Last Year
  • Issues event: 3
  • Watch event: 8
  • Issue comment event: 3
  • Fork event: 1

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 276
  • Total Committers: 2
  • Avg Commits per committer: 138.0
  • Development Distribution Score (DDS): 0.21
Past Year
  • Commits: 10
  • Committers: 2
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.2
Top Committers
Name Email Commits
Aneesh Naik 4****k 218
michael-petersen p****s@g****m 58

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 7
  • Total pull requests: 9
  • Average time to close issues: 3 months
  • Average time to close pull requests: 14 days
  • Total issue authors: 4
  • Total pull request authors: 3
  • Average comments per issue: 1.71
  • Average comments per pull request: 1.56
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 2
  • Average time to close issues: 3 months
  • Average time to close pull requests: 5 days
  • Issue authors: 2
  • Pull request authors: 2
  • Average comments per issue: 1.5
  • Average comments per pull request: 1.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • vankesteren (4)
  • charlieprior (1)
  • matt-graham (1)
  • WuShichao (1)
Pull Request Authors
  • michael-petersen (10)
  • aneeshnaik (6)
  • jbytecode (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 72 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 7
  • Total maintainers: 1
pypi.org: lintsampler

Efficient random sampling via linear interpolation.

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 72 Last month
Rankings
Dependent packages count: 9.7%
Average: 36.8%
Dependent repos count: 63.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

docs/requirements.txt pypi
  • sphinx_rtd_theme *