Skip to main content

Calibrated hypothesis test for the rank of a probability matrix estimated from multinomial samples.

Project description

probrank

A calibrated hypothesis test for the rank of a probability matrix.

Given an m x n matrix of probabilities (or cell proportions) estimated from N multinomial samples, probrank tests whether the matrix is consistent with rank at most k, following Ratsimalahelo (2001). Under the null H0: rank <= k the statistic is asymptotically chi-squared with (m - k)(n - k) degrees of freedom, so the p-value is (asymptotically) Uniform[0, 1] under H0. A small p-value is evidence that rank(M) > k.

The test is generic. One motivating application is causal discovery in mixtures of populations, where rank(M) <= k corresponds to two (super)variables being d-separated given a k-class latent source — but nothing in the test is specific to that use.

Install

pip install probrank

Usage

import numpy as np
from probrank import rank_pvalue, low_rank, rank_pvalue_from_data

p = rank_pvalue(M, k=2, N=5000)      # small p => rank > k
ok = low_rank(M, k=2, N=5000)        # True    => fail to reject rank <= k

data = np.random.randint(0, 2, size=(5000, 4))
p = rank_pvalue_from_data([0, 1], [2, 3], data, k=2)

d_separated is provided as a causal-discovery alias for low_rank.

Dependencies

numpy and scipy only.

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

probrank-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

probrank-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file probrank-0.1.0.tar.gz.

File metadata

  • Download URL: probrank-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for probrank-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ab4c01d6872256909d5998329e2464f6de1093bb19327af72d563da5c62a2210
MD5 8e356e20ff823cf5b8d4ba8dea84c48c
BLAKE2b-256 7269831919621ceee5108fd2ef64712ea0e2f96d4d43a4cf5b8873ac25cc93ab

See more details on using hashes here.

File details

Details for the file probrank-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: probrank-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for probrank-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ea5e3bcd32507f347304c6bf908c882f3b096e5037ed6fd3f797eabb5b6b5f1
MD5 e532d8b91b208ee780092e537a27b642
BLAKE2b-256 6964fc118017d795182e3cd210e37405dd9dafc7e23d0f2a9953cfbaee59b946

See more details on using hashes here.

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