Skip to main content

A dedicated inverse-trigamma function implementation over positive reals

Project description

itrigamma

A self-contained implementation of the inverse-trigamma function, $\psi'^{-1}$, for inference on log-gamma random variables, etc.

Written in C with fast 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

You can 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

This yields a shared library binary r_itrigamma.so. Load it within R using dyn.load("r_itrigamma.so").

Test (R)

Within R, you can then load the shared library and use base R's .Call for a simple wrapper,

dyn.load("r_itrigamma.so")

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

# Test
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.1.0a0.tar.gz (86.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.1.0a0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (143.9 kB view details)

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

itrigamma-0.1.0a0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (145.9 kB view details)

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

itrigamma-0.1.0a0-cp314-cp314-macosx_15_0_arm64.whl (32.3 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

itrigamma-0.1.0a0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (144.2 kB view details)

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

itrigamma-0.1.0a0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (146.9 kB view details)

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

itrigamma-0.1.0a0-cp313-cp313-macosx_15_0_arm64.whl (32.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

itrigamma-0.1.0a0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (151.3 kB view details)

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

itrigamma-0.1.0a0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (154.1 kB view details)

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

itrigamma-0.1.0a0-cp312-cp312-macosx_15_0_arm64.whl (32.8 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

itrigamma-0.1.0a0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (143.5 kB view details)

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

itrigamma-0.1.0a0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (144.7 kB view details)

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

itrigamma-0.1.0a0-cp311-cp311-macosx_15_0_arm64.whl (32.9 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

File details

Details for the file itrigamma-0.1.0a0.tar.gz.

File metadata

  • Download URL: itrigamma-0.1.0a0.tar.gz
  • Upload date:
  • Size: 86.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for itrigamma-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 48a13b6c1fc6caea651499991470b59cea2a393ab36c8554284fe33baf4deddc
MD5 e1a2d80f52c2187884e8cf30a7e24385
BLAKE2b-256 6c9deaea1924a815706a742122c065c44462fd2758e24254c8411f30f75c61ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0.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.1.0a0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6b2a137cc3e907741161ae88fcc47570fcd74253c10be82646b591eadaa4fc46
MD5 cd31e7b544d7d2fb15160e44220c6c0e
BLAKE2b-256 f2671cf46647fc2a1083cddc04b7fdcade858c694637d8f315b35b40c75a0851

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 7dcbb30edda91cce0aafcb4e866ee562d67a1dc08cc9866228420a80b83df755
MD5 a084772ef16911ff52e29b4407e7809e
BLAKE2b-256 6b19290f2cf98bdbc152ce91c14db20546a2e8bde6f461732e5c2dccc1a56c5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f995430e87a412fdbe7bc2b71a0804403d804a7cda1ce3ba4366f92fd5f1147b
MD5 f0c15d96d4bacbeb79d405fd2e6a610f
BLAKE2b-256 e04417e180cfbbb3f948d5ef7ed59109363ea4aa7170f21f1a72c2630b24ed3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ac3effd584ef55091228cc3d45b1e6a294127dafd564672aa035c6eebf1f6ba0
MD5 aba96a68f19e9e069637e235fbcbf78d
BLAKE2b-256 005d5f0dd12cb8b18da0cbdbfbc293529ff4f8fab8deab6398dc2f9bda9d3363

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 74156c5a51cc2d0c4743c7b2fc647362e42117b77a2a3f746e87231a4dcffe08
MD5 9fbf5fb3a9732cb092a6a93e3a1a5c22
BLAKE2b-256 cf1fae03d3ad877d77c101fe4abe880510c2cde74378d173fa070e01fcdc2172

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e339d7110260e25cbfdbd20feaac1a77e28ff5a04dfb4ce59b3842fb74954ff5
MD5 6d721c4a128a76f04842d771e60bb767
BLAKE2b-256 1e8cd3eed4022f63602d79359ace3d381c6eea23d97b3cca3764a279b74163db

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1263dcbc89db15d6ba5239a2c364b92ed0e6b76a12326fdb5de1b1efaa6c1c34
MD5 17128d175cfb0e218ce03643784c7b19
BLAKE2b-256 b9c6ef45994e7c005233d5cf3ef3f44759142f0d3ae710ded485ce5cd61126d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 abad2fd9eaa585e52a81f7f16ab7aaa49a3fe9d9bfe23165ef09b9ebe004729f
MD5 0dcb04d031ee7a736745259fe1911b69
BLAKE2b-256 f61064136e09a6c17fc720e6bf4191985af35cee0b5c8a48df6266487fc17479

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1e343971a9b7c05d313a965f82128b5f241fef4e1e0c435864b678e87e93f36c
MD5 e64be3e72fe840d90f911da6471e7c83
BLAKE2b-256 2ecc780d094607df2680d448a0cd375ccc8535d1457070ea90ae108ece42e801

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9eb6d093ffebdc6be7169dff2425e60ce101933e05196a17c276b7436c167b9d
MD5 065e82dc21c730ad0f75ec9572e2dd14
BLAKE2b-256 317b3209bf6938779d79ff2660a68384824633113748b8e07fba192c36a09984

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0901c42bf1dc740bf1190a78b295b051768907b54ea5393b9fb8934229c90f15
MD5 fa6a135d543803e134c7e40e268e1dbb
BLAKE2b-256 be235765306aa29f59f769834f88a2971db55ab1619a19580a461f77078eff04

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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.1.0a0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for itrigamma-0.1.0a0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 35bffa718eb0762b4caa1752f141d0443dae3f2cb41cb7bc2dea259d80a04cce
MD5 8afaa3e8da16a4eac6c0fa7073ae249e
BLAKE2b-256 e76d204a609e2cc8bf96737e92bc9455f8865c2470b3ba26ef1aab3c6cb93ddf

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.1.0a0-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