eummd
Description
Computes maximum mean discrepancy two-sample test for univariate data using the Laplacian kernel. It is also possible to compute the p-value using permutations. Also includes implementation for computing the robust median difference statistic 'Q_n' from Croux and Rousseeuw (1992) doi:10.1007/978-3-662-26811-7_58 based on Johnson and Mizoguchi (1978) doi:10.1137/0207013.
Installation instructions
Install using pip:
python3 -m pip install eummd
Methods are implemented in C++, and then called using Cython.
Functions
There are various functions for computing the maximum mean discrepancy (MMD).
eummd: efficient univariate MMD with the Laplacian kernel, O(n log n) for a total of n samples.mmd: MMD (univariate/multivariate).meammd: multivariate efficient approximate MMD, using either random projections or interpoint distances.mediandiff: computes the median difference. If univariate, can be computed in O(n log n), otherwise is O(n^2).medianheuristic: the inverse of the median difference.
eummd and mmd return a dictionary with the items pval for
p-value (if specified), stat for the statistic and beta for the
kernel parameter value that was used. If beta is specified as a
non-positive number, then the median heuristic will be calculated.
Examples:
from eummd import eummd
from eummd import mediandiff
X = np.array([7.1, 1.2, 4.3, 0.4]).astype(np.float64)
Y = np.array([5.5, 2.6, 8.7]).astype(np.float64)
beta = 0.1
# only computes statistic,
d = eummd(X, Y, beta, pval=False)
print(d['stat'])
# computes statistic and p-value, and used median heuristic for beta
d = eummd(X, Y, beta=-0.1, pval=True)
print("p-value for univariate data: ", d['pval'])
print("statistic for univariate data: ", d['stat'])
print("beta for univariate data: ", d['beta'])
# show median heuristic was used
print(1.0 / mediandiff(X, Y, fast=True))
# a multivariate example, using median heuristic for beta
X = np.array([[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]).reshape((6, 2))
Y = np.array([[13, 14, 15, 16], [17, 18, 19, 20]]).reshape((4, 2))
d = mmd(X=X, Y=Y, beta=-0.5, pval=True, kernel="Laplacian")
print("p-value for multivariate data: ", d['pval'])
print("statistic for multivariate data: ", d['stat'])
print("beta for multivariate data: ", d['beta'])
Metadata
Release files for eummd 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| eummd-0.0.2.tar.gz | 224.5 kB | Without provenance | Details for eummd-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| eummd-0.0.2-cp311-cp311-macosx_12_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 12.0+ ARM64 | Details for eummd-0.0.2-cp311-cp311-macosx_12_0_arm64.whl |
Total release size: 453.7 kB
Release files / eummd-0.0.2.tar.gz
| Download URL | eummd-0.0.2.tar.gz |
|---|---|
| Size | 224.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a932af282d03a0e07a80f304e8a8ee65281de0686ef864d01a47fd112717f46
|
|
BLAKE2b-256 checksum How to use checksums |
869075c71159f89fe5dbbf6281923eec3817d48814bbbe02c613b35fc9c8f080
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / eummd-0.0.2-cp311-cp311-macosx_12_0_arm64.whl
| Download URL | eummd-0.0.2-cp311-cp311-macosx_12_0_arm64.whl |
|---|---|
| Size | 229.2 kB |
| Tags | CPython 3.11 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
08c1d90285ce9d7a31a7acfb7e3b858d2f2420f50c7d382a434d960553152249
|
|
BLAKE2b-256 checksum How to use checksums |
919550f01023d975e344c85c39cfb650726f282f0e94e620689f4ea7eaa0701e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for eummd 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.