gonzalipto
gonzalipto

Reputation: 71

Scypy: Wilcoxon test: Compare distribution with a single value

I was applying the t-student test in order to evaluate whether or not a value was belonging to a given sample. Since I cannot assume normality, now I want to apply the Wilcoxon test from scypy.

Is it possible to compare a sample with a single value?

If I do: stats.wilcoxon(sample_array , single_value)

The code argues that the two arrays don't have the same length. I found in a forum that the one sample counterpart for the t-student using wilcoxon would be:

stats.wilcoxon(sample_array - single_value)

Is it correct? If not, do you know any alternative in order to perform a non parametric test in order to evaluate if a given value belongs or not to a sample distribution?

Upvotes: 0

Views: 1716

Answers (1)

Javier
Javier

Reputation: 420

You can't use wilcoxon for that. Those are to compare distributions.

You can't know whether or not a value may belong to a given sample. If your sample is large enough you can say that the probability of that happening is sum(sample_array>single_value)/len(sample_array) (or < for the other extreme).

You can compare the value to the MEAN or the MEDIAN of the population using bootstrapping:

import scikits.bootstrap as bootstrap
CIs = bootstrap.ci(sample_array, statfunction=np.mean,n_samples=100000)  
print(CIs)

If the value is within the CIs, then you can't reject that your value is the real mean (or median).

Upvotes: 1

Related Questions