Skip to main content

Schechter galaxy luminosity distribution for NumPyro.

Project description

numpyro_schechter

Schechter galaxy luminosity distribution for NumPyro

Schechter distribution logo for numpyro_schechter

Python Versions Docs Status PyPI MIT License Tests


Overview

numpyro_schechter provides a NumPyro-compatible probability distribution for Bayesian inference with Schechter luminosity functions in absolute magnitude space.

Built for astronomers and statisticians, it includes a JAX-compatible, differentiable implementation of the upper incomplete gamma function, enabling stable and efficient modelling in probabilistic programming frameworks.


Parameter Constraints

Due to the custom normalisation logic, some constraints apply:

  • alpha must be real and non-integer.
  • The valid range of alpha + 1 depends on alpha_domain_depth. By default, alpha_domain_depth=3, which supports the domain -3 < alpha + 1 < 3.
  • To model more extreme values of alpha, increase the alpha_domain_depth parameter (see below).
  • The list of valid depths is fixed and can be queried programmatically:
    from numpyro_schechter import SchechterMag
    SchechterMag.supported_depths()
    # -> [3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30]
    

Installation

From PyPI:

pip install numpyro_schechter

From GitHub (latest development version):

pip install git+https://github.com/alserene/numpyro_schechter.git

Usage

Here is a minimal example showing how to use the SchechterMag distribution:

import jax.numpy as jnp
import numpyro
import numpyro.distributions as dist
from numpyro_schechter.distribution import SchechterMag

# Simulated observed magnitudes
mag_obs = jnp.linspace(-24, -18, 100)

def model(mag_obs):
    # Priors
    alpha = numpyro.sample("alpha", dist.Uniform(-3.0, 1.0))
    M_star = numpyro.sample("M_star", dist.Uniform(-24.0, -20.0))
    logphi = numpyro.sample("logphi", dist.Normal(-3.0, 1.0))

    # Custom likelihood using the SchechterMag distribution
    schechter_dist = SchechterMag(alpha=alpha, M_star=M_star, logphi=logphi, mag_obs=mag_obs)
    
    # Use numpyro.factor to inject the log-likelihood
    log_likelihood = jnp.sum(schechter_dist.log_prob(mag_obs))
    numpyro.factor("likelihood", log_likelihood)

# You can now run inference with NumPyro's MCMC
# e.g., numpyro.infer.MCMC(...).run(rng_key, model, mag_obs=...)

# Note: Sampling is not implemented for SchechterMag; it is intended for use as a likelihood in inference.

For detailed usage and API documentation, please visit the Documentation.


Development

If you want to contribute or develop locally:

git clone https://github.com/alserene/numpyro_schechter.git
cd numpyro_schechter
poetry install
poetry run pytest

License

This project is licensed under the MIT License - see the LICENSE file.


Contact

Created by Alice — aserene@swin.edu.au


Happy modelling!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numpyro_schechter-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numpyro_schechter-1.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file numpyro_schechter-1.0.0.tar.gz.

File metadata

  • Download URL: numpyro_schechter-1.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Darwin/23.6.0

File hashes

Hashes for numpyro_schechter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2a84ce28759495d703288fbba2dcfc97f41cf95cb72c97ac3ba430fab16cc14a
MD5 b0e7cf9c298f9f0d7d9d9bfda58e3ad1
BLAKE2b-256 cb9ebac5ba6601290f30147a696d54f8992b75d4fd5f15967ef81da5003923df

See more details on using hashes here.

File details

Details for the file numpyro_schechter-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: numpyro_schechter-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Darwin/23.6.0

File hashes

Hashes for numpyro_schechter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d95dfcdc75d6b21b643ab5f67818fe0ba1d99de66e79a697ef41798102a2dff
MD5 f288906d969104f585694f6e3d17c1c3
BLAKE2b-256 fe01acf14f03bab5b87fff7a20c49c0028c3b91686460369e48b821da6477455

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page