Giter Site home page Giter Site logo

chi2comb-py's Introduction

chi2comb

Travis AppVeyor

This package estimates cumulative density functions of linear combinations of independent noncentral χ² random variables and a standard Normal distribution. Formally, it estimates P[Q<q], where:

Q = λ₁X₁ + ... + λₙXₙ + σX₀.

Xᵢ (𝚒≠𝟶) is an independent random variable following a noncentral χ² distribution with nᵢ degrees of freedom and noncentrality parameter λᵢ. X₀ is an independent random variable having a standard Normal distribution.

Install

It can be installed using the pip command

pip install chi2comb

Usage

Consider the following linear combination of four random variables:

Q = 6⋅X₁ + 3⋅X₂ + 1⋅X₃ + 2⋅X₀,

where X₁, X₂, and X₃ are noncentral χ² random variables having degrees of freedom n₁=n₂=1 and n₃=2 and noncentrality parameters λ₁=0.5 and λ₂=λ₃=0. Let us estimate P[Q<1]:

>>> from chi2comb import chi2comb_cdf, ChiSquared
>>>
>>> gcoef = 2
>>> ncents = [0.5, 0, 0]
>>> q = 1
>>> dofs = [1, 1, 2]
>>> coefs = [6, 3, 1]
>>> chi2s = [ChiSquared(coefs[i], ncents[i], dofs[i]) for i in range(3)]
>>> result, errno, info = chi2comb_cdf(q, chi2s, gcoef)
>>> result
0.050870657088644244
>>> errno
0
>>> info
Info(emag=0.6430413191446991, niterms=43, nints=1, intv=0.03462571527167856, truc=1.4608856930426104, sd=0.0, ncycles=21)

The estimated value is P[Q<1] ≈ 0.0587.

Problems

If you encounter any issue, please, submit it.

Authors

License

This project is licensed under the MIT License.

chi2comb-py's People

Contributors

horta avatar

Stargazers

Jan Lukas Späh avatar Marina Evers avatar  avatar Hamidreza Kamkari avatar Ayman Chaouki avatar Tim Poulsen avatar Jeff Hammerbacher avatar  avatar Yuanhua Huang avatar  avatar  avatar

Watchers

Tom White avatar  avatar James Cloos avatar

Forkers

likangxidian

chi2comb-py's Issues

Question

Can I in this package, or another package you are aware of, compute the pdf instead of the cdf?

How to handle error message

I find that when using chi2comb_cdf to test p-value when there are many small coefs ( > e-12) are input into ChiSquared, chi2comb_cdf tend to have error (not always). The error message is 1 and emag = 0. May I know what this means?

Recommendations on Python version and build process

Hello!

I stumbled upon this nice package, thanks a lot for your work. I was wondering if you have any recommendations on the Python version. As hinted at in #8, it does not seem possible to install this with pip using Python 3.10. I also failed to install the package with Python 3.8. Building from source (cloning and then pip install .) fails as well on when I am building it in a virtual python env or a fresh conda environment (either 3.10 or 3.8), error is attached. I am using MacOSX Venture 13.4.1. Any help would be very much appreciated.
Thank you!

error_build_from_source.txt

Problem with installation

Hello,
I encounter a problem with the installation.
Is a C compiler mandatory to use this code ?

THank you

incorrect output in some cases

Dear developer,
I encountered some unexpected result when applying this function:
2022-02-23
The 2.0 entries are due to the incorrect output "-1" of chi2comb_cdf.

I then checked the case when two chisquared random variables are in the combination, both having dof 1, ncent 0. Whenever the expected probability is smaller than around 0.225, it will output -1 as the result and the errno is 1. For example, chi2comb_cdf(1.25,[ChiSquared(coef=2, ncent=0, dof=1),ChiSquared(coef=3, ncent=0, dof=1)],0), which should output 0.2246805.

However this does not hold for all cases. I have not found any error when either of the dof is not 1. When the number of variables is at least 3, it also works well. As for the non-centrality parameters, error also occurs when the output is small, for example, chi2comb_cdf(5,[ChiSquared(coef=5, ncent=3, dof=1),ChiSquared(coef=3, ncent=0, dof=1)],0), which should be 0.1471154.

Could you please check why it goes wrong?

How to be add more precision on p-value

Dear developer:

I am using your method to perform multiple hypothesis tests. The test set is very big so I need to perform Bonferroni correction after getting all the p-values. However, most of the p-value I got using your algorithm are 0s. Therefore, I wonder if there is some way to increase the precision of the p-value so that I can pick the true signal after Bonferroni correction. Thank you!

Best
Boyang

installation issue in M1 MacMini

Hi,

I am trying to install chi2comb in M1 Mac mini running OSX 12.5, and running into a following build issues;

build/temp.macosx-12-arm64-cpython-310/chi2comb._ffi.c:569:10: fatal error: 'chi2comb.h' file not found
      #include "chi2comb.h"
               ^~~~~~~~~~~~
      1 error generated.
      error: command '/opt/homebrew/opt/llvm/bin/clang' failed with exit code 1

Am I missing some prerequisite libraries or some issues with an arm version of cpython ?

installation problems

Hey, I get a wheel error message after installation:

ERROR: Failed building wheel for chi2comb

Reinstallation of wheel does not help. Thanks

Installation via conda fails

Hello! First of all, I would like to thank you for the wonderful limix package.
Unfortunately, I've encountered an installation issue.
When I enter the "conda install -c conda-forge chi2comb" command, I get "PackagesNotFoundError" from conda. Could you, please, update the readme section for chi2comb package? Installing from source is not an option, because I don't have superuser access to this particular machine.
image

Citing this

Hello, I am publishing a work that uses this code. Could you please provide information on the approximation method used and any related citations?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.