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.0a0.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.0a0-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.0a0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (212.4 kB view details)

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

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

Uploaded CPython 3.14macOS 15.0+ ARM64

itrigamma-0.2.0a0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (210.4 kB view details)

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

itrigamma-0.2.0a0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (214.3 kB view details)

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

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

Uploaded CPython 3.13macOS 15.0+ ARM64

itrigamma-0.2.0a0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (221.6 kB view details)

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

itrigamma-0.2.0a0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (226.2 kB view details)

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

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

Uploaded CPython 3.12macOS 15.0+ ARM64

itrigamma-0.2.0a0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (207.6 kB view details)

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

itrigamma-0.2.0a0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (207.4 kB view details)

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

itrigamma-0.2.0a0-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.0a0.tar.gz.

File metadata

  • Download URL: itrigamma-0.2.0a0.tar.gz
  • Upload date:
  • Size: 93.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.2.0a0.tar.gz
Algorithm Hash digest
SHA256 6f52c3d9e512e768a9886166b1df1d5bb3dcfcd7561c6c29285ce35ef69c859e
MD5 4b8879d6a5a9fda49f6568ff44102204
BLAKE2b-256 0bb16317b10f837fdf87eef231007c82bca063bd3f1fa827729dbcaeeb87261d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 15d23a09923e5f36e590ecb62a85339164159f14e177e2adaeecd6747736905f
MD5 46281b0f720e722c2bc1dd5d7838b5b8
BLAKE2b-256 cc1dbcbee00c338acbf2a13a2ba25e77060173451119f8c1c3b387e5f5bc18e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.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.2.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.2.0a0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 37a649a688a26a297197ff124d97c6eed57cbb7f1d455399cc2f4dff3223cbcf
MD5 a922d96b94dc29fc2e13881ea9359bf4
BLAKE2b-256 ba4954b3e74f16f1c8c90815eb25355f4626ee98fb0b1ac7e24d3a8c261c10bb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9d7e6f1398076a72c0a2b8ad74d960172d0ee33917620bb0418cfeab26999c11
MD5 fe48a07445516fc1f7e0c848ebaeefe3
BLAKE2b-256 55f9e2575a664933a74c817699d967859678369fc5f5d5e7bfee4898d2111312

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 364a24a7ef84cb22d6f7b90716c5b87d1c5f88518f46309bd1029d11257354f0
MD5 f42cc0273322f499e47f378fc6f354ec
BLAKE2b-256 db3d07dfa574991199621ba460bf60a8700b12417d80968702cfbf83510dce7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.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.2.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.2.0a0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 dd8bbd21d16a78ad0e7877098e6beca04db880b69bf5beb6c1fabec62bec22c3
MD5 f49eaf87c672c0171665635f092036c6
BLAKE2b-256 4966774d9d84eefa46e027d8e6e8b8a48f1573afe24ad62c7f64321275a19bed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4760820ed8e1b1e3a5128ded14688ce3db1795f7dfc8463de8881e88f4f5e5a3
MD5 80cdf715e3b1fdf155a108d2e1f10425
BLAKE2b-256 1ee903a5e1e472c2006cde0c53d5c0541c6d7b5d4f63e1e26231c7848c845780

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eb93a34bdb200c54e62f116d8864693135e8fce816bea2cac8757f096289f502
MD5 3b9a314fae891272f21c376ea2620740
BLAKE2b-256 c787d00b0e99df0f1fcd0d724e18a0097df2fdd546056f4b2a1cb199011d52eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.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.2.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.2.0a0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 759bd61baba20b5093ef5c4e3de4a64056ae99fc9954402859f70c6bf2981a3c
MD5 c2856db4c4f8680395f29d7f56da87e8
BLAKE2b-256 fe755749e8afb606a55b4fb94832cfb04bd6866fc9f8a45cbeaff28fae683c64

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f1d29d196cbf22edcadbbaf47ff8ad87f9bdfff611db08a1d8a9d3d9a45fb4e2
MD5 7afaafa5fb93bc2e18b0b1c334467133
BLAKE2b-256 220e8f11caf5c4dd8dd99a38a23a12bc3946c64e4892f060590c910f0a2694e9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0fba454f8f9b9130426ace26a9d177d951f10cfc5ed42b1793f3b852a7863106
MD5 96efb1c25b5ccc017de84b5c301e6f48
BLAKE2b-256 585d2dd7758f35057362ff7a69e94f2a8fa2eb7edfaa55c65d6bae1a7cdf19d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for itrigamma-0.2.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.2.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.2.0a0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ccbb9e79ca9b84681474d8b426cf774318dafb466a5779bb9dbbcaeecd8e8e63
MD5 f8fa193667503d186b83c485df8f6cb0
BLAKE2b-256 dcc5685e610cf2900fb5a0477c4a1a70dfa64efa74a541f54950128b8026d31b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for itrigamma-0.2.0a0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 907a9424b33fe1eb805dd61d542b7d2ae5a47a21ec229da718d60a71b0cd15c9
MD5 b536a526fa85b67fb6010c5ce790ecd1
BLAKE2b-256 89528aae417b35ebc53da778ee2a196617b5d183dd7b40cade88639f6326cbb7

See more details on using hashes here.

Provenance

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