# Designing a statistical test

Question:

Let $U_1,U_2,\ldots$ be a sequence of independent uniform $U(0,1)$ random variables, and let $$N = \min\{n\geq 2: U_n > U_{n-1}\}$$ In other words, $N$ is the index of the first uniform random variable that is larger than the one that comes immediately before. For example, if the numbers are $0.2$, $0.1$, $0.3$ then $N = 3$. Then $$\mathbb{P}\{N > n\} = \frac{1}{n!}$$

a.) What is the density function of $N$, i.e., what is $\mathbb{P}\{N = n\}$?

b.) Design a statistical test for randomness. Explain how to go from a specific random number generator, to the final recommendation on whether the generator is accepted or not.

I normally don't post a question without somewhat of an attempted solution, but I am pretty lost here. For part b.) I was thinking of using chi-squared to test for randomness or plotting the pairs of triplets in the sequence of $u_1,\ldots,u_n$ that are generated from $U(0,1)$ but I am not sure if this is sufficient or not. Any suggestions are greatly appreciated.

a) $\mathbb{P}\{N = n\} = \mathbb{P}\{N > n-1\}-\mathbb{P}\{N > n\}$.

For (b): It seems that you should design some test based on $N$. Say, Region of rejection of Null-hypothesis can be smth like $\{N>c\}$.

Say, for given $\alpha>0$ define $n$ such that $\dfrac{1}{n!}\leq \alpha<\dfrac{1}{(n-1)!}$. Then get samples from random numbers generator and find the index $N$ of the first random variable that is larger than the one that comes immediately before. If $N\leq n$, accept generator. Otherwise reject. Type-I error of this test is $P(N>n|H_0)=\dfrac{1}{n!}\leq\alpha$.

You can try to design some other tests based on this r.v. $N$.

• Thank you, I was more so confused with b.) could you provide a more detailed answer? I can reward you with a 300 bounty once I can start a bounty – Wolfy Feb 23 '17 at 2:32
• @Wolfy Try to make your own efforts. The question sounds like a problem from the homework that needs your solution trials. In particular, can you find the $\alpha$-level for the test with rejection region $\{N>c\}$? – NCh Feb 23 '17 at 3:05
• It is not for homework, they are practice questions for preparing for the exam and I just don't really know where to begin with b.) if I had a solution that I could refer to then I would be able to solve questions like this – Wolfy Feb 23 '17 at 3:07
• Try firstly to design test with Rejection region as above. – NCh Feb 23 '17 at 3:09
• umm, you mean like region where $N > c$ such that $c$ is something that contradicts the way $N$ is defined, if that makes any sense – Wolfy Feb 23 '17 at 3:11