# Rewriting bionomial sum using partial derivative

1. Aug 25, 2014

### Nikitin

Hi. Assume there's a probability $q$ for a guy to take a step to the right, and $p=1-q$ to take one to the left. Then the probability to take $n$ steps to the right out of $N$ trials is $P(n) = {{N}\choose{n} }q^n p^{N-n}$.

Now, what is $<n>$? My textbook in statistical physics says $<n> = \sum_{n=0}^N n{{N}\choose{n}} q^n p^{N-n} = q \frac{\partial}{\partial q} \sum_{n=0}^N {{N}\choose{n} }q^n p^{N-n} = q \frac{\partial}{\partial q} (q+p)^N = qN$

OK, fair enough.. But what about the fact that $(q+p)^N=1$ ? Shouldn't this mean you're taking the partial derivative of a constant, and thus it equals 0? What am I missing here?

Last edited: Aug 25, 2014
2. Aug 25, 2014

### HallsofIvy

Staff Emeritus
I can see no place where the "partial derivative" comes into this. Since p+ q= 1, your equation $(q+ p)^N= 1$ is simply $1^N= 1$. What variable are you taking the partial derivative with respect to?

3. Aug 25, 2014

### Nikitin

I'm taking it with respect to $q$.. Or, rather, my textbook is. I'm kind of confused as well.

The author wants to find $<n>$, the expected amount of steps to the right, by doing a "trick":

First he rewrites $<n>$ from $<n> = \sum_{n=0}^N n{{N}\choose{n}} q^n p^{N-n}$ into $<n> = q \frac{\partial}{\partial q} \sum_{n=0}^N {{N}\choose{n} }q^n p^{N-n}$

Then, since

$\sum_{n=0}^N {{N}\choose{n}} q^n p^{N-n} = (q+p)^N$

This must be true:

$<n> = \sum_{n=0}^N n{{N}\choose{n}} q^n p^{N-n} = q \frac{\partial}{\partial q} \sum_{n=0}^N {{N}\choose{n} }q^n p^{N-n} = q \frac{\partial}{\partial q} (q+p)^N =qN (q+p)^{N-1} = qN$

What I don't understand is how it's legal to take the partial derivative of something (in this case, $(q+p)^N$) that's equal to 1, and not get 0.

EDIT: I also fixed a type in OP: the $<n>$ was misplaced outside the summation sign.

Last edited: Aug 25, 2014
4. Aug 25, 2014

### disregardthat

Here you are treating q as a real variable, and p, n and N as constants. So basically you are defining a function f(q), and taking its derivative.

5. Aug 25, 2014

### Stephen Tashi

The textbook didn't have to enforce the condition p+q = 1 in order to do the trick.

For a function F(x,y) of two variables , there is a difference between ${ \frac{\partial F(x,y)}{\partial x}} _{|_{ x=q,\ y=1-q}}$ and ${ \frac{\partial F(x,1-x)}{\partial{x}}}_{|_{x=q}}$

6. Aug 25, 2014

### Ray Vickson

First, regard p and q as two separate variables when differentiating $P(n)$ wrt $q$ and summing over n. Then, after finishing you can finally put $q = 1-p$. This is not really any different from evaluating $\sum_{n=1}^N n 2^n$ by first differentiating $\sum_{n=1}^N n x^n$ wrt $x$, then putting in $x=2$ later.

7. Aug 26, 2014

### Nikitin

But how is this legal? You are differentiating something that is 1, yet you do not get 0? This seems very un-mathematical.

8. Aug 26, 2014

### disregardthat

The expression represents something, an expectancy value for a certain binomial situation where the probability is p.

But, the expression can also be treated differently. Assuming q is a real variable, it is no longer the expectancy value of anything, just a function. But, after plugging in q = 1-p, we find that we have the same thing.

Finding that the function is the derivative of a certain other function is just calculus. And this other function is easier to deal with, and we know its value at q = 1-p. By plugging, we see that we end up with the value we wanted to find. This is an example of using calculus just to calculate a certain value, and the calculation does not need any statistical interpretation. We just wanted to find the value.

9. Aug 26, 2014

### Ray Vickson

Which message are you responding to? Please use the Quote button---which is put there for a good reason.

Have you looked at my response (post #6)? That says it all, but since you seem to be missing something, here goes again. We certainly have
$$(x+y)^n = \sum_{k=0}^n {n \choose k} x^k y^{n-k}$$
for ANY $x$ and $y$. Do you accept that
$$x \frac{\partial}{\partial x} (x+y)^n = n x (x+y)^{n-1}?$$
Do you accept that
$$x \frac{\partial}{\partial x} \sum_{k=0}^n {n \choose k} x^k y^{n-k} = \sum_{k=0}^n k {n \choose k} x^k y^{n-k}?$$
If you accept these equations then you are forced---no choice--- to accept the equation
$$x n (x+y)^{n-1} = \sum_{k=0}^n k {n \choose k} x^k y^{n-k}$$
for ANY $x$ and $y$. What is now preventing you from putting $x=q, y = 1-q$?

10. Aug 26, 2014

### Nikitin

Ray: The calculus in itself was never the issue.

Guys, what confused me was that it's OK to define away the fact that p+q = 1 in the first moment, and then apply it in the next for convenience. But fair enough, I see things from a different perspective now. At the end of the day there's no mathematical reason you can't do it.

Last edited: Aug 26, 2014