Simple fixed-point solver implemented in JAX
Project description
Fixed-point solver
FixedPointJAX is a simple implementation of a fixed-point iteration algorithm for root finding in JAX. The implementation allow the user to solve the system of fixed point equations by standard fixed point iterations and the SQUAREM accelerator, see Du and Varadhan (2020).
- Strives to be minimal
- Has no dependencies other than JAX
Installation
pip install FixedPointJAX
Usage
import jax.numpy as jnp
from jax import random
from FixedPointJAX import FixedPointRoot
# Define the logit probabilities
def logit(x, axis=1):
nominator = jnp.exp(x - jnp.max(x, axis=axis, keepdims=True))
denominator = jnp.sum(nominator, axis=axis, keepdims=True)
return nominator / denominator
# Define the function for the fixed-point iteration
def fxp(x):
s = logit(x)
z = jnp.log(s0 / s)
return x + z, z
# Dimensions of system of fixed-point equations
I, J = 3, 4
# Simulate probabilities
s0 = random.dirichlet(key=random.PRNGKey(123), alpha=jnp.ones((J,)), shape=(I,))
# Initial guess
x0 = jnp.zeros_like(s0)
print('-----------------------------------------')
# Solve the fixed-point equation
x, (step_norm, root_norm, iterations) = FixedPointRoot(fxp, x0)
print('-----------------------------------------')
print(f'System of fixed-point equations is solved: {jnp.allclose(x,fxp(x)[0])}.')
print(f'Probabilities are identical: {jnp.allclose(s0, logit(x))}.')
print('-----------------------------------------')
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fxp_jax-0.1.20.tar.gz.
File metadata
- Download URL: fxp_jax-0.1.20.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6954e3573c0d039fce4a255d080e4b5baadc5cb6f0f29ea3b819bbc30b85b436
|
|
| MD5 |
340ff5921a55db4152eaa8a1df562b62
|
|
| BLAKE2b-256 |
6b31c4f60a356741440aec10a1a0f367825399ed927becd7ac063fab3c480b05
|
Provenance
The following attestation bundles were made for fxp_jax-0.1.20.tar.gz:
Publisher:
cd.yml on esbenscriver/fxp-jax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fxp_jax-0.1.20.tar.gz -
Subject digest:
6954e3573c0d039fce4a255d080e4b5baadc5cb6f0f29ea3b819bbc30b85b436 - Sigstore transparency entry: 391101963
- Sigstore integration time:
-
Permalink:
esbenscriver/fxp-jax@a51c32359be8e1bb3958c3dc4959b3584443e283 -
Branch / Tag:
refs/tags/0.1.20 - Owner: https://github.com/esbenscriver
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@a51c32359be8e1bb3958c3dc4959b3584443e283 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fxp_jax-0.1.20-py3-none-any.whl.
File metadata
- Download URL: fxp_jax-0.1.20-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b55313bbeae28e5fffab0f80f16905b3d2cfb0250d52bbbf909f920d85f5e72
|
|
| MD5 |
bbd619250b55f3c20f4f54e5cb65f512
|
|
| BLAKE2b-256 |
58ecf3cf1f9bc30a17e4957c76ce9d4e834c7b80d61370f6dd479d72d79b8bfb
|
Provenance
The following attestation bundles were made for fxp_jax-0.1.20-py3-none-any.whl:
Publisher:
cd.yml on esbenscriver/fxp-jax
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fxp_jax-0.1.20-py3-none-any.whl -
Subject digest:
6b55313bbeae28e5fffab0f80f16905b3d2cfb0250d52bbbf909f920d85f5e72 - Sigstore transparency entry: 391101980
- Sigstore integration time:
-
Permalink:
esbenscriver/fxp-jax@a51c32359be8e1bb3958c3dc4959b3584443e283 -
Branch / Tag:
refs/tags/0.1.20 - Owner: https://github.com/esbenscriver
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@a51c32359be8e1bb3958c3dc4959b3584443e283 -
Trigger Event:
push
-
Statement type: