How to do Statistical hypothesis testing Let $\Omega$ be the finite sample space and random variable $X$ is defined on $\Omega$ sending $x$ to $x$. The probability distribution function of $X$ is denoted by $f(x;p_1,..p_r)$ where $p_i$ are parameters.
Given a sequences $S=\{a_{i}\}_{i=1}^{n}$ where $a_{i} \in \Omega$, I want to know whether this sequence is sampled according to that probability distribution $(\Omega,f(x))$ or not. 
For example $\Omega = \{0,1\}$,
\begin{eqnarray}f(x;p)=
\begin{cases}
p, &x=0\cr 1-p, &x=1 \cr 0, &otherwise\end{cases},
\end{eqnarray}
$p=0.1$,$n=10$,$S=0100100011$, Then how to do Statistical hypothesis testing ? 
 A: We expect that the sequence has more or less one zero, because the xpectednumber  zeros is $10\cdot 0.1=1$. Since there are six zeros in your example we have the null hypothesis $H_0: p\leq 0.1$. And the corresponding alternative hypothesis is $H_1: p>0.1$
We need a significance level. Let´s say it is $\alpha=0.05$ 
The confidence level is $1-\alpha=0.95$. The random variable for the number of zeros in the sequence is binomial distributed, with $n=10$ and $p=0.1$ The sample is not sufficently large enough to approximate the binomial distribution by the normal distribution.
Thus we have to find the greatest  value of $x$ where
$$\sum_{i=0}^{x} {10 \choose i} \cdot 0.1^i\cdot 0.9^{10-i}<0.95$$
Not many attempts has to be made to find that $x=2$. 
The interval for not rejecting $H_0$ is $\{0,1,2\}$. The interval for rejecting $H_0$ is $\{3,4,5,6,7,8,9,10\}$  
Therefore we have to reject the null hypothesis at a signicance level of $5\%$. If the sample would have no ones up to two ones we could not reject the null hypothesis. But with this sample we have to reject the null hypothesis.
