Skip to main content

A dedicated implementation of inverse-trigamma and related functions written in C, with bindings for Python and R.

Project description

itrigamma

A self-contained implementation of the inverse-trigamma function and related polygammas for analyses involving log-gamma random variables, etc.

Written in C with basic interfaces/bindings for:

  • Python (python/citrigamma.pyx)
  • R (r/RCall_itrigamma.c)

Python

Install

  • Through PyPI/pip: pip install itrigamma
  • or from source: python -m build; python -m pip install .

Test

Copy+paste into shell:

python <<'TEST_PY'
import time, numpy as np, math
from itrigamma import itrigamma

x = np.random.default_rng(0).random(10_000_000)

t = time.perf_counter()
y = itrigamma(x)
dt = time.perf_counter() - t

print(f'Approx. {(x.size/dt) / 1_000_000:.1f} million evals per sec.')

KNOWN = [
    (1.0e-8, 100000000.499999999167),
    (0.05, 20.49583523915460591),
    (0.10, 10.491681821078422372),
    (0.20, 5.4834517798530476662),
    (0.50, 2.4599529483523074137),
    (1.00, 1.4262551202150789904),
    (2.00, 0.87666407746426017692),
    (5.00, 0.49616873470410694489),
    (10.0, 0.33508104437803564513),
    (20.0, 0.23077632915242632912),
    (50.0, 0.14337981235286147770),
]

for i, (x0, y0) in enumerate(KNOWN):
    assert math.isclose(itrigamma(x0), y0, abs_tol=1e-12)
    print(f'  --> check {i}:\t{(x0,y0)}\tGOOD')

TEST_PY

Output (Exact results vary wrt machine precision.)

TEST_PY
Approx. 8.2 million evals per sec.
  --> check 0:	(1e-08, 100000000.5)	GOOD
  --> check 1:	(0.05, 20.495835239154605)	GOOD
  --> check 2:	(0.1, 10.491681821078423)	GOOD
  --> check 3:	(0.2, 5.4834517798530475)	GOOD
  --> check 4:	(0.5, 2.4599529483523073)	GOOD
  --> check 5:	(1.0, 1.426255120215079)	GOOD
  --> check 6:	(2.0, 0.8766640774642602)	GOOD
  --> check 7:	(5.0, 0.49616873470410694)	GOOD
  --> check 8:	(10.0, 0.33508104437803565)	GOOD
  --> check 9:	(20.0, 0.23077632915242632)	GOOD
  --> check 10:	(50.0, 0.14337981235286149)	GOOD

R

Install (R)

Clone the repository:

git clone https://github.com/nolan-h-hamilton/itrigamma.git
cd itrigamma

Build with base R's r/utils/SHLIB utility as:

PKG_CPPFLAGS="-I$(pwd)/src" R CMD SHLIB r/RCall_itrigamma.c src/itrigamma.c -o r_itrigamma.so # r_trigamma.dll for windows

Test (R)

dyn.load("r_itrigamma.so")

# e.g., write a simple wrapper around .Call
itrigamma = function(x) .Call("r_itrigamma", x)


x_ = seq(1.0e-8, 100, length.out = 50)

y = itrigamma(x_)

plot(x_,y, type='l')

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

itrigamma-0.2.0a1.tar.gz (93.4 kB view details)

Uploaded Source

Built Distributions

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

itrigamma-0.2.0a1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (209.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

itrigamma-0.2.0a1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (212.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

itrigamma-0.2.0a1-cp314-cp314-macosx_15_0_arm64.whl (38.5 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

itrigamma-0.2.0a1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (210.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

itrigamma-0.2.0a1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (214.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

itrigamma-0.2.0a1-cp313-cp313-macosx_15_0_arm64.whl (38.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

itrigamma-0.2.0a1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (221.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

itrigamma-0.2.0a1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (225.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

itrigamma-0.2.0a1-cp312-cp312-macosx_15_0_arm64.whl (38.5 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

itrigamma-0.2.0a1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (207.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

itrigamma-0.2.0a1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (207.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

itrigamma-0.2.0a1-cp311-cp311-macosx_15_0_arm64.whl (38.6 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

File details

Details for the file itrigamma-0.2.0a1.tar.gz.

File metadata

  • Download URL: itrigamma-0.2.0a1.tar.gz
  • Upload date:
  • Size: 93.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for itrigamma-0.2.0a1.tar.gz
Algorithm Hash digest
SHA256 5c681c142fc8a1037edd47f94ab6caab830b50d801c833bf21c9c9a3bcfcaccd
MD5 7965a52ec4e036906317faeff8ef51bc
BLAKE2b-256 6bc167ea0175389a72e93fd2395f9cb01e181c719f0f6f5ceabe775e621d836a

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1.tar.gz:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2faa56efae190b857ad93e78ace12b9d08cb3125ace04e1237efd37583557739
MD5 59d22aeef8c5dae3f93d2257735162db
BLAKE2b-256 ba4073b7be810ed7277c8ed387af9932469133fe1001717b0095634a547962cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 35589a2f086754a54502025d8c1a314d1b78daba4fecc442a3a3e2dae4783f10
MD5 ffdf7c7aa3c1e667c7d07362e455ce9a
BLAKE2b-256 9c92eef6fab5991187126065614c6aa411d88ba03f12645b1023e3b337a8ede6

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ea4e6269eccdb2db1ba81f65e26c6566308a747b2e9fbab7f14bc530e5f5ba38
MD5 bc328fb024291fb31f42124119fcb5bf
BLAKE2b-256 efc20e5b5b2ffdf7a6c385a12426bbf66146f904bedc20ff11690fe075bb3665

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp314-cp314-macosx_15_0_arm64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b60f59967d25dcf709d55e89a3a137a0ce929df58d953413c237bba6efd45be2
MD5 e43fedd04c5ebedb69357c9b64f21f86
BLAKE2b-256 afb529348c42806ccebcf639cf2afc7531c6636c03348227a780391294e291e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ce82b6cf9298f8389882680dd4ce8739430a7614f59a683a326b057e77160963
MD5 bb615088d758769fd02d68eadfd51f59
BLAKE2b-256 fc2a17fdf86b64ce13dfb3c0aa479248a6dbaaf004e4822bedc77faea35607d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 bcecb9e506f2f655ace2df0a19f2e5dec0166b09f09e690066cc42b9fc7530b3
MD5 51e065f6faeab10e785babfcff0b6591
BLAKE2b-256 a71c8d05c7b772b3ed2acdb01e876a96a00596a802e17aefe7bda49b3fa6e8a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 077db2f551ee769fd596c8018ca46e14287d1f3a6924195c681ec915f586e7ed
MD5 3fb285fcd66c65f4a51c19d8642ed3b3
BLAKE2b-256 eabb91ec4435dce09c3b1d92bea17aa46ffaaa5bd65865a6fd5d0ba33e818e85

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 91750701e5ba9b8f6656987200f6b2c2a40f444b24b07bbc92295404554d6829
MD5 bcee19b72f6d3000368c33b771e1789b
BLAKE2b-256 ad955e35e3c1e8c3b17c2a64df787e6541728257d4a31738a11ebe74bae2ecd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 296311a76c0ac5a722a74cb0f3095603fc7b8715093e9732b0675ba8ca854f41
MD5 0a80529c4282befe5fe11975af0a88eb
BLAKE2b-256 10b635d1bdd00ae39f97148e92d6c8bb12c7eb276f73b33b665c2b91c9080b6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f92411f5723b4714b3a0090b68e9b651df554df15ad94e0d156e0e41b4d81919
MD5 f6ed0155813d2d5640a8c233e4c2b135
BLAKE2b-256 d71fc4cd84f90720d752df3d7dcc23a3a21d87f299a3848a2a029ee6fae600a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 f811dadf7a2220f1db6e0e8d31758038673c0a987f643d8f87bd5a2d35923b57
MD5 1f6773ca80699baab16bb77fe08d9135
BLAKE2b-256 f4e84c1954a9ff1c5c9181617e6caa0b58cc38292f15cced6a338a80278eb740

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file itrigamma-0.2.0a1-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.2.0a1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b6bb85c0cc2e1c67107ffa79e4556585035bcfd8df17ba3112bba020f05cef84
MD5 7814ecab829e18f6d9405d14eac1d6d5
BLAKE2b-256 922972dcf3c42ba98a369b798ed09e34d25cfa218b24adfff2fa9234254b3654

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.0a1-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: wheels.yml on nolan-h-hamilton/itrigamma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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