Kernel Stein Discrepancy
Project description
KSD-Metric
Kernel Stein Discrepancy
Example
import jax
from jax import numpy as jnp
from jax.scipy.stats import multivariate_normal
from ksd_metric.kernel import KernelJax
from ksd_metric.stein import KernelSteinDiscrepancyJax
from ksd_metric.target import TargetDistributionJax
from ksd_metric.utils import JaxKernelFunction
# Example usage of KernelSteinDiscrepancyJax with a multivariate normal distribution
# and the inverse multiquadric kernel function.
key = jax.random.PRNGKey(42)
dim = 2
mean = jnp.zeros(dim)
cov = jnp.eye(dim)
N = 10_000
x = jax.random.multivariate_normal(key, mean, cov, shape=(N,))
# Define the target distribution and kernel
log_target_pdf = lambda x: multivariate_normal.logpdf(x, mean=mean, cov=cov)
target = TargetDistributionJax(log_target_pdf=log_target_pdf)
kernel = KernelJax(lambda x, y: JaxKernelFunction.imq(x, y, jnp.eye(dim)))
ksd = KernelSteinDiscrepancyJax(target=target, kernel=kernel)
# Compute the kernel Stein discrepancy
print(ksd.kernel_stein_discrepancy(x))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ksd_metric-0.1.0.tar.gz
(5.9 kB
view details)
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 ksd_metric-0.1.0.tar.gz.
File metadata
- Download URL: ksd_metric-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77ac8a20c015e17f9d7e1f386d79c7716a39481d49b82dc769a7d938e4dc5477
|
|
| MD5 |
d27055282a2e92e06cc4a2544be5cba9
|
|
| BLAKE2b-256 |
c6b417d9a2534e798d2450580966cf619d7aea838d5867724757ec684f4b368b
|
File details
Details for the file ksd_metric-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ksd_metric-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19b8a9f29bd0e3404d81cb162a90dc68b72ae73cc9f0dd4b5488d8ec8ff4aeee
|
|
| MD5 |
f881ace61127eeb0954d81b3bad51bf0
|
|
| BLAKE2b-256 |
2976ab77c1455ad0e33a55f5785b24f5d09c412cdd0230581cffdf736aae3464
|