# commons-user mailing list archives

##### Site index · List index
Message view
Top
From Thomas Neidhart <thomas.neidh...@gmail.com>
Subject Re: [MATH] Estimate of the population mean given a sample
Date Wed, 11 Sep 2013 19:42:24 GMT
```On 09/11/2013 08:37 PM, email@thorstenschaefer.de wrote:
> We have a sample which comes from a binomial process with unknown probability. Is it
possible to get the likelihood of the population is larger than a user-specified value (with
e.g. 95% certainty) in commons-math?
> For example, given we have two samples:
> S1: we have 4 out of 5 successes
> S2: we have 80 out of 100 successes
>
> I would like to know the probability that the real mean is larger than 60% given one
of the samples above. Is there an easy way to calculate it?

Hi Thorsten,

there is not yet a binomial test available (would be a nice addition),
but you can calculate the requested values with the binomial distribution:

// create a binomial distribution with null hypothesis of p=0.6
BinomialDistribution s1 = new BinomialDistribution(5, 0.6);
System.out.println(1 - s1.cumulativeProbability(4-1));

// = 0.3369 > 0.05 significance level
// thus null hypothesis can not be rejected

BinomialDistribution s2 = new BinomialDistribution(100, 0.6);
System.out.println(1 - s2.cumulativeProbability(80-1));

// = 1.64e-5 < 0.05 significance level
// thus null hypothesis can be rejected
// the observed probability must be larger

Note: the - 1 is used to get the same results as with R binom.test
http://stats.stackexchange.com/questions/44125/is-there-an-error-in-the-one-sided-binomial-test-in-r

Best regards,

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org