Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

An urn contains N balls numbered 1.2.3...N.

I draw at random n balls, one by one with replacement.

Let X the smallest number, the largest Y and S the sum of all the n numbers

How to compute:

-the probability P(X=x,Y=y) that X=x AND Y=y

-the probability that S=s

share|cite|improve this question
P(x) = 1/N^n [ (n-x+1)^n - (N-x)^] – Jean-Pierre May 12 '11 at 12:18

You should count the number of the "good" instances and divide by the total number of instances.
For the first question - if the smallest is $x$ and the largest is $y$, then you are writing words of length $n$ using only the symbols $x,x+1,...,y-1,y$ (why?). How many such words do you have?
For the second question - it's equivalent to counting the number of solutions to $X_1+...+X_n=s$ where $1\leq X_i\leq N$, and then dividing by the total number of words of length $n$ over $1,...,N$ (why?). As to finding the number of solutions to this equation: it's the same as the number of solutions to $Y_1+...+Y_n=s-n$ where $0\leq X_i\leq N-1$. This can be done with exclusion-inclusion principle.
The other question, in your second post, is very similar. You can use the same approach, but there each letter/value can appear only once.

share|cite|improve this answer
up vote 1 down vote accepted

Thanks to Dennis for his comments.

So, I think the answer to the first question is:

P(X=x,Y=y) = 1/(N^n) * [ (y-x+1)^n -2 (y-x)^n + (y-x-1)^n ]

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.