TransWikia.com

Create a random chi-Square independence distribution with a given p-Value

Data Science Asked by Cowboy_Patrick on June 6, 2021

I want to randomly create a table of data that has a predefined p-Value and chi-Value of a chi-square distribution.

For example this would have a p-Value of 1 on a chi-square independence test:

[[25,25],
 [25,25]]

Trying arround some random values I see that:

[[50,0],
 [30,20]]

has a p-Value of 2.02E-6 and a chi-Value of 22,56.

But how would I do it the other way arround? I have given p-Value of 0.05 for example from that I want to get a table with random values that has exactly that p-Value.

I already tried the following in python: np.random.default_rng().chisquare(dof,size_arr)*homogenous_expected_value specifically:
np.random.default_rng().chisquare(1,[2,2])*25
which is a good start and gives me something like this:

[[ 4.83409623 42.00549597]
 [ 5.17981502 20.08927103]]

or

[[ 11.59607448   1.58326752]
 [ 25.40019747 111.6858744 ]]

But as these are random values without and limits whatsoever the p-Values differ widely. For now I have no better option than to repeat this process until I get a table with a random distribution that is in a from me predefined desired range. But there must be a better way, right?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP