text stringlengths 1 2.12k | source dict |
|---|---|
# Thread: Find the interval in which the function concave up??
1. ## Find the interval in which the function concave up??
The graph of the function
is concave up on the interval:
(-infinity,infinity)
None
(1,infinity)
(-infinity,0)U(1,infinity)
(0,infinity)
=======================
I solve the question and my answer is :
The graph is concave up on (-infinity,-0.5)U(0,infinity)
and I'm sure from my answer but my answer is not included in the choices
and When I use the graphics calculator the graph is concave up on all interval
So what is the correct answer??
2. You can use derivatives to answer this question
First you must find the critical points, take your first equation and differentiate and solve for 0
$f(x)=x^4+x^3+x$
$f\prime(x)=4x^3+3x^3+1$
Now that its differentiated solve for 0
$4x^3+3x^2+1=0$
$x(4x^2+3x+1)=0$
you a critical point at x = -1.5 and x = 0
now to find a graph is increasing you plug your critical points back in the derivative and if its <0 graph is decreasing >0 increasing
to find concavity you take second derivative and plug in critical points if
>0 then concave up and <0 concave down
the second derivative is
$12x^2+6$
plus in 0 and -1.5
plug 0 in and you see it is >0 so intervals from 0 to infinity is concave up
plug -1.5 it is also concave up because > 0 so from -inf. to -1.5
sorry for lack of work studying for finals
3. Originally Posted by sk8erboyla2004
You can use derivatives to answer this question
First you must find the critical points, take your first equation and differentiate and solve for 0
$f(x)=x^4+x^3+x$
$f\prime(x)=4x^3+3x^3+1$
Now that its differentiated solve for 0
$4x^3+3x^2+1=0$
$x(4x^2+3x+1)=0$
you a critical point at x = -1.5 and x = 0
now to find a graph is increasing you plug your critical points back in the derivative and if its <0 graph is decreasing >0 increasing
to find concavity you take second derivative and plug in critical points if
>0 then concave up and <0 concave down | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9719924777713886,
"lm_q1q2_score": 0.8608271262277404,
"lm_q2_score": 0.8856314692902446,
"openwebmath_perplexity": 912.2231368772646,
"openwebmath_score": 0.8478879332542419,
"tags": null,
"url": "http://mathhelpforum.com/calculus/87199-find-interval-function-concave-up.html"
} |
>0 then concave up and <0 concave down
the second derivative is
$12x^2+6$
plus in 0 and -1.5
plug 0 in and you see it is >0 so intervals from 0 to infinity is concave up
plug -1.5 it is also concave up because > 0 so from -inf. to -1.5
sorry for lack of work studying for finals
but I would to remind you that in concavity test we do the following :
1)find first derivative
2)find second derivative
3)set first derivative=0 and solve for x
4)usinig the zeros of second derivative we will set open interval and select test number within each interval to determine the type of concavity ..
4. Originally Posted by change_for_better
The graph of the function
is concave up on the interval:
(-infinity,infinity)
None
(1,infinity)
(-infinity,0)U(1,infinity)
(0,infinity)
=======================
I solve the question and my answer is :
The graph is concave up on (-infinity,-0.5)U(0,infinity)
and I'm sure from my answer but my answer is not included in the choices
and When I use the graphics calculator the graph is concave up on all interval
So what is the correct answer??
A function is concave upward when its second derivative is positive.
If $y= x^4+ x^3+ x$, then $y"= 12x^2+ 6x= 6x(2x+ 1)$. That is 0 at x= 0 and x= -1/2. If x< -1, x< 0 and 2x+1< 0 so y" is positive. If -1< x< 0, x< 0 and 2x+1> 0 so y" is negative. If x> 0, 2x+1> 0 so y" is positive. y is concave upward on exactly the interval you give, whether is one of the options or not!
5. Originally Posted by change_for_better
but I would to remind you that in concavity test we do the following :
1)find first derivative
2)find second derivative
3)set first derivative=0 and solve for x
4)usinig the zeros of second derivative we will set open interval and select test number within each interval to determine the type of concavity ..
If you know this why you couldnt have used this to answer your own question? | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9719924777713886,
"lm_q1q2_score": 0.8608271262277404,
"lm_q2_score": 0.8856314692902446,
"openwebmath_perplexity": 912.2231368772646,
"openwebmath_score": 0.8478879332542419,
"tags": null,
"url": "http://mathhelpforum.com/calculus/87199-find-interval-function-concave-up.html"
} |
If you know this why you couldnt have used this to answer your own question?
6. Originally Posted by HallsofIvy
A function is concave upward when its second derivative is positive.
If $y= x^4+ x^3+ x$, then $y"= 12x^2+ 6x= 6x(2x+ 1)$. That is 0 at x= 0 and x= -1/2. If x< -1, x< 0 and 2x+1< 0 so y" is positive. If -1< x< 0, x< 0 and 2x+1> 0 so y" is negative. If x> 0, 2x+1> 0 so y" is positive. y is concave upward on exactly the interval you give, whether is one of the options or not!
I would like to ask you ,when I use graphics calculator the shape of the graph of the function is concave up in all interval,butwhen we solve the question the interval (-0.5,0)is concave down ??
7. Originally Posted by sk8erboyla2004
If you know this why you couldnt have used this to answer your own question?
Because ,when I use graphics calculator the shape of the graph of the function is concave up in all interval,butwhen we solve the question the interval (-0.5,0)is concave down ??
8. Hello, change_for_better!
I agree with your intervals . . .
The graph of the function: . $f(x) \;=\;x^4+x^3+x$ is concave up on the interval:
. . $(a)\;(-\infty, \infty) \qquad(b)\text{ None} \qquad (c)\;(1,\infty) \qquad (d)\;(-\infty,0) \;\cup\; (1,\infty) \qquad(e)\;(0,\infty)$
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
I solved and my answer is: . $\left(-\infty,-\tfrac{1}{2}\right) \cup (0,\infty)$
and I'm sure from my answer but my answer is not included in the choices.
and when I use the graphics calculator the graph is concave up on all interval
. .
Um ... not quite!
So what is the correct answer?
$\begin{array}{ccc}f(x) &=&x^4+x^3+x \\ f'(x) &=& 4x^3+3x^2+1 \\ f''(x) &=& 12x^2+6x \end{array}$
$f''(x) > 0 \quad\Rightarrow\quad x < \text{-}\tfrac{1}{2}\:\text{ or }\:x > 0$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9719924777713886,
"lm_q1q2_score": 0.8608271262277404,
"lm_q2_score": 0.8856314692902446,
"openwebmath_perplexity": 912.2231368772646,
"openwebmath_score": 0.8478879332542419,
"tags": null,
"url": "http://mathhelpforum.com/calculus/87199-find-interval-function-concave-up.html"
} |
$f''(x) > 0 \quad\Rightarrow\quad x < \text{-}\tfrac{1}{2}\:\text{ or }\:x > 0$
If you zoom in on your graph, there is a concave-down portion.
Code:
|
| *
| *
| *
* | *
- - - - - - - - - o - - - - - - - -
* o |
* o |
* * |
* |
|
And it's right where you predicted! . . . $\left(\text{-}\tfrac{1}{2},\:0\right)$
9. Originally Posted by Soroban
Hello, change_for_better!
I agree with your intervals . . .
$\begin{array}{ccc}f(x) &=&x^4+x^3+x \\ f'(x) &=& 4x^3+3x^2+1 \\ f''(x) &=& 12x^2+6x \end{array}$
$f''(x) > 0 \quad\Rightarrow\quad x < \text{-}\tfrac{1}{2}\:\text{ or }\:x > 0$
If you zoom in on your graph, there is a concave-down portion.
Code:
|
| *
| *
| *
* | *
- - - - - - - - - o - - - - - - - -
* o |
* o |
* * |
* |
|
And it's right where you predicted! . . . $\left(\text{-}\tfrac{1}{2},\:0\right)$
Thank you very very very very much Soroban for great explanation
Now I understand my mistake ..
So from choices I should select none because the correct answer is not included .. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9719924777713886,
"lm_q1q2_score": 0.8608271262277404,
"lm_q2_score": 0.8856314692902446,
"openwebmath_perplexity": 912.2231368772646,
"openwebmath_score": 0.8478879332542419,
"tags": null,
"url": "http://mathhelpforum.com/calculus/87199-find-interval-function-concave-up.html"
} |
# Compute the $n$-th power of triangular $3\times3$ matrix
I have the following matrix
$$\begin{bmatrix} 1 & 2 & 3\\ 0 & 1 & 2\\ 0 & 0 & 1 \end{bmatrix}$$
and I am asked to compute its $n$-th power (to express each element as a function of $n$). I don't know at all what to do. I tried to compute some values manually to see some pattern and deduce a general expression but that didn't gave anything (especially for the top right). Thank you.
Computing the first few powers should allow you to find a pattern for the terms. Below are some terms:
$$\left(\begin{matrix}1 & 2 & 3\\0 & 1 & 2\\0 & 0 & 1\end{matrix}\right), \left(\begin{matrix}1 & 4 & 10\\0 & 1 & 4\\0 & 0 & 1\end{matrix}\right), \left(\begin{matrix}1 & 6 & 21\\0 & 1 & 6\\0 & 0 & 1\end{matrix}\right), \left(\begin{matrix}1 & 8 & 36\\0 & 1 & 8\\0 & 0 & 1\end{matrix}\right), \left(\begin{matrix}1 & 10 & 55\\0 & 1 & 10\\0 & 0 & 1\end{matrix}\right), \left(\begin{matrix}1 & 12 & 78\\0 & 1 & 12\\0 & 0 & 1\end{matrix}\right)$$
All but the top right corner are trivial so lets focus on that pattern. (Although if you look at it carefully you should recognize the terms.)
Terms: $3,10,21,36,55,78$
First difference: $7, 11, 15, 19, 23$
Second difference: $4, 4, 4, 4$
As the second difference is a constant the formula must be a quadratic. As the second difference is 4 then it is in the form $2n^2+bn+c$. Examining the pattern gives formula of $2n^2+n=n(2n+1)$.
So the $n^{th}$ power is given by:
$$\left(\begin{matrix}1 & 2n & n(2n+1)\\0 & 1 & 2n\\0 & 0 & 1\end{matrix}\right)$$
The reason I said you should recognize the pattern is because it is every second term out of this sequence: $1,3,6,10,15,21,27,37,45,55,66,78,\cdots$ which is the triangular numbers. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777180191995,
"lm_q1q2_score": 0.8608124858076805,
"lm_q2_score": 0.8723473779969194,
"openwebmath_perplexity": 290.0539395983521,
"openwebmath_score": 0.9655170440673828,
"tags": null,
"url": "https://math.stackexchange.com/questions/2079950/compute-the-n-th-power-of-triangular-3-times3-matrix/2079962"
} |
• It seemed more in line with what the OP had been trying. It would also let the OP see if their approach (and the powers of the matrix) were correct. – Ian Miller Jan 2 '17 at 1:28
• This is a great approach to "guess the formula" (and it is enough for any practical purpose), but it is not enough to constitute a proof. Could you please make it complete (or at least mention in the body that it still needs a proof)? – dtldarek Jan 2 '17 at 9:57
Write this matrix as follows: $$\left[ \begin{matrix} 1 & 2&3\\ 0 & 1 & 2\\ 0 & 0 &1 \end{matrix} \right] = I + 2 J+ 3 J^{2}.$$ where $$I = \left[ \begin{matrix} 1 & & \\ &1 & \\ & & 1 \end{matrix} \right], ~ J = \left[ \begin{matrix} 0& 1 &0 \\ 0 &0 & 1 \\ 0 & 0& 0 \end{matrix} \right],~ J^2 = \left[ \begin{matrix} 0& 0 &1\\ 0 & 0 &0\\ 0& 0 & 0 \end{matrix} \right], ~ J^{3}=0.$$ With this relation you can expand the power of the matrix into sum of $I$, $J$ and $J^2$.
• Thank you for your answer, interesting because it takes a different approach to my original idea, I will study it. – Trevör Jan 2 '17 at 12:06
Define
$$J = \begin{bmatrix} 0 & 2 & 3\\ 0 & 0 & 2\\ 0 & 0 & 0 \end{bmatrix}$$
so that the problem is to compute $(I+J)^n$. The big, important things to note here are
• $I$ and $J$ commute
• $J^3 = 0$
which enables the following powerful tricks: the first point lets us expand it with the binomial theorem, and the second point lets us truncate to the first few terms:
$$(I+J)^n = \sum_{k=0}^n \binom{n}{k} I^{n-k} J^k = I + nJ + \frac{n(n-1)}{2} J^2$$
More generally, for any function $f$ that is analytic at $1$, (such as any polynomial), if you extend it to matrices via Taylor expansion, then under the above conditions, its value at $I+J$ is given by
$$f(I+J) = \sum_{k=0}^\infty f^{(k)}(1) \frac{J^k}{k!} = f(1) I + f'(1) J + \frac{1}{2} f''(1) J^2$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777180191995,
"lm_q1q2_score": 0.8608124858076805,
"lm_q2_score": 0.8723473779969194,
"openwebmath_perplexity": 290.0539395983521,
"openwebmath_score": 0.9655170440673828,
"tags": null,
"url": "https://math.stackexchange.com/questions/2079950/compute-the-n-th-power-of-triangular-3-times3-matrix/2079962"
} |
$$f(I+J) = \sum_{k=0}^\infty f^{(k)}(1) \frac{J^k}{k!} = f(1) I + f'(1) J + \frac{1}{2} f''(1) J^2$$
As examples of things whose result you can check simply (so you can still use the method even if you're uncomfortable with it, because you can check the result), you can compute the inverse by
$$(I+J)^{-1} = I - J + J^2 = \begin{bmatrix} 1 & -2 & 1\\ 0 & 1 & -2\\ 0 & 0 & 1 \end{bmatrix}$$
and if you want a square root, you can get
$$\sqrt{I+J} = I + \frac{1}{2} J - \frac{1}{8} J^2 = \begin{bmatrix} 1 & 1 & 1\\ 0 & 1 & 1\\ 0 & 0 & 1 \end{bmatrix}$$
(These are actually special cases of $(I+J)^n$ by the generalized binomial theorem for values of $n$ that aren't nonnegative integers)
• Thank you so much for your answer, interesting because it takes a different approach than my original idea, I will study it. – Trevör Jan 2 '17 at 12:06
Let $I=\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}$, $A=\begin{pmatrix}0&1&0\\0&0&1\\0&0&0\end{pmatrix}$ and $B=\begin{pmatrix}0&0&1\\0&0&0\\0&0&0\end{pmatrix}$. Then $M=I+2A+3B$.
You can prove that for any $n$, $M^n$ can be written as $M^n=\lambda_n I + a_n A + b_n B$ (because it's upper triangular and the symmetry along the ascending diagonal will remain).
So $M^{n+1}=M^nM=(\lambda_n I + a_n A + b_n B) (I + 2A + 3B) = \dots$
Using this, compute $\lambda_n$, and then $a_n$ and finally $b_n$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777180191995,
"lm_q1q2_score": 0.8608124858076805,
"lm_q2_score": 0.8723473779969194,
"openwebmath_perplexity": 290.0539395983521,
"openwebmath_score": 0.9655170440673828,
"tags": null,
"url": "https://math.stackexchange.com/questions/2079950/compute-the-n-th-power-of-triangular-3-times3-matrix/2079962"
} |
Using this, compute $\lambda_n$, and then $a_n$ and finally $b_n$.
• An essential point is that the matrices commute – Rene Schipperus Jan 2 '17 at 2:29
• @ReneSchipperus : It's not really essential. The essential thing is that the vector space generated by the matrices is an algebra: $\forall X,Y\in Vect(I, A, B), XY \in Vect(I, A, B)$ (which is equivalent to $\forall X,Y\in \{I, A, B\}, XY \in Vect(I, A, B)$, because it's a vector space and you can use distributivity). In the general case, you would us the algebra of upper-triangular matrices, compute the coefficients on the diagonal, then right above the diagonal and keep going, and you'll only need the values already computed because the matrices are upper triangular. – xavierm02 Jan 2 '17 at 13:17
Here is another variation based upon walks in graphs.
We interpret the matrix $A=(a_{i,j})_{1\leq i,j\leq 3}$ with \begin{align*} A= \begin{pmatrix} 1 & 2 & 3\\ \color{grey}{0} & 1 & 2\\ \color{grey}{0} & \color{grey}{0} & 1 \end{pmatrix} \end{align*} as adjacency matrix of a graph with three nodes $P_1,P_2$ and $P_3$ and for each entry $a_{i,j}\neq 0$ with a directed edge from $P_i$ to $P_j$ weighted with $a_{i,j}$.
Note: When calculating the $n$-th power $A^n=\left(a_{i,j}^{(n)}\right)_{1\leq i,j\leq 3}$ we can interpret the element $a_{i,j}^{(n)}$ of $A^n$ as the number of (weighted) paths of length $n$ from $P_i$ to $P_j$. The entries of $A=(a_{i,j})_{1\leq i,j\leq 3}$ are the weighted paths of length $1$ from $P_i$ to $P_j$.
See e.g. chapter 1 of Topics in Algebraic Combinatorics by Richard P. Stanley.
Let's look at the corresponding graph and check for walks of length $n$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777180191995,
"lm_q1q2_score": 0.8608124858076805,
"lm_q2_score": 0.8723473779969194,
"openwebmath_perplexity": 290.0539395983521,
"openwebmath_score": 0.9655170440673828,
"tags": null,
"url": "https://math.stackexchange.com/questions/2079950/compute-the-n-th-power-of-triangular-3-times3-matrix/2079962"
} |
Let's look at the corresponding graph and check for walks of length $n$.
• We see there are no directed edges from $P_2$ to $P_1$ and no directed edges from $P_3$ to $P_2$ and from $P_3$ to $P_1$ which implies there are no walks of length $n$ either. So, $A^n$ has due to the specific triangle structure of $A$ necessarily zeroes at the same locations as $A$. \begin{align*} A^n= \begin{pmatrix} . & . & .\\ \color{grey}{0} & . & .\\ \color{grey}{0} & \color{grey}{0} & . \end{pmatrix} \end{align*}
• It is also easy to consider the walks of length $n$ from $P_i$ to $P_i$. There is only one possibility to loop along the vertex weighted with $1$ from $P_i$ to $P_i$ and so the entries $a_{i,i}^{(n)}$ are \begin{align*} 1\cdot 1\cdot 1\cdots 1 = 1^n=1 \end{align*} and we obtain \begin{align*} A^n= \begin{pmatrix} 1& . & .\\ \color{grey}{0} & 1 & .\\ \color{grey}{0} & \color{grey}{0} & 1 \end{pmatrix} \end{align*}
and now the more interesting part
• $P_1$ to $P_2$:
The walks of length $n$ from $P_1$ to $P_2$ can start with zero or more loops at $P_1$ followed by a step (weigthed with $2$) from $P_1$ to $P_2$ and finally zero or more loops at $P_2$. All the loops are weighted with $1$. There are $n$ possibilities to walk this way \begin{align*} a_{1,2}^{(n)}=2\cdot 1^{n-1}+1\cdot 2\cdot 1^{n-2}+\cdots +1^{n-2}\cdot 2\cdot 1+1^{n-1}\cdot 2=2n \end{align*}
• $P_2$ to $P_3$:
Symmetry is trump. When looking at the graph we observe the same situation as before from $P_1$ to $P_2$ and conclude
\begin{align*} a_{2,3}^{(n)}=2n \end{align*}
• $P_1$ to $P_3$: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777180191995,
"lm_q1q2_score": 0.8608124858076805,
"lm_q2_score": 0.8723473779969194,
"openwebmath_perplexity": 290.0539395983521,
"openwebmath_score": 0.9655170440673828,
"tags": null,
"url": "https://math.stackexchange.com/questions/2079950/compute-the-n-th-power-of-triangular-3-times3-matrix/2079962"
} |
\begin{align*} a_{2,3}^{(n)}=2n \end{align*}
• $P_1$ to $P_3$:
Here are two different types of walks of length $n$ possible. The first walk uses the weight $3$ edge from $P_1$ to $P_3$ as we did when walking from $P_1$ to $P_2$ along the weight $2$ edge. This part gives therefore \begin{align*} 3\cdot 1^{n-1}+1\cdot 3\cdot 1^{n-2}+\cdots +1^{n-2}\cdot 3\cdot 1+1^{n-1}\cdot 3=3n\tag{1} \end{align*} The other type of walk of length $n$ uses the hop via $P_2$. We observe it is some kind of concatenation of walks as considered before from $P_1$ to $P_2$ and from $P_2$ to $P_3$. In fact there are $\binom{n}{2}$ possibilities to place two $2$'s in a walk of length $n$. All other steps are loops at $P_1,P_2$ and $P_3$ and we obtain \begin{align*} \binom{n}{2}\cdot 2\cdot 2=2n(n-1)\tag{2} \end{align*} Summing up (1) and (2) gives \begin{align*} a_{1,3}^{(n)}=3n+2n(n-1)=n(2n+1) \end{align*}
and we finally obtain
\begin{align*} A^n=\left(a_{i,j}^{(n)}\right)_{1\leq i,j\leq 3}=\begin{pmatrix} 1& 2n & n(2n+1)\\ \color{grey}{0} & 1 & 2n\\ \color{grey}{0} & \color{grey}{0} & 1 \end{pmatrix} \end{align*}
Using symmetry, write the recurrence relation
$$\begin{pmatrix} a_{n+1} & b_{n+1}&c_{n+1}\\ 0 & a_{n+1} & b_{n+1}\\ 0 & 0 &a_{n+1} \end{pmatrix}= \begin{pmatrix} 1 & 2&3\\ 0 & 1 & 2\\ 0 & 0 &1 \end{pmatrix} \begin{pmatrix} a_{n} & b_{n}&c_{n}\\ 0 & a_{n} & b_{n}\\ 0 & 0 &a_{n} \end{pmatrix}.$$
Then $$\begin{cases}a_{n+1}=a_n\\ b_{n+1}=b_n+2a_n\\ c_{n+1}=c_n+2b_n+3a_n.\end{cases}$$
We solve with
$$a_n=Cst=1,\\b_n=2(n-1)+Cst=2n,\\ c_n=4t_{n-1}+3(n-1)+Cst=2n^2+n,$$
where $t_n$ denotes a triangular number, using the initial conditions $a_1=1,b_1=2,c_1=3$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777180191995,
"lm_q1q2_score": 0.8608124858076805,
"lm_q2_score": 0.8723473779969194,
"openwebmath_perplexity": 290.0539395983521,
"openwebmath_score": 0.9655170440673828,
"tags": null,
"url": "https://math.stackexchange.com/questions/2079950/compute-the-n-th-power-of-triangular-3-times3-matrix/2079962"
} |
# Trying to convert a summation to an equation
Here is what I am trying to figure out $\sum_{i=1}^n 3+2 (1-i)$ It would be nice if this could be put into a single equation to be used in a larger system. I know that it is possible to break up the summation into two parts like this $\sum_{i=1}^n 3+\sum_{i=1}^n2 (1-i)$ and it then becomes $3*n+\sum_{i=1}^n2 (1-i)$ I get stuck in trying to convert the second summation into a regular equation. Ultimately, it seems that this should be some sort of exponential function, but I am not having any luck finding it.
This is for a personal project and not homework in case this is a concern.
Brandon
Well, $\displaystyle \sum_{i=1}^n 2(1-i) = \sum_{i=1}^n 2 - 2\sum_{i=1}^n i = 2n - \frac{2n(n+1)}{2}$.
Then we have $\displaystyle \sum_{i=1}^n 3 +2(1-i) = 3n + 2n - n(n+1) = 4n - n^2$.
For intuition on $\displaystyle \sum_{i=1}^n i = \frac{n(n+1)}{2}$, notice $1 + 2 + 3 + \ldots + (n-2) + (n-1) +n = (n+1) + (n-1 +2) + (n -2 +3) + \ldots + (\frac{n}{2} + (\frac{n}{2}+1)) = (n+1) + (n+1) + (n+1) + \ldots + (n+1)$,
grouping the first and last terms together, then the second and second to last, etc., where there are $\frac{n}{2}$ (for even $n$) terms in the last sum. If $n$ is odd, treat with $\frac{n+1}{2}$ where necessary.
Then summing $n+1$ $\frac{n}{2}$ times clearly gives $\frac{n(n+1)}{2}$.
• Awesome explanation. Thank you! – Brandon Dec 29 '16 at 21:02
Hint :- $\sum_{i=1}^n2(1-i)=\sum_{i=1}^n2-2\sum_{i=1}^ni=2.n-2(\frac{n(n+1)}{2})$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.986777175136814,
"lm_q1q2_score": 0.8608124748481518,
"lm_q2_score": 0.8723473713594992,
"openwebmath_perplexity": 166.52656671219535,
"openwebmath_score": 0.9556393623352051,
"tags": null,
"url": "https://math.stackexchange.com/questions/2075609/trying-to-convert-a-summation-to-an-equation"
} |
# Show $\lim\limits_{n\to\infty} \sqrt[n]{n^e+e^n}=e$
Why is $\lim\limits_{n\to\infty} \sqrt[n]{n^e+e^n}$ = $e$? I couldn't get this result.
-
I tried it with the triangle inequality and did not get the right result. I tried it with $a^b = e^{a*ln(b)}$ but did not get any further. This is a exercise I do for exam preparation, it's not homework. – leo Dec 29 '12 at 11:06
Thanks for all the brilliant answers. The accepted one is the one which I could understand the best, even if might not be the most elegant or shortest. – leo Dec 29 '12 at 13:57
Would you like me to provide more details about my solution? What do you not understand about it? It's a straightforward way to deal with n roots, and is just based on Bernoulli's inequality that $(1+x)^n \geq 1+ nx$ for $x\geq 0, n\in \mathbb{N}$. – Calvin Lin Dec 30 '12 at 1:08
@CalvinLin I changed my mind now. Nameless solution did just use Math I was more familiar with. But your solution is very clean and I understand it now. – leo Jan 27 '13 at 16:31
This is equivalent to showing that $\lim_{n \rightarrow \infty} \sqrt[n]{\frac {n^e}{e^n} + 1 } = 1$.
This is clearly bounded below by 1. It is bounded above by $1 + \frac {n^e}{n e^n}$, which has a limit of 1 since polynomials grow much slower than exponentials.
-
$$\large (n^e + e^n)^{\frac{1}{n}} = e \left ( 1 + \frac {n^e}{e^n} \right) ^{\frac 1 n}$$ $$e \Large \left ( 1 + \frac {n^e}{e^n} \right) ^{\frac 1 n} = e \left ( \underbrace { \left ( 1 + \frac {1}{e^{n - e \log n}} \right) ^{e^{n - e \log n}} }_{e}\right)^{ \underbrace{\frac{n}{e^{n - e \log n}}}_{0}}$$
-
What BIG fonts you have!! – Haskell Curry Dec 30 '12 at 8:13 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109529751892,
"lm_q1q2_score": 0.8608008381670373,
"lm_q2_score": 0.8740772384450967,
"openwebmath_perplexity": 313.8755475987201,
"openwebmath_score": 0.944831371307373,
"tags": null,
"url": "http://math.stackexchange.com/questions/266977/show-lim-limits-n-to-infty-sqrtnneen-e/266981"
} |
-
What BIG fonts you have!! – Haskell Curry Dec 30 '12 at 8:13
$$\lim_{n\to\infty} \sqrt[n]{n^e+e^n}=\lim_{n\to\infty} (n^e+e^n)^{\frac1n}=\lim_{n\to\infty} e^{\ln (n^e+e^n)\frac1n}$$ Now you just have to compute $$\lim_{n\to\infty} \frac{\ln (n^e+e^n)}n=\lim_{n\to\infty} \frac{\ln (e^{e\ln n}+e^n)}n=\lim_{n\to\infty} \frac{\ln e^n(e^{e\ln n-n}+1)}n=1+\lim_{n\to\infty} \frac{\ln (e^{e\ln n-n}+1)}n=1+\lim_{n\to\infty} \frac{\ln (e^{-\infty}+1)}n=1+\lim_{n\to\infty} \frac{\ln (0+1)}n=1+\lim_{n\to\infty} \frac{\ln (1)}n=1+0=1$$ since $e\ln n-n\to -\infty$.
-
could you please show the second last step a bit more fine grained. Otherwise this is the most clear answer to me. – leo Dec 29 '12 at 12:56
@leo Sure I can – Nameless Dec 29 '12 at 12:57
Let's see a more direct way
$$\lim\limits_{n\to\infty} \sqrt[n]{n^e+e^n}=\lim\limits_{n\to\infty} \sqrt[n]{e^n}=e$$ because the ratio test applied to $\frac{n^e}{e^n}$ yields $\lim_{n\to\infty}\frac{n^e}{e^n}=0.$
-
Why is $n^e$ is negligible? – leo Dec 29 '12 at 11:28
@leo: because the exponential function grows much faster than the polynomial function. – Chris's sis Dec 29 '12 at 11:29
That is of course far from rigorous. – Eckhard Dec 29 '12 at 12:19
@Eckhard: in addition, this is the way I was taught to answer such questions in high school. – Chris's sis Dec 29 '12 at 12:30
I have to agree this is far from rigorous. – user641 Dec 29 '12 at 12:54
You can also apply two gendarmes theorem. The idea is to find sequences $l_n, u_n$ which bound (from below and above) the given sequence $a_n$, i.e. $$l_n\le a_n\le u_n$$ holds, and which converge to a joint limit (i.e. $\lim_{n\to\infty}l_n=\lim_{n\to\infty}u_n=g).$ Then the theorem says that $a_n$ is also convergent and the limit is $g$. Let's see how it works. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109529751892,
"lm_q1q2_score": 0.8608008381670373,
"lm_q2_score": 0.8740772384450967,
"openwebmath_perplexity": 313.8755475987201,
"openwebmath_score": 0.944831371307373,
"tags": null,
"url": "http://math.stackexchange.com/questions/266977/show-lim-limits-n-to-infty-sqrtnneen-e/266981"
} |
Finding these bounds is usually pretty straightforward – lower bound is often obtained by simple missing some nonnegative terms. While seeking the upper bound, one have to remeber that the inequality have to be true only for all sufficiently large $n$'s. In this case one can write: $$\sqrt[n]{0+e^n}\le\sqrt[n]{n^e+e^n}\le\sqrt[n]{e^n+e^n}$$ since $0\le n^e$ and $n^e\le e^n$ for sure if $n$ is sufficiently large. Next, we observe that
$l_n:= \sqrt[n]{e^n}=e\longrightarrow e$ as well as
$u_n:=\sqrt[n]{2e^n}=e\sqrt[n]{2}\longrightarrow e\cdot 1 =e.$
The theorem yields the claim.
-
You can also use that $\sqrt[n]{a+b}\le \sqrt[n]{a}+\sqrt[n]{b}$. – user641 Dec 29 '12 at 19:31
Another very nice answer! Thank you! – leo Dec 29 '12 at 20:07
$0\le n^e$ and $n^e\le e^n$ are true for all $n\ge 0$ – Henry Dec 29 '12 at 22:44
You have $$\sqrt[n]{n^e+e^n}= \exp \left( \frac{\ln(n^e+e^n)}{n} \right)= \exp \left(1+ \frac{\ln \left( 1+ \frac{n^e}{e^n} \right)}{n} \right)$$ But $\ln \left( 1+ \frac{n^e}{e^n} \right) \sim \frac{n^e}{e^n}$ so you can conclude.
-
Note that by L'Hospital$$\lim_{n\to\infty}\frac{\log (n^e+e^n)}{n}=\lim_{n\to\infty}\frac{\frac{1}{n^e+e^n}(n^{e-1}+e^n)}{1}=\lim_{n\to\infty}\frac{n^{e-1}}{n^e+e^n}+\lim_{n\to\infty}\frac{1}{1+\frac{n^e}{e^n}}$$ Now $n.n^{e-1}\leq n^e+e^n$, so $n^{e-1}/(n^e+e^n)\leq1/n$. Hence taking limit on both side, the first limit is zero. For the second one it can be proved that $n^{e+1}\leq e^n$ for all $n\geq n_0$, for some $n_0$. So $\lim_{n\to\infty}(n^e/e^n)\leq\lim_{n\to\infty}(1/n)=0$. Hence the second limit equals $1$. Now taking exponential the required limit evaluates to $e$.
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109529751892,
"lm_q1q2_score": 0.8608008381670373,
"lm_q2_score": 0.8740772384450967,
"openwebmath_perplexity": 313.8755475987201,
"openwebmath_score": 0.944831371307373,
"tags": null,
"url": "http://math.stackexchange.com/questions/266977/show-lim-limits-n-to-infty-sqrtnneen-e/266981"
} |
-
Taking logs, you must show that $$\lim_{n \rightarrow \infty} {\ln(n^e + e^n) \over n} = 1$$ Applying L'hopital's rule, this is equivalent to showing $$\lim_{n \rightarrow \infty}{en^{e-1} + e^n \over n^e + e^n} = 1$$ Which is the same as $$\lim_{n \rightarrow \infty}{e{n^{e-1}\over e^n} + 1 \over {n^e \over e^n}+ 1} = 1$$ By applying L'hopital's rule enough times, any limit of the form $\lim_{n \rightarrow \infty}{\displaystyle {n^a \over e^n}}$ is zero. So one has $$\lim_{n \rightarrow \infty}{e{n^{e-1}\over e^n} + 1 \over {n^e \over e^n}+ 1} = {e*0 + 1 \over 0 + 1}$$ $$= 1$$ (If you're wondering why you can just plug in zero here, the rigorous reason is that the function ${\displaystyle {ex + 1 \over y + 1}}$ is continuous at $(x,y) = (0,0)$.)
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109529751892,
"lm_q1q2_score": 0.8608008381670373,
"lm_q2_score": 0.8740772384450967,
"openwebmath_perplexity": 313.8755475987201,
"openwebmath_score": 0.944831371307373,
"tags": null,
"url": "http://math.stackexchange.com/questions/266977/show-lim-limits-n-to-infty-sqrtnneen-e/266981"
} |
# Odds of drawing an ace on the first draw OR a two on the second
I'm working on a puzzle which describes a casino game where you draw 13 cards. You win if your first card is an ace, or your second is a two, or... all the way up to the 13th draw being a king. In order to analyse the problem, I started by simplifying to a two-card version. You draw two cards and win if the first is an ace or the second is a deuce.
The odds of drawing an ace on the first card is clearly 4/52 or 1/13.
My understanding, backed up by this question If you draw two cards, what is the probability that the second card is a queen?, suggests that the odds of drawing a 2 on the second card is also 1/13. What are the odds of drawing either? To my knowledge, you can't directly calculate that but instead calculate the inverse. The odds of not drawing a specific card should clearly be 12/13 and the odds of not drawing an ace followed by not drawing a two should be 12/13 * 12/13 = 144/169. The odds of drawing one or the other should therefore be 25/169.
But there's another approach to analysing the problem. There are 52 * 51 = 2652 different combinations for the first two cards. If A is an ace, T is a two and x is any other card, there are 5 combinations which give you a win:
AA Ax AT xT TT
Given that there are four aces, four twos and 44 other cards, the number of winning hands is:
4*3 + 4*44 + 4*4 + 44*4 + 4*3 = 392.
So the odds of winning should be 392 / 2652.
25/169 and 392/2652 are very close but they are NOT the same number. I believe the second number is accurate, but I can't see where the logic in the first method fails. I suspect that it has to do with the possibility of drawing both being double counted but I can't see how that should matter. It seems like you should be able to treat each draw as an independent event. Additionally, the second method doesn't scale well - it would be extremely tedious to directly calculate the number of winning hands for the full 13 card game. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.984810952529396,
"lm_q1q2_score": 0.8608008313165687,
"lm_q2_score": 0.8740772318846386,
"openwebmath_perplexity": 221.9916547173893,
"openwebmath_score": 0.5406288504600525,
"tags": null,
"url": "https://math.stackexchange.com/questions/1991652/odds-of-drawing-an-ace-on-the-first-draw-or-a-two-on-the-second"
} |
edit: Clarified the rules for winning the game.
• The odds of firstly drawing an ace and secondly a two is $\frac4{52}\frac4{51}$. Can you understand why? – drhab Oct 30 '16 at 15:22
• Arthur, I'm not counting the number of ways to draw aces and twos, I'm counting the number of ways to win. Neither xA nor Tx win the game. – Dan J. Oct 30 '16 at 15:44
• Heads up - odds and probability are two different things. – Sean Roberson Oct 30 '16 at 15:56
• drhab, I disagree. If you draw a two on the first draw, then the odds of drawing a two on the second draw are only 3/51, not 4/51. You have to take both possibilities into account and that gives you odds of 1/13. See the linked question in my submission. – Dan J. Oct 30 '16 at 16:04
• The probability of firstly drawing an ace (not a two) and secondly a two is $\frac4{52}\frac4{51}$. If firstly an ace has been drawn then $4$ of the remaining $51$ cards are two's. – drhab Oct 30 '16 at 16:26
Let $A$ denote the event that the first draw will be an ace and let $B$ be the event that the second draw will be a two.
Then:$$\Pr(A\cup B)=$$$$\Pr(A)+\Pr(B)-\Pr(A\cap B)=$$$$\Pr(A)+\Pr(B)-\Pr(A)\Pr(B\mid A)=$$$$\frac4{52}+\frac4{52}-\frac{4}{52}\frac{4}{51}$$
The problem with your first method is that the events are not independent. Yes, the probability that you don't draw an ace from a full deck is $12/13$, and the probability that you don't draw a two from a full deck is $12/13$, but if you draw one card and then draw a second, the outcome of the second draw is dependent on the outcome of the first draw. Hence you cannot multiply the probabilities.
Your second method of calculating $P(\text{ace on first draw or two on second draw})$ is correct because it takes into account the outcome of the first draw and the second draw. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.984810952529396,
"lm_q1q2_score": 0.8608008313165687,
"lm_q2_score": 0.8740772318846386,
"openwebmath_perplexity": 221.9916547173893,
"openwebmath_score": 0.5406288504600525,
"tags": null,
"url": "https://math.stackexchange.com/questions/1991652/odds-of-drawing-an-ace-on-the-first-draw-or-a-two-on-the-second"
} |
• Then is the question I linked to about drawing a queen on the second card wrong? In particular, look at A.J.'s accepted answer showing that the odds remain 1/13 even if you take the first draw into account. Is that incorrect or does it not apply here? And if doesn't apply, why not? Also, my description of the game was ambiguous. It should be OR, not AND. I'll edit. – Dan J. Oct 30 '16 at 15:50
• I'm sorry, I misunderstood the condition for winning! As for the accepted answer in the link, the probability that the second card is a queen given that you know nothing about the first card is indeed $1/13$. Similarly, the probability that the second card is not a two given that you know nothing about the first card is $12/13$. But you cannot use this to calculate $P(\text{first card not ace and second card not two})$ because in that event you do have information about the first card. – kccu Oct 30 '16 at 20:23
On questions like these you have to stop yourself from taking shortcuts and keep your eye on the big picture. Therefore always use both cards. First the number of probabilities of getting an ace on the first throw is 4 times the other 51 cards. Second the odds on getting a 2 on the second card if the first one isn't a ace or a 2 is 4 times 44 plus if the first card is a 2 then 4 times 3. Third add up all the 4 times and you get 4 times 98 which equals 392.
• 4 * 51 +
• 4 * 44 +
• 4 * 3 =
• 4 * 98 = 392
Or for simplicity you could just add the odds of an ace for the first card (4 times 51) and a deuce for the second card (51 times 4) then minus one of the double wins (4 times 4) and you get 4 times (51 + 51 - 4) equals 4 times 98 equals 392. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.984810952529396,
"lm_q1q2_score": 0.8608008313165687,
"lm_q2_score": 0.8740772318846386,
"openwebmath_perplexity": 221.9916547173893,
"openwebmath_score": 0.5406288504600525,
"tags": null,
"url": "https://math.stackexchange.com/questions/1991652/odds-of-drawing-an-ace-on-the-first-draw-or-a-two-on-the-second"
} |
# Thread: Find the Indicated Integrals
1. ## Find the Indicated Integrals
I'm supposed to find several indefinite integrals, but I am not sure exactly how to do each, especially as they involve natural logs and trigonmetric functions.
The three are:
$\int ln(x^4)/x$ dx
$\int$((e^t^x) cos (e^t))/(3+5 sin (e^t))
and lastly
$\int (superscript 4/5, subscript 0) (sin^-1 ((5/4)x))/(sqrt(16-25x^2))$
2. Hi
Originally Posted by Pikeman85
$\int ln(x^4)/x$ dx
$\frac{\ln(x^4)}{x}=\frac{4\ln x}{x}=4\times \frac{1}{x}\times \ln x$ and as the derivative of $x\mapsto \ln x$ is $x\mapsto\frac{1}{x}$...
$\int$((e^t^x) cos (e^t))/(3+5 sin (e^t))
Is it $\int \frac{\mathrm{e}^{tx} \cos (\mathrm{e}^t)}{3+5 \sin (\mathrm{e}^t)}\,\mathrm{d}{\color{red}x}$ or $\int \frac{\mathrm{e}^{tx} \cos (\mathrm{e}^t)}{3+5 \sin (\mathrm{e}^t)}\,\mathrm{d}{\color{red}t}$ ?
$\int (superscript 4/5, subscript 0) (sin^-1 ((5/4)x))/(sqrt(16-25x^2))$
$\int_0^{\frac{4}{5}} \frac{\arcsin \left(\frac{5}{4}x\right)}{\sqrt{16-25x^2}}\,\mathrm{d}x$
Remember that $\arcsin'x=\frac{1}{\sqrt{1-x^2}}$
3. Originally Posted by Pikeman85
I'm supposed to find several indefinite integrals, but I am not sure exactly how to do each, especially as they involve natural logs and trigonmetric functions.
The three are:
$\int ln(x^4)/x$ dx
$\int$((e^t^x) cos (e^t))/(3+5 sin (e^t))
and lastly
$\int (superscript 4/5, subscript 0) (sin^-1 ((5/4)x))/(sqrt(16-25x^2))$
for the frist one
$\int \frac{\ln(x^4)}{x}dx=4\int\frac{\ln(x)}{x}dx$
Let $u=\ln(x) \implies du=\frac{1}{x}dx$
$4\int udu=2u^2+C=2\left( \ln(x)\right)^2+C$
For number 2 you have both x's and t's but no dx or dt what variable are integrating with respect to?
For the last one
$\int_{0}^{4/5}\frac{\sin^{-1\left( \frac{5}{4}x\right)}}{\sqrt{16-25x^2}}dx$
let $x=\frac{4}{5}\sin(t) \implies dx=\frac{4}{5}\cos(t)dt$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109503004294,
"lm_q1q2_score": 0.8608008277530769,
"lm_q2_score": 0.874077230244524,
"openwebmath_perplexity": 10399.127820408063,
"openwebmath_score": 0.9726709127426147,
"tags": null,
"url": "http://mathhelpforum.com/calculus/41982-find-indicated-integrals.html"
} |
let $x=\frac{4}{5}\sin(t) \implies dx=\frac{4}{5}\cos(t)dt$
$\int_{0}^{4/5}\frac{\sin^{-1\left( \frac{5}{4}x\right)}}{\sqrt{16-25x^2}}dx=\int_{0}^{\frac{\pi}{2}}\frac{t}{\sqrt{1 6-16\sin^2(t)}}\left( \frac{4}{5}\cos(t)dt \right)=$
$\frac{1}{5}\int_{0}^{\pi/2}tdt=\frac{1}{5} \left[ \frac{1}{2} \left( \frac{\pi}{2}\right)^2-0\right]=\frac{\pi^2}{40}$
Here is a web page with some La tex code for you
Helpisplaying a formula - Wikipedia, the free encyclopedia
Good luck.
4. Hello, Pikeman85!
These all require "simple" substitutions.
. . The trick is to recognize them.
$\int \frac{\ln(x^4)}{x}\,dx$
We have: . $\int\frac{4\ln(x)}{x}\,dx \;=\;4\int \ln x\,\frac{dx}{x}$
Let $u \:=\:\ln(x) \quad\Rightarrow\quad du \:=\:\frac{dx}{x}$
Substitute: . $4\int u\,du$ . . . etc.
$\int \frac{e^{t}\cos(e^t)\,dt}{3+5\sin(e^t)}$
Let $u \:=\:3+5\sin(e^t)\quad\Rightarrow\quad du \:=\:5e^t\cos(e^t)\,dt \quad\Rightarrow\quad e^t\cos(e^t)\,dt \:=\:\frac{1}{5}\,du$
Substitute: . $\int\frac{\frac{1}{5}\,du}{u} \;=\;\frac{1}{5}\int \frac{du}{u}$ . . . etc.
$\int^{\frac{4}{5}}_0 \frac{\sin^{-1}\!\left(\frac{5}{4}x\right)}{\sqrt{16-25x^2}}\,dx$
The denominator is: . $\sqrt{16\left(1 - \frac{25}{16}x^2\right)} \;=\;4\sqrt{1 - \left(\frac{5}{4}x\right)^2}$
The integral becomes: . $\int^{\frac{4}{5}}_0 \frac{\sin^{-1}\!\left(\frac{5}{4}x\right)\,dx} {4\sqrt{1 - \left(\frac{5}{4}x\right)^2}}$ . $= \;\;\frac{1}{4}\int^{\frac{4}{5}}_0\sin^{-1}\!\left(\frac{5}{4}x\right)\cdot\frac{dx}{\sqrt{ 1 - \left(\frac{5}{4}x\right)^2}}$
$\text{Let }u \:=\:\sin^{-1}\!\left(\frac{5}{4}x\right) \quad\Rightarrow\quad
du \:=\:\frac{\frac{5}{4}\,dx}{\sqrt{1-\left(\frac{5}{4}x\right)^2}}
Substitute: . $\frac{1}{4}\int^{\frac{4}{5}}_0 u\cdot\frac{4}{5}\,du \;=\;\frac{1}{5}\int^{\frac{4}{5}}_0 u\,du$ . . . etc.
Edit: I'm way too slow this time . . . *sigh*
.
$\int x^2 \sqrt{(7 + x^3)}$ dx
The answer I got for it is $(x^3/3) \sqrt{(7x+(x^4/4))}$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109503004294,
"lm_q1q2_score": 0.8608008277530769,
"lm_q2_score": 0.874077230244524,
"openwebmath_perplexity": 10399.127820408063,
"openwebmath_score": 0.9726709127426147,
"tags": null,
"url": "http://mathhelpforum.com/calculus/41982-find-indicated-integrals.html"
} |
$\int x^2 \sqrt{(7 + x^3)}$ dx
The answer I got for it is $(x^3/3) \sqrt{(7x+(x^4/4))}$
Which is not correct. How am I doing this incorrectly? I imagine my substitution is wrong.
6. Originally Posted by Pikeman85
$\int x^2 sqrt(7 + x^3)$ dx
The answer I got for it is (x^3/3) sqrt(7x+(x^4/4))
Which is not correct. How am I doing this incorrectly? I imagine my substitution is wrong.
One can notice that the derivative of $7+x^3$ is $3x^2$ so $x^2 \sqrt{7 + x^3}$ looks like $u'(x)\sqrt{u(x)}$ which can easily be integrated : you may try to substitute $u(x)=x^3+7$.
7. Well, a faster substitution is also $z^2=x^3+7.$
8. $x^3 \sqrt{7+x^3}$
I got this, but it did not work. I'm missing a step here I think
I don't get substitution very well
9. Originally Posted by Pikeman85
$\int x^2 \sqrt{(7 + x^3)}$ dx
The answer I got for it is $(x^3/3) \sqrt{(7x+(x^4/4))}$
Let $u=7+x^3 \implies du=3x^2dx \iff \frac{du}{3}=x^2dx$
$\int x^2\sqrt{7+x^3}dx=\int \sqrt{u}\left( \frac{du}{3}\right)=\frac{1}{3}\int u^\frac{1}{2}du=\frac{2}{9}u^\frac{3}{2}+C=\frac{2 }{9}(7+x^3)^\frac{3}{2}+C$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9848109503004294,
"lm_q1q2_score": 0.8608008277530769,
"lm_q2_score": 0.874077230244524,
"openwebmath_perplexity": 10399.127820408063,
"openwebmath_score": 0.9726709127426147,
"tags": null,
"url": "http://mathhelpforum.com/calculus/41982-find-indicated-integrals.html"
} |
# If S and T are transformattion mappings, what is [ST]?
S and T are transformation mappings, what does [ST] and [TS] mean?
Does it mean transform via S and then apply T to the result and vice versa?
Juxtaposition of linear transformations means composition. In details, $ST$ means $S \circ T$ and $TS$ means $T \circ S$ (whenever they are defined, surely). This notation is used thinking of the following: $$T: V_1 \to V_2 \qquad S:V_2 \to V_3 \qquad S\circ T: V_1 \to V_3$$ Let $B_1, B_2, B_3$ be basis for the respective spaces (in finite dimension). Then: $$[S \circ T]_{B_1, B_3} = [S]_{B_2, B_3}[T]_{B_1,B_2}$$ At the bottom of our hearts, we know the distinction, so, writing, we oftem "confuse" the matrix with the transformation, so $S \circ T$ becomes $ST$. Actually, the identity above is the motivation for the definition of matrix multiplication.
• Yes, the composition goes from $V_1$ to $V_1$. To understand that notation better, I think it is important to take a look at matrices of linear transformations. – Ivo Terek Oct 13 '14 at 2:09
• Great, and for the format of B1,B3, can the B3 also be written above B1 or is it B3 above B1? – user83039 Oct 13 '14 at 2:23 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. Yes\n2. Yes",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9907319866190857,
"lm_q1q2_score": 0.8607744780503122,
"lm_q2_score": 0.8688267762381843,
"openwebmath_perplexity": 672.6112142775514,
"openwebmath_score": 0.8997182846069336,
"tags": null,
"url": "https://math.stackexchange.com/questions/970992/if-s-and-t-are-transformattion-mappings-what-is-st"
} |
# What are the odds of rolling a 3 number straight throwing 6d6
If you throw six fair dice, what are the odds that at least three dice make a straight (i.e. 123, 234, 345, or 456) I am certain that I am making a mistake in calculating it?
-
## migrated from boardgames.stackexchange.comOct 2 '11 at 2:38
This question came from our site for people who like playing board games, designing board games or modifying the rules of existing board games.
what's your current calculation? – DForck42 Oct 1 '11 at 4:27
should be moved to SE mathematics – Hackworth Oct 1 '11 at 18:35
It's pretty high, pretty near one. But I'd have to think of how to get the exact probability... – PearsonArtPhoto Oct 1 '11 at 22:02
I went through a long and nasty inclusion-exclusion argument, watched lots of stuff cancel, and in the end got $6^6 - 6 \cdot 4^6 + 8 \cdot 3^6 - 3 \cdot 2^6$, which agrees with Ed Pegg's calculations. I imagine there's a simple way to explain this formula, but I don't see it. I'm offering my results here in the hope that someone else can. – Mike Spivey Oct 2 '11 at 7:02
@Mike Sounds like I did the same calculation as you. If you have time, why don't you post your solution? We can also try to think of a shortcut. – Byron Schmuland Oct 2 '11 at 13:01
## 3 Answers
This problem is harder than I thought such a simple-sounding dice problem would be. :) However, the analysis below works for any number of six-sided dice! If $n$ is the number of dice, then the probability that we obtain at least one of 123, 234, 345, 456 is $$\frac{6^n - 6 \cdot 4^n + 8 \cdot 3^n - 3 \cdot 2^n}{6^n}.$$
For example, if $n=0$ or $n = 1$ or $n = 2$, we get $0$, as we should. If $n = 3$, we get $24$ in the numerator, which agrees with the $4 \cdot 3!$ ways we could obtain at least one of the required straights with three dice. And if $n = 6$, we get $27720$ in the numerator, which agrees with Ed Pegg's calculations. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232909876815,
"lm_q1q2_score": 0.8607438581151349,
"lm_q2_score": 0.8757869965109764,
"openwebmath_perplexity": 226.40024347342285,
"openwebmath_score": 0.8829420804977417,
"tags": null,
"url": "http://math.stackexchange.com/questions/69178/what-are-the-odds-of-rolling-a-3-number-straight-throwing-6d6"
} |
We'll obtain the numerator in the fraction above by counting the number of ways not to get at least one of the four required straights and then subtract that from $6^n$. Let's call this event $\bar{S}$.
Start by considering subsets of {1, 2, 3, 4, 5, 6} such that throwing only numbers from that subset would give us an outcome in $\bar{S}$. There aren't any subsets of size five that do it, but there are six of size four: 1245, 1246, 1256, 1346, 1356, 2356. (I'm using a compact notation here for simplicity's sake.) Since $|\bar{S}| = |1245 \cup 1246 \cup 1256 \cup 1346 \cup 1356 \cup 2356|$, we now have a way to calculate $|\bar{S}|$ using the principle of inclusion-exclusion (PIE). We just have to consider all possible ways of intersecting these six sets and then add up the cardinalities of the resulting intersections according to parity given by $(-1)^{k(A)}$, where $k(A)$ is the number of sets intersected to obtain the subset $A$.
What makes applying PIE more difficult than usual here is that intersecting two sets sometimes gives a subset of size 3 and sometimes one of size 2, and this problem only gets worse as you intersect more sets. However, if you work through all the possibilities, most of the resulting intersections show up more than once with different parities, and most of these surprisingly cancel. What's left is 124, 125, 126, 136, 146, 156, 256, 356 (from intersecting 2 sets) and 12, 16, 26 (from intersecting 3 sets).
Finally, since there are $j^n$ ways to throw the $n$ dice so that they only take on values from a subset of size $j$, we obtain $|\bar{S}| = 6 \cdot 4^n - 8 \cdot 3^n + 3 \cdot 2^n$.
Unfortunately, I don't have a good explanation for why so many terms cancel, and I think there should be one. If someone can find such an explanation, I would love to see it. I've found an explanation for the massive term cancellation. (I suspect there are others.) See comments below. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232909876815,
"lm_q1q2_score": 0.8607438581151349,
"lm_q2_score": 0.8757869965109764,
"openwebmath_perplexity": 226.40024347342285,
"openwebmath_score": 0.8829420804977417,
"tags": null,
"url": "http://math.stackexchange.com/questions/69178/what-are-the-odds-of-rolling-a-3-number-straight-throwing-6d6"
} |
Finally, thanks to Ed Pegg for the brute force approach; that was very helpful in checking my work.
Added: Here is one explanation for the massive term cancellation when using PIE.
The six sets of size four that we're working with can be expressed as a graph. Each set is a vertex, and two vertices are connected by an edge if their corresponding sets differ by only one element. The graph looks like this.
1245 — 1256 — 2356
\ / \ /
1246 1356
\ /
1346
It turns out that, of the intersections that remain when applying PIE, the vertices correspond to the 6 sets of size 4, the edges correspond to the 8 sets of size 3, and the minimal cycles correspond to the 3 sets of size 2. Every other intersection is either empty or can be paired with another intersection such that they cancel each other in the PIE formula. To obtain the mapping between pairs of intersections, take an intersection that produces a connected subgraph. Pair it with the intersection obtained by removing the vertex with the highest connectivity in the subgraph. This produces a disconnected subgraph. For example, the intersection of 1245, 1256, 1356, and 2356 is paired with the intersection of 1245, 1356, and 2356. Both intersections produce 5, yet have different parities, so they cancel when using PIE. (Well, the 4-cycle is a special case, but everything there cancels nicely, too, except for the full cycle itself.)
As far as I know, inclusion-exclusion cannot, in general, be represented in a graph like this. Maybe there are some special cases, though, and this graph happens to fall into one of those. Is anyone familiar with this?
Inclusion-exclusion can, in some cases, be represented and simplified by a graph like this. My observations here are an instance of the following theorem: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232909876815,
"lm_q1q2_score": 0.8607438581151349,
"lm_q2_score": 0.8757869965109764,
"openwebmath_perplexity": 226.40024347342285,
"openwebmath_score": 0.8829420804977417,
"tags": null,
"url": "http://math.stackexchange.com/questions/69178/what-are-the-odds-of-rolling-a-3-number-straight-throwing-6d6"
} |
Suppose sets $A_1, A_2, \ldots, A_n$ can be represented as the vertices of a planar graph $(V,E)$ such that, for each $x \in \cup_i A_i$, the subgraph consisting of the $A_i$'s containing $x$ is connected. For each edge $e = \{A_i, A_j\}$, let $|e| = |A_i \cap A_j|$. For each minimal cycle $c = \{A_{c_1}, A_{c_2}, \ldots, A_{c_m}\}$ in $(V,E)$, let $|c| = |\bigcap_{j=1}^m A_{c_j}|$. Then $$\left|\bigcup_{i=1}^n A_i \right| = \sum_{v \in V} |v| - \sum_{e \in E} |e| + \sum_{c \in C} |c|.$$
Since the graph above satisfies the hypotheses of this theorem, we immediately get $|\bar{S}| = 6 \cdot 4^n - 8 \cdot 3^n + 3 \cdot 2^n$.
The proof of the theorem follows directly from Euler's famous formula $V - E + F = 2$ for connected planar graphs. For any element $x \in \cup_i A_i$, the subgraph consisting of the $A_i$'s containing $x$ is connected (by hypothesis) and planar. The element $x$ is counted once on the left side of the formula in the theorem. Since minimal cycles correspond to faces except for the one outer face, Euler's formula tells us that $x$ is counted a net total of once for the right-hand side as well.
More general versions of this theorem that use the Euler characteristic can be found in
-
This is very nice!. I wish I could upvote again. – Byron Schmuland Oct 4 '11 at 17:19
@Byron: Thanks! The compliment is worth more than the extra upvote would be, though. :) – Mike Spivey Oct 4 '11 at 17:28
@Byron: I found an explanation for the term cancellation in terms of the graph representation. Fascinating, really! And I think now that I have officially beaten this question to death. :) – Mike Spivey Oct 5 '11 at 4:51
In Mathematica, here's a brute force solution. There are 27720 rolls of the 6 dice that will give that straight.
Length[Select[Tuples[Range[6], {6}], Max[Table[Length[Intersection[#, {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}, {4, 5, 6}}[[n]]]], {n, 1, 4}]] == 3 &]]/6^6
$385/648 = 0.5941358024691358024691\dots$
- | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232909876815,
"lm_q1q2_score": 0.8607438581151349,
"lm_q2_score": 0.8757869965109764,
"openwebmath_perplexity": 226.40024347342285,
"openwebmath_score": 0.8829420804977417,
"tags": null,
"url": "http://math.stackexchange.com/questions/69178/what-are-the-odds-of-rolling-a-3-number-straight-throwing-6d6"
} |
$385/648 = 0.5941358024691358024691\dots$
-
Here's another way. Let ${\bf k}$ be the number of distinct die numbers, let $S$ ("success") be the event that at least one of the four required straights occurred.
Then $$P(S) = \sum_{k=1}^6 P(S | {\bf k}=k) \; P({\bf k}=k)$$
It's clear that, for a given fixed $k$, all configurations are equiprobable.
It's trivial that $P(S | {\bf k}=0)=P(S | {\bf k}=1)=P(S | {\bf k}=2)=0$. The other are not difficult:
$P(S | {\bf k}=3)$ : There are 4 possible success configurations, out of ${6 \choose 3}$, hence $P(S | {\bf k}=3) = 1/5$
$P(S | {\bf k}=4)$ : This is the most difficult one, let's count the unsuccessful configurations: These are : [o x x o x x] [x o x o x x] [x o x x o x] [x x o o x x] plus the mirroring of the first two: 6 unsuccessful configurations out of ${6 \choose 4}$ hence $P(S | {\bf k}=4) = 1- 2/5 = 3/5$ [*]
Further, $P(S | {\bf k}=5)= P(S | {\bf k}=6) = 1$
Now, to compute $P({\bf k}=k)$, we must count the number of ways of filling $k$ positions with 6 throws: for example, $$P({\bf k}=4)=\frac{{6 \choose 4} \; 4! \; S_2(6,4)}{6^6}$$
where $S_2(n,m)$ are the Stirling numbers of the second kind. So finally
$$P(S) = \sum_{k=3}^6 a_k \; \frac{{6 \choose k} \; k! \; S_2(6,k)}{6^6} \approx 0.59413$$
with $a_3=1/5$, $a_4=3/5$, $a_5=1$, $a_6=1$.
[*] Added: to generalize this for arbitrary number of dice or runlengths, notice that this counting of unsuccessful configurations is equivalent to count the ways of expressing the number $k=4$ as a sum of $n-k+1=3$ non-negative terms less that $m=3$ (runlength), with order (in the example, 0+2+2 , 1+1+2, 1+2+1, 2+0+2, 2+2+0,2+1+1). Hence $P(S | {\bf k}) = 1 - b_{k,n-k+1,m}/{n \choose k}$ where $b_{r,s,t}$ counts the $s$-terms weak-compositions of the integer $r$, with the restriction that each term is less than $t$. An expression is given in Enumerative combinatorics (Stanley) page 120, problem 28. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232909876815,
"lm_q1q2_score": 0.8607438581151349,
"lm_q2_score": 0.8757869965109764,
"openwebmath_perplexity": 226.40024347342285,
"openwebmath_score": 0.8829420804977417,
"tags": null,
"url": "http://math.stackexchange.com/questions/69178/what-are-the-odds-of-rolling-a-3-number-straight-throwing-6d6"
} |
Added 2: Because the exact formula for arbitrary dice is quite formidable, here's some quick asymptotics. Let $n$ be the number of throws, $c$ the number of dice faces, $m$ the straight length. For large $c,n$, the probability that a particular face number does not appear is $q=(1-1/c)^n \approx \exp(- n/c)$. Asymptotically, we can assume that these events are independent, and disregard border effects, and regard each outcome as a sequence of runlengths $(a_1 b_1 a_2 b_2 ... a_r b_r)$ where $a_i$ is the length of consecutive (run) die faces that appeared, $b_i$ the faces that didn't (and $a_1 + b_1 + ... = c$). Each run can then be approximated by independent geometric variables (starting at 1) with stopping probabilities $q$ and $1-q$. Their expectations are respectively $1/q$ and $1/(1-q)$, so that equating the expected sum we get $r=c \; q \;(1-q)$. The event of no-success, correspond to $a_i<m$, and its probability is given, in this approximation, by $(1-(1-q)^{m-1})^r$. Finally:
$$P(S) \approx 1- \left[ 1- (1-q)^{m-1} \right]^r$$
with
$$r = c \; q \; (1-q) \hspace{20px} q = (1-1/c)^n \approx e^{-n/c}$$
In our original question... we have $c=n=6$,$m=3$, the numbers are too small to apply this asymptotics, but anyway, I get: $P(S) \approx 0.50922$ ($0.54184$ if using the "exact" $q$)
-
+1: I like this better than my answer for the 6-dice problem. Can it be generalized to $n$ dice? – Mike Spivey Oct 4 '11 at 18:47
@MikeSpivey: The counting of $P(S|k=k)$ is not trivially generalizable (for $n$ dice and $m$ sequence lengths), but I think it can be done, I'll give it a look tonight. – leonbloy Oct 4 '11 at 19:00
@MikeSpivey: See my addition. Now it remains to see if those bounded weak-compositions have some closed formula. – leonbloy Oct 4 '11 at 19:20 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9828232909876815,
"lm_q1q2_score": 0.8607438581151349,
"lm_q2_score": 0.8757869965109764,
"openwebmath_perplexity": 226.40024347342285,
"openwebmath_score": 0.8829420804977417,
"tags": null,
"url": "http://math.stackexchange.com/questions/69178/what-are-the-odds-of-rolling-a-3-number-straight-throwing-6d6"
} |
# Math Help - Geometry regarding the intersection of wires criss crossing vertical poles.
1. ## Geometry regarding the intersection of wires criss crossing vertical poles.
Two vertical poles are of lengths 10 m and 6 m. They are connected by wires going from the top of each pole to the base of the other. At what height do the two connecting wires intersect?
help step by step would be appreciated. thanks. i have tried but failed maybe something very simple i am missing. btw i am new, so if i was to post my method (which was utterly useless), i apologize in advance for not doing so.
2. Do you find it odd that the distance between the poles is not given?
In any case, you're going to need some similar triangles. If you have a method that has similar triangles, I suspect it is NOT totally worthless. Post it.
3. Originally Posted by swanz
Two vertical poles are of lengths 10 m and 6 m. They are connected by wires going from the top of each pole to the base of the other. At what height do the two connecting wires intersect?
help step by step would be appreciated. thanks. i have tried but failed maybe something very simple i am missing. btw i am new, so if i was to post my method (which was utterly useless), i apologize in advance for not doing so.
If you know the poles are vertical, you know they are parallel. You can treat each wire as a transversal of these - check out which angles are alternate interior angles of these two transversals to see some similar triangles. Draw yourself a decent picture to see them! Then use these similar triangles to answer the question.
4. Originally Posted by swanz
Two vertical poles are of lengths 10 m and 6 m. They are connected by wires going from the top of each pole to the base of the other. At what height do the two connecting wires intersect? | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.97364464791863,
"lm_q1q2_score": 0.8607401241457467,
"lm_q2_score": 0.8840392909114836,
"openwebmath_perplexity": 480.6962069266633,
"openwebmath_score": 0.797980010509491,
"tags": null,
"url": "http://mathhelpforum.com/geometry/102193-geometry-regarding-intersection-wires-criss-crossing-vertical-poles.html"
} |
help step by step would be appreciated. thanks. i have tried but failed maybe something very simple i am missing. btw i am new, so if i was to post my method (which was utterly useless), i apologize in advance for not doing so.
Assume the wires are straight (with no sag)
Since the distance between the two is irrelevant, we can assign it what ever needed, say 1 m.
Assume the shorter pole is coincident with the y axis and the taller pole is parallel but at x = 1
An equation for each wire:
$y_1 = -6x_1 + 6$
$y_2 = 10x_2 + 0$
Isolate x:
$x_1 = \dfrac{ y_1 - 6 }{-6}$
$x_2 = \dfrac{y_2}{10}$
equate:
$\dfrac{ y - 6}{-6} = \dfrac{y}{10}$
solve for y
$y = \dfrac{ 60 }{16}$
.
5. ## Resolved
thank you aidan....never even considered plotting it on the graph .....all the time i was playing around with similar triangles, transversals and loads of variables.
nice method, can come in handy in various situations, thnx a bunch.
6. Originally Posted by aidan
Since the distance between the two is irrelevant
Well, one probably should prove that, rather than just state it.
7. Originally Posted by TKHunny
Well, one probably should prove that, rather than just state it.
My Bad. I just made an assumption that it was common knowledge.
One proof (if needed) is here:
PlanetMath: harmonic mean in trapezoid
It indicates that the diagonals of a trapezoid will intersect at some point. A line through that point parallel to the parallel sides will intersect the non parallel sides. The length of this segment is a ratio of the parallel sides only:
If the lengths of the parallel sides are "a" and "b" then the length of the interior line that is parallel to the parallel lines and passes through the intersection point is
$\dfrac{2 a b }{(a+b)}$
The intersection point is at the midpoint of the interior line.
In our case here:
HALF the length of the interior line is
$\dfrac{( 6 \cdot 10) }{( 6 + 10 )} = 3.75$ | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.97364464791863,
"lm_q1q2_score": 0.8607401241457467,
"lm_q2_score": 0.8840392909114836,
"openwebmath_perplexity": 480.6962069266633,
"openwebmath_score": 0.797980010509491,
"tags": null,
"url": "http://mathhelpforum.com/geometry/102193-geometry-regarding-intersection-wires-criss-crossing-vertical-poles.html"
} |
HALF the length of the interior line is
$\dfrac{( 6 \cdot 10) }{( 6 + 10 )} = 3.75$
8. I think it is second tier common knowledge. It can be assumed if you work with that sort of thing, but not generally.
My views. I welcome others.
9. That problem is "ye olde crossing ladders" problem in disguise | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES\n\n",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.97364464791863,
"lm_q1q2_score": 0.8607401241457467,
"lm_q2_score": 0.8840392909114836,
"openwebmath_perplexity": 480.6962069266633,
"openwebmath_score": 0.797980010509491,
"tags": null,
"url": "http://mathhelpforum.com/geometry/102193-geometry-regarding-intersection-wires-criss-crossing-vertical-poles.html"
} |
# Dominated Convergence Theorem
Give an example of a sequence $\{f_n\}_{n=1}^\infty$ of integrable functions on $\mathbb{R}$ such that $f_n \to f$ but $\int f_n \not\to \int f$. Explain why your example does not conflict with the Dominated Convergence Theorem.
I do notice that the inequality $|f_n(x)| \le g(x)$, where $g$ is an integrable function over $\mathbb{R}$, is not listed here in this problem. So the function need not be dominated by an integrable function here. But this is required as one hypothesis of the Dominated Convergence Theorem; hence the example will not conflict.
If this is sound reasoning, how may I come up with functions that are not dominated by another function? Initially I was thinking $f_n(x)=x \sin (nx)$ because its lim sup is $\infty$, but even then, we still have $|f_n(x)| \le |x| =: g(x)$.
• $f_n = n 1_{(0,{1 \over n}]}$. – copper.hat May 8 '15 at 16:35
• It is not only a matter of being dominated by a function, but by an integrable function. $|x|$ is not integrable on $\mathbb{R}$, as $\int_{-\infty}^\infty |x| dx = \infty$. – Pedro M. May 8 '15 at 16:39
• @PedroM. I forgot about the "integrable" function part. :O But thanks for clearing that up. – Cookie May 8 '15 at 16:42
• It may be dominated by another function, however the detail is that the if dominating function does not belong to $L_1$ then DCT may not hold. – Alonso Delfín May 8 '15 at 16:42
• @AaronMaroja I do not understand why you centerized "$\int f \not\to \int f$" and removed the period at the end of that sentence. – Cookie May 9 '15 at 7:28
Consider the sequence of functions on $(0,1)$ $$f_n(x) = \begin{cases} n & \text{ if } x \in (0,1/n)\\ 0 & \text{ otherwise} \end{cases}$$ We have $\lim_{n \to \infty} f_n(x) = 0 = f(x)$. However, $$\lim_{n \to \infty} \int_0^1f_n(x)dx = 1 \neq 0 = \int_0^1 f(x) dx$$ The key in the dominated convergence theorem is that sequence of functions $f_n(x)$ must be dominated by a function $g(x)$, which is also integrable. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446418006305,
"lm_q1q2_score": 0.8607401187371948,
"lm_q2_score": 0.8840392909114836,
"openwebmath_perplexity": 205.5637991302053,
"openwebmath_score": 0.9119226932525635,
"tags": null,
"url": "https://math.stackexchange.com/questions/1273139/dominated-convergence-theorem"
} |
I would like to provide a slightly more abstract framework to illustrate this "loss of compactness"$^{[2]}$ phenomenon. The functional setting is the $L^1(\mathbb{R})$ space: $$L^1(\mathbb{R})=\left\{f\colon\mathbb{R}\to\mathbb{R}\ :\ \int_{-\infty}^\infty \lvert f(x)\rvert\, dx<\infty \right\},\qquad \lVert f\rVert=\lVert f\rVert_{L^1}=\int_{-\infty}^\infty\lvert f(x)\rvert\, dx.$$ Here we take a bounded sequence $f_n$ that converges pointwise a.e. : $$\begin{array}{cc} \|f_n\|\le C, & f_n\to f\, \text{a.e.} \end{array}$$ The question is: does this sequence converge, that is, is it true that $$\lVert f_n-f\rVert\to 0?^{[1]\ [2]}$$ This would make for a very desirable property of our functional space. However, as other answers very clearly show, the answer is negative in general. The problem is that our space is subject to the action of noncompact groups of isometries. Namely, one has the action of the translation group $$\begin{array}{cc} \left(T_\lambda f\right)(x)=f(x-\lambda), &\lambda \in (\mathbb{R}, +) \end{array}$$ and of the dilation group $$\begin{array}{cc} \left(D_\lambda f\right)(x)=\frac{1}{\lambda}f\left(\frac{x}{\lambda}\right), &\lambda \in (\mathbb{R_{>0}}, \cdot) \end{array}$$ The change of variable formula for integrals immediately shows that those group actions are isometric, that is, they preserve the norm.
So, fixing a non-vanishing function $f\in L^1(\mathbb{R})$, its orbits $T_\lambda f$ and $D_\lambda f$ form bounded and non-compact subsets of $L^1(\mathbb{R})$. In particular, letting $\lambda \to +\infty$ (or $\lambda \to -\infty$ for translations, or $\lambda\to 0$ for dilations), one finds counterexamples to the question above. (Note that, more or less, all the examples constructed in the other, excellent, answers are constructed this way). | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446418006305,
"lm_q1q2_score": 0.8607401187371948,
"lm_q2_score": 0.8840392909114836,
"openwebmath_perplexity": 205.5637991302053,
"openwebmath_score": 0.9119226932525635,
"tags": null,
"url": "https://math.stackexchange.com/questions/1273139/dominated-convergence-theorem"
} |
In technical jargon one says that the translation and dilation groups introduce a defect of compactness in $L^1(\mathbb{R})$ space. This is the terminology of the Concentration-Compactness theory (the linked page is a blog entry of T. Tao, but the theory has been founded by P.L. Lions). The dominated convergence theorem can be therefore seen as a device that impedes the defect of compactness to take place.
Footnotes
$^{[1]}$ The OP only asks about the convergence of the integrals: $\int f_n\to \int f$. Now a standard theorem (cfr. Lieb & Loss Analysis, 2nd ed. Theorem 1.9 (Missing term in Fatou's lemma), see in the remarks) gives us the equivalence $$\begin{array}{ccc} \lVert f_n\rVert_{L^1} \to \lVert f\rVert_{L^1} & \iff & \lVert f_n-f\rVert_{L^1}, \end{array}$$ Therefore, at least for sequence of positive functions for which $\int f_n=\lVert f_n\rVert_{L^1}$, the failure of convergence for sequences of integrals is exactly the same thing as the failure of convergence in $L^1$ space. That's why one can see the phenomenon in this functional analytic setting.
$^{[2]}$ Compactness usually means that bounded sequences have convergent subsequences. In $L^1(\mathbb{R})$ space, pointwise convergent sequences are compact if and only if they are norm convergent.
• wow! Very interesting point of view, never heard of that before! :-) – Ant May 8 '15 at 18:47
It is not only a matter of being dominated by just any function $g$, but by an integrable function. $|x|$ is not integrable on $\mathbb{R}$, as $\int_{-\infty}^\infty |x| dx = \infty$.
copper.hat provided an example that is not dominated by any function, but you can also pick bounded examples, such as $f_n = 1_{[n,n+1]}$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446418006305,
"lm_q1q2_score": 0.8607401187371948,
"lm_q2_score": 0.8840392909114836,
"openwebmath_perplexity": 205.5637991302053,
"openwebmath_score": 0.9119226932525635,
"tags": null,
"url": "https://math.stackexchange.com/questions/1273139/dominated-convergence-theorem"
} |
• Does $f_n=\chi_{[-n,n]}$ also work? (Sorry, I'm used to the characteristic function that uses the Greek letter $\chi$ instead of $1$.) – Cookie May 8 '15 at 16:46
• @dragon: Then $f_n$ converges to the constant function $1$, which is not integrable on $\mathbb{R}$. This is another illustration of how the DCT may fail if the dominating function $g$ is not integrable: $\int f = \infty$ (in my example, $\int f$ is finite but is different from $\lim \int f_n$). Notice, however, that in your case, $\int f_n \to \infty = \int f$. – Pedro M. May 8 '15 at 16:49
Let $$f_n(x) = \frac{n^3x^2}{1+n^4x^4}.$$ Then $f_n(x) \to 0$ pointwise everywhere, and $\int_\infty^\infty f_n(x)\,dx = \int_\infty^\infty \frac{x^2}{1+x^4}\,dx$ for every $n.$
Let $f_n = \chi[n,2n]$ then for any $x \in \mathbb R$
$$\lim_{n \to \infty} f_n (x) = 0 \,\,\, \text{and} \,\,\, \int_{x\in \mathbb R} f_n(x) dx = n \to \infty \,\,\, \text{as}\,\, n \to \infty$$
On the other hand taking $f(x) = 0 , \forall x \in \mathbb R$ we have $$\int_{x\in \mathbb R} f(x) dx = \int _{x\in \mathbb R} 0\,\, dx = 0$$ then
$$\int_{x\in \mathbb R} f_n(x) dx \not \to \int_{x\in \mathbb R} f(x) dx$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446418006305,
"lm_q1q2_score": 0.8607401187371948,
"lm_q2_score": 0.8840392909114836,
"openwebmath_perplexity": 205.5637991302053,
"openwebmath_score": 0.9119226932525635,
"tags": null,
"url": "https://math.stackexchange.com/questions/1273139/dominated-convergence-theorem"
} |
# Math Help - Integration;unsure method
1. ## Integration;unsure method
Hi, I have another integration question (because they're just so fun ).
Int ( dx/(x^2-3x+2)^(1/2) )
The item giving me the biggest problem is the square rt. From what I know, I don't think u-sub will work (just complicate things more), integrating my parts seems like it would be very messy, partial fractions is out of the mix since its raised to a power and I don't think you can do complete the square for the same reason. I'm assuming I'm making this much more complicated than it really is. Can anybody help me start it out, thats all I need help with.
Thanks a ton.
2. Originally Posted by ChaosBlue
Hi, I have another integration question (because they're just so fun ).
Int ( dx/(x^2-3x+2)^(1/2) )
The item giving me the biggest problem is the square rt. From what I know, I don't think u-sub will work (just complicate things more), integrating my parts seems like it would be very messy, partial fractions is out of the mix since its raised to a power and I don't think you can do complete the square for the same reason. I'm assuming I'm making this much more complicated than it really is. Can anybody help me start it out, thats all I need help with.
Thanks a ton.
Start this by looking under the square root sign. You want to do a "complete the square."
x^2 - 3x + 2 = (x^2 - 3x) + 2 = (x^2 - 3x + 9/4 - 9/4) + 2 = (x^2 - 3x + 9/4) - 9/4 + 2
= (x - 3/2)^2 - 1/4
Now let y = x - 3/2, dy = dx
Int[1/(x^2-3x+2)^{1/2}dx] = Int[1/(y^2 - 1/4)^{1/2}dy]
One more trick and we're done. Pull a 1/4 out from under the radical:
Int[1/((1/4)(2y)^2 - 1/4)^{1/2}dy] = 2*Int[1/((2y)^2 - 1)^{1/2}dy]
And now let z = 2y, dz = 2dy and your integral becomes:
Int[1/(x^2-3x+2)^{1/2}dx] = Int[1/(y^2 - 1/4)^{1/2}dy] = Int[1/(z^2 - 1)^{1/2}dz]
This is a more standard problem. Can you take it from here?
-Dan
3. Originally Posted by ChaosBlue
Hi, I have another integration question (because they're just so fun ). | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446486833801,
"lm_q1q2_score": 0.8607401173852395,
"lm_q2_score": 0.8840392832736083,
"openwebmath_perplexity": 1382.927568327193,
"openwebmath_score": 0.837983250617981,
"tags": null,
"url": "http://mathhelpforum.com/calculus/12005-integration-unsure-method.html"
} |
Int ( dx/(x^2-3x+2)^(1/2) )
The item giving me the biggest problem is the square rt. From what I know, I don't think u-sub will work (just complicate things more), integrating my parts seems like it would be very messy, partial fractions is out of the mix since its raised to a power and I don't think you can do complete the square for the same reason. I'm assuming I'm making this much more complicated than it really is. Can anybody help me start it out, thats all I need help with.
Thanks a ton.
The way I see to do it is really long, so if anyone out there has an easier way, you are welcome to post.
We begin by completing the square.
int(1/sqrt(x^2 - 3x + 2))dx
= int(1/(sqrt( x^2 - 3x + (-3/2)^2 - 1/4))dx
= int(1/sqrt((x - 3/2)^2 - 1/4))dx
= int(1/sqrt((x - 3/2)^2 - (1/2)^2))dx
= int(1/sqrt[(1/2)^2*([(x - 3/2)/(1/2)]^2 - 1)])dx
= 2*int(1/sqrt[(2x - 3)^2 - 1])dx
let u= 2x - 3
=> du = 2 dx
so our integral becomes
int(1/sqrt(u^2 - 1))du
Now continue using trig substitution
4. Originally Posted by topsquark
Start this by looking under the square root sign. You want to do a "complete the square."
x^2 - 3x + 2 = (x^2 - 3x) + 2 = (x^2 - 3x + 9/4 - 9/4) + 2 = (x^2 - 3x + 9/4) - 9/4 + 2
= (x - 3/2)^2 - 1/4
Now let y = x - 3/2, dy = dx
Int[1/(x^2-3x+2)^{1/2}dx] = Int[1/(y^2 - 1/4)^{1/2}dy]
One more trick and we're done. Pull a 1/4 out from under the radical:
Int[1/((1/4)(2y)^2 - 1/4)^{1/2}dy] = 2*Int[1/((2y)^2 - 1)^{1/2}dy]
And now let z = 2y, dz = 2dy and your integral becomes:
Int[1/(x^2-3x+2)^{1/2}dx] = Int[1/(y^2 - 1/4)^{1/2}dy] = Int[1/(z^2 - 1)^{1/2}dz]
This is a more standard problem. Can you take it from here?
-Dan
Ha ha, i took forever typing this up only to see that u beat me to it once i clicked "submit reply"
Thanks a lot Dan
5. Originally Posted by Jhevon
Ha ha, i took forever typing this up only to see that u beat me to it once i clicked "submit reply"
Thanks a lot Dan
It happens. You're welcome.
And besides, my variables are prettier anyway. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446486833801,
"lm_q1q2_score": 0.8607401173852395,
"lm_q2_score": 0.8840392832736083,
"openwebmath_perplexity": 1382.927568327193,
"openwebmath_score": 0.837983250617981,
"tags": null,
"url": "http://mathhelpforum.com/calculus/12005-integration-unsure-method.html"
} |
Thanks a lot Dan
It happens. You're welcome.
And besides, my variables are prettier anyway.
-Dan
6. Originally Posted by topsquark
It happens. You're welcome.
And besides, my variables are prettier anyway.
-Dan
Nu-uh, u is a much more suitable variable for substitution, most text books use u. You're just fighting the system.
Do you know what they do to non-conformists in the math field?!
7. Thanks guys so much, you really helped me out. I do have one question though.
Originally Posted by topsquark
One more trick and we're done. Pull a 1/4 out from under the radical:
Int[1/((1/4)(2y)^2 - 1/4)^{1/2}dy] = 2*Int[1/((2y)^2 - 1)^{1/2}dy]
And now let z = 2y, dz = 2dy and your integral becomes:
Int[1/(x^2-3x+2)^{1/2}dx] = Int[1/(y^2 - 1/4)^{1/2}dy] = Int[1/(z^2 - 1)^{1/2}dz]
topsquark: I understand we're essentially "manipulating" our equation so we can effectively use trig substitution, but I kind-of got lost in the process. I have trouble grasping it after we pull out the 1/4.? Is there anyway you (or Jhevon since you got it as well) could explain that part to me a bit more?
Thanks a ton.
8. Originally Posted by ChaosBlue
Thanks guys so much, you really helped me out. I do have one question though.
topsquark: I understand we're essentially "manipulating" our equation so we can effectively use trig substitution, but I kind-of got lost in the process. I have trouble grasping it after we pull out the 1/4.? Is there anyway you (or Jhevon since you got it as well) could explain that part to me a bit more?
Thanks a ton.
When he said pull out 1/4, he meant we factorized the function to obtain (1/4)*(something), he did that so he could get something of the form u^2 - 1 under the square root
9. Originally Posted by Jhevon
When he said pull out 1/4, he meant we factorized the function to obtain (1/4)*(something), he did that so he could get something of the form u^2 - 1 under the square root
I worded my question poorly (my bad ). What I mean is this. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446486833801,
"lm_q1q2_score": 0.8607401173852395,
"lm_q2_score": 0.8840392832736083,
"openwebmath_perplexity": 1382.927568327193,
"openwebmath_score": 0.837983250617981,
"tags": null,
"url": "http://mathhelpforum.com/calculus/12005-integration-unsure-method.html"
} |
I get where we use completing the square to transform:
int 1/sqrt(x^2-3x+2) dx--> int 1/sqrt( (x-3/2)^2 - 1/4 )dx
From there we have u = x-3/2 and therefore du = dx
Plug in and we get int 1/ (u^2 - 1/4)^1/2 du
Now, we pull out or factor out the 1/4; But I am struggling with when we do that, how
int 1/ (u^2 - 1/4)^1/2 du becomes
Int[1/((1/4)(2u)^2 - 1/4)^{1/2}du]
(we pull out 1/4, so how does u^2 become 2u^2 ?
and then
2*Int[1/((2u)^2 - 1)^{1/2}du]
Sorry for bothering you guys so much!
10. Originally Posted by ChaosBlue
I worded my question poorly (my bad ). What I mean is this.
I get where we use completing the square to transform:
int 1/sqrt(x^2-3x+2) dx--> int 1/sqrt( (x-3/2)^2 - 1/4 )dx
From there we have u = x-3/2 and therefore du = dx
Plug in and we get int 1/ (u^2 - 1/4)^1/2 du
Now, we pull out or factor out the 1/4; But I am struggling with when we do that, how
int 1/ (u^2 - 1/4)^1/2 du becomes
Int[1/((1/4)(2u)^2 - 1/4)^{1/2}du]
(we pull out 1/4, so how does u^2 become 2u^2 ?
and then
2*Int[1/((2u)^2 - 1)^{1/2}du]
Sorry for bothering you guys so much!
it's no bother, we're all here to learn.
ok, here it is. Say we had some function b, and we wanted to factor an a out of it, we could write is as a*(b/a).
similarly, when he factored 1/4 out of u^2, he ended up with (1/4)*(u^2/(1/4))
u^2/(1/4) = u^2/(1/2)^2 = [u/(1/2)]^2 = 2u^2
11. Funny you should say thanks, we actually left the hard part to you
12. Originally Posted by Jhevon
Nu-uh, u is a much more suitable variable for substitution, most text books use u. You're just fighting the system.
Do you know what they do to non-conformists in the math field?!
Good thing I'm not in the Math field, then.
-Dan
13. Originally Posted by topsquark
Good thing I'm not in the Math field, then.
-Dan
It's even worst in the physics field, which i suppose you're a part of | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446486833801,
"lm_q1q2_score": 0.8607401173852395,
"lm_q2_score": 0.8840392832736083,
"openwebmath_perplexity": 1382.927568327193,
"openwebmath_score": 0.837983250617981,
"tags": null,
"url": "http://mathhelpforum.com/calculus/12005-integration-unsure-method.html"
} |
-Dan
It's even worst in the physics field, which i suppose you're a part of
14. Originally Posted by Jhevon
It's even worst in the physics field, which i suppose you're a part of
Yes, but as long as you define your variables, you can technically get away with any set of variables you wish.
I think I'm going to create a unit called the "Dan." It'll be defined as the amount of work needed to translate an equation from the variable z to the variable u...
-Dan
15. Originally Posted by topsquark
Yes, but as long as you define your variables, you can technically get away with any set of variables you wish.
I think I'm going to create a unit called the "Dan." It'll be defined as the amount of work needed to translate an equation from the variable z to the variable u...
-Dan
haha, bless your heart Dan, you need help
Page 1 of 2 12 Last | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446486833801,
"lm_q1q2_score": 0.8607401173852395,
"lm_q2_score": 0.8840392832736083,
"openwebmath_perplexity": 1382.927568327193,
"openwebmath_score": 0.837983250617981,
"tags": null,
"url": "http://mathhelpforum.com/calculus/12005-integration-unsure-method.html"
} |
# Is it possible to write a sum as an integral to solve it?
I was wondering, for example,
Can:
$$\sum_{n=1}^{\infty} \frac{1}{(3n-1)(3n+2)}$$
Be written as an Integral? To solve it. I am NOT talking about a method for using tricks with integrals.
But actually writing an integral form. Like
$$\displaystyle \sum_{n=1}^{\infty} \frac{1}{(3n-1)(3n+2)} = \int_{a}^{b} g(x) \space dx$$
What are some general tricks in finding infinite sum series.
• math.stackexchange.com/questions/1002440/… – lab bhattacharjee Nov 3 '14 at 13:26
• @labbhattacharjee, I did not meant that. I know the solution to this, I was just asking if in general it is possible to write a sum as an actual integral. – Amad27 Nov 3 '14 at 13:28
• You can trivially write the sum as an integral using the Iverson bracket (add a factor of $[n \in \mathbb{N}]$ to the integrand). This ignores the question of how to evaluate the resulting integral, of course. – chepner Nov 3 '14 at 19:10
• "I am NOT talking about a method for using tricks with integrals." "But actually writing an integral form." "What are some general tricks" Combining these quotes with the accepted answer that does not seem to be a general trick, I'm a bit confused on what this question is asking. – JiK Nov 4 '14 at 8:28
• @Amad27 $\int_\mathbb{N}\frac{d \mu}{(3n-1)(3n+2)}$ where $\mu$ is the counting measure on $\mathbb{N}$. It doesn't give you anything you didn't already have though. I didn't really mean it seriously although it is true. – Tim Seguine Nov 5 '14 at 17:21
A General Trick | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446463891303,
"lm_q1q2_score": 0.8607401138697173,
"lm_q2_score": 0.8840392817460333,
"openwebmath_perplexity": 633.7219715032601,
"openwebmath_score": 0.9224899411201477,
"tags": null,
"url": "https://math.stackexchange.com/questions/1004081/is-it-possible-to-write-a-sum-as-an-integral-to-solve-it"
} |
A General Trick
A General Trick for summing this series is to use Telescoping Series: \begin{align} \sum_{n=1}^\infty\frac1{(3n-1)(3n+2)} &=\frac13\lim_{N\to\infty}\sum_{n=1}^N\left(\frac1{3n-1}-\frac1{3n+2}\right)\\ &=\frac13\lim_{N\to\infty}\left[\sum_{n=1}^N\frac1{3n-1}-\sum_{n=1}^N\frac1{3n+2}\right]\\ &=\frac13\lim_{N\to\infty}\left[\sum_{n=0}^{N-1}\frac1{3n+2}-\sum_{n=1}^N\frac1{3n+2}\right]\\ &=\frac13\lim_{N\to\infty}\left[\frac12-\frac1{3N+2}\right]\\ &=\frac16 \end{align}
An Integral Trick
Since $$\int_0^\infty e^{-nt}\,\mathrm{d}t=\frac1n$$ for $n\gt0$, we can write \begin{align} \sum_{n=1}^\infty\frac1{(3n-1)(3n+2)} &=\sum_{n=1}^\infty\frac13\int_0^\infty\left(e^{-(3n-1)t}-e^{-(3n+2)t}\right)\mathrm{d}t\\ &=\frac13\int_0^\infty\frac{e^{-2t}-e^{-5t}}{1-e^{-3t}}\mathrm{d}t\\ &=\frac13\int_0^\infty e^{-2t}\,\mathrm{d}t\\ &=\frac16 \end{align} | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446463891303,
"lm_q1q2_score": 0.8607401138697173,
"lm_q2_score": 0.8840392817460333,
"openwebmath_perplexity": 633.7219715032601,
"openwebmath_score": 0.9224899411201477,
"tags": null,
"url": "https://math.stackexchange.com/questions/1004081/is-it-possible-to-write-a-sum-as-an-integral-to-solve-it"
} |
• I think this is a better "trick" for dealing with sums. Integral "tricks" are nice however integrals and infinite series' are very different in what they calculate and manipulating a sum or integral on its own without switching is preferred. – Ali Caglayan Nov 3 '14 at 16:23
• @Alizter: For the most part, I agree. However, sometimes pure series manipulation can be extremely complicated, and the proper integral representation of a sum can be useful. However, in this case, I think staying with series manipulation is easiest. That being said, I have added an integral approach, as well. – robjohn Nov 3 '14 at 18:40
• The sum under the first integral could have been computed as a telescoping series either. Considering this, I think the use of integrals in the second solution is completely void. Edit: I mean exactly what Henning Makholm points out under the other answer. – Adayah Nov 4 '14 at 19:41
• @Adayah: My reply to Henning was meant as an agreement. I first posted only the telescoping series, but then added an integral approach to satisfy the first part of the question. In any approach where one breaks up the summand using partial fractions, it could be said that, at that point, the answer could be computed as a telescoping sum. – robjohn Nov 4 '14 at 20:48
Since $\int_{0}^{1}x^k\,dx = \frac{1}{k+1}$, $$\frac{1}{(3n-1)(3n+2)}=\frac{1}{3}\left(\frac{1}{3n-1}-\frac{1}{3n+2}\right)=\frac{1}{3}\int_{0}^{1}x^{3n-2}(1-x^3)\,dx,$$ so, summing over $n$: $$\sum_{n=1}^{+\infty}\frac{1}{(3n-1)(3n+2)}=\frac{1}{3}\int_{0}^{1}x\,dx=\frac{1}{6}.$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446463891303,
"lm_q1q2_score": 0.8607401138697173,
"lm_q2_score": 0.8840392817460333,
"openwebmath_perplexity": 633.7219715032601,
"openwebmath_score": 0.9224899411201477,
"tags": null,
"url": "https://math.stackexchange.com/questions/1004081/is-it-possible-to-write-a-sum-as-an-integral-to-solve-it"
} |
• I thought we need uniform convergence in order to interchange the limit and integral. The power series is uniformly convergent inside the radius of convergence, how to pass it to the whole interval $[0,1]$? – John Nov 3 '14 at 13:45
• @JohnZHANG Actually no, Fubini and Tonelli's theorems allow this for a monotone sequence supposedly, I believe. – Amad27 Nov 3 '14 at 13:45
• Nice trick for the given sum, but this still doesn't answer the bold-marked question of general tricks. – Ruslan Nov 3 '14 at 16:34
• Isn't the integral just a detour here? The operative step is exactly the same telescoping that could have been done without rewriting the terms into integrals. – Henning Makholm Nov 4 '14 at 10:11
• @HenningMakholm: smoke and mirrors. – robjohn Nov 4 '14 at 12:07
Actually writing it as an integral, as asked for:
$$\displaystyle \sum_{n=1}^{\infty} \frac{1}{(3n-1)(3n+2)} = \int_{1}^{\infty} \frac{1}{(3\lfloor x\rfloor-1)(3\lfloor x\rfloor+2)} dx$$
This probably won't help with finding the value, though.
• why won't it help finding the value? – Amad27 Nov 4 '14 at 13:20
• @Amad27: I don't see a way it would. If you can find one, then more power to you, I suppose ... – Henning Makholm Nov 4 '14 at 13:33
• @Amad27 Methods for solving integrals are poorly suited for integrating functions that are non-continuous. The usual approach for integrating functions like the one here is to separately integrate over each interval where it is continuous. Which brings us back to the sum form. – Rafał Dowgird Nov 4 '14 at 15:11
• @Amad27 It is quite literally equivalent to the original sum in a trivially useless manner XD – Simply Beautiful Art Jan 12 '17 at 2:11 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446463891303,
"lm_q1q2_score": 0.8607401138697173,
"lm_q2_score": 0.8840392817460333,
"openwebmath_perplexity": 633.7219715032601,
"openwebmath_score": 0.9224899411201477,
"tags": null,
"url": "https://math.stackexchange.com/questions/1004081/is-it-possible-to-write-a-sum-as-an-integral-to-solve-it"
} |
In such cases, the partial fractions of general term (i.e. $n^{th}$ term ) of the infinite-series are very useful.
Given that $$\sum_{n=1}^{\infty}\frac{1}{(3n-1)(3n+2)}=\sum_{n=1}^{\infty} T_{n}$$ Where, $T_{n}$ is the $n^{th}$ term of the given series which can be easily expressed in the partial fractions as follows $$T_{n}=\frac{1}{(3n-1)(3n+2)}=\frac{1}{3}\left(\frac{1}{3n-1}-\frac{1}{3n+2}\right)$$ Now, we have $$\sum_{n=1}^{\infty}\frac{1}{(3n-1)(3n+2)}=\frac{1}{3}\sum_{n=1}^{\infty} \left(\frac{1}{3n-1}-\frac{1}{3n+2}\right)$$ $$=\frac{1}{3} \lim_{n\to \infty} \left[\left(\frac{1}{2}-\frac{1}{5}\right)+\left(\frac{1}{5}-\frac{1}{8}\right)+\left(\frac{1}{8}-\frac{1}{11}\right)+\! \cdot \! ........ +\left(\frac{1}{3n-4}-\frac{1}{3n-1}\right)+\left(\frac{1}{3n-1}-\frac{1}{3n+2}\right)\right]$$ $$=\frac{1}{3} \lim_{n\to \infty} \left[\frac{1}{2} -\frac{1}{3n+2}\right]$$ $$=\frac{1}{3} \left[\frac{1}{2} -\frac{1}{\infty}\right]$$ $$=\frac{1}{3} \left[\frac{1}{2}\right]=\color{blue}{\frac{1}{6}}$$
We can indeed write the sum as an integral, after research. Consider:
Find: $\psi(1/2)$
By definition:
$$\psi(z+1) = -\gamma + \sum_{n=1}^{\infty} \frac{z}{n(n+z)}$$
The required $z$ is $z = -\frac{1}{2}$
so let $z = -\frac{1}{2}$
$$\psi(1/2) = -\gamma + \sum_{n=1}^{\infty} \frac{-1}{2n(n - \frac{1}{2})}$$
Simplify this: $$\psi(1/2) = -\gamma - \sum_{n=1}^{\infty} \frac{1}{n(2n - 1)}$$
The sum seems difficult, but really isnt.
We can telescope or:
$$\frac{1}{1-x} = \sum_{n=1}^{\infty} x^{n-1}$$
Let $x \rightarrow x^2$
$$\frac{1}{1-x^2} = \sum_{n=1}^{\infty} x^{2n-2}$$
Integrate once:
$$\tanh^{-1}(x) = \sum_{n=1}^{\infty} \frac{x^{2n-1}}{2n-1}$$
Integrate again:
$$\sum_{n=1}^{\infty} \frac{x^{2n}}{(2n-1)(n)} = 2\int \tanh^{-1}(x) dx$$
From the tables, the integral of $\tanh^{-1}(x)$
$$\sum_{n=1}^{\infty} \frac{x^{2n}}{(2n-1)(n)} = \log(1 - x^2) + 2x\tanh^{-1}(x)$$
Take the limit as $x \to 1$
$$\sum_{n=1}^{\infty} \frac{1}{(2n-1)(n)} = \log(4)$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446463891303,
"lm_q1q2_score": 0.8607401138697173,
"lm_q2_score": 0.8840392817460333,
"openwebmath_perplexity": 633.7219715032601,
"openwebmath_score": 0.9224899411201477,
"tags": null,
"url": "https://math.stackexchange.com/questions/1004081/is-it-possible-to-write-a-sum-as-an-integral-to-solve-it"
} |
Take the limit as $x \to 1$
$$\sum_{n=1}^{\infty} \frac{1}{(2n-1)(n)} = \log(4)$$
$$\psi(1/2) = -\gamma - \sum_{n=1}^{\infty} \frac{1}{(2n-1)(n)}$$
$$\psi(\frac{1}{2}) = -\gamma - \log(4)$$
• I am the OP per say. This is a general trick. I converted the sum into an integral. Please read carefully. – Amad27 Dec 21 '14 at 8:15
Yes you can use the Euler Maclaruin formula to write the sum as an integral plus an infinite number of derivatives. I remember deriving this for my self when I was younger and being very pleased with myself.
This particular sum could be solved because you had two terms $ax+b$ and $ax+c$ and the difference between c and b is equal to a (I think it would work in a slightly more complicated way if it was a not-too-large multiple of a).
If you want numerical values in general cases, and the sum doesn't converge quickly for your taste, or you want just a partial sum, you can use that
$$\displaystyle f (k) = \int_{k-1/2}^{k+1/2} f(k) dx ≈ \int_{k-1/2}^{k+1/2} f(x) dx$$
and therefore
$$\displaystyle \sum_{k=n}^{m} f(k) ≈ \int_{n-1/2}^{m+1/2} f(x) dx$$
Assuming that you can solve the integral in closed form, if you let
$$\displaystyle g (k) = f(k) - \int_{k-1/2}^{k+1/2} f(x) dx$$
then
$$\displaystyle \sum_{k=n}^{m} f(k) = \int_{n-1/2}^{m+1/2} f(x) dx + \sum_{k=n}^{m} g(k)$$
$g (k)$ will usually converge much faster than $f (k)$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446463891303,
"lm_q1q2_score": 0.8607401138697173,
"lm_q2_score": 0.8840392817460333,
"openwebmath_perplexity": 633.7219715032601,
"openwebmath_score": 0.9224899411201477,
"tags": null,
"url": "https://math.stackexchange.com/questions/1004081/is-it-possible-to-write-a-sum-as-an-integral-to-solve-it"
} |
# How can I determine which of two sequences of coin flips is real and which is fake?
This is an interesting problem I came across. I'm attempting to write a Python program to get a solution to it; however, I'm not sure how to proceed. So far, I know that I would expect the counts of heads to follow a binomial, and length of runs (of tails, heads, or both) to follow a geometric.
Below are two sequences of 300 “coin flips” (H for heads, T for tails). One of these is a true sequence of 300 independent flips of a fair coin. The other was generated by a person typing out H’s and T’s and trying to seem random. Which sequence is truly composed of coin flips?
Sequence 1:
TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHH TTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHH TTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHT THHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHT HTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTT HHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT
Sequence 2:
HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTH THTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHH TTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTT THTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTH HHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHH HTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT
Both sequences have 148 heads, two less than the expected number for a 0.5 probability of heads. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
Both sequences have 148 heads, two less than the expected number for a 0.5 probability of heads.
• Naive qustion : Does the question means: can I find with that porbablity that such sequence is generated by human is big enough ? Can I compute such probablity ? Every sequence is possible, so this is not a proof but only possibility. Am I right ?
May 7 at 8:53
• (I find it truly amusing that somebody voted to close this thread because it asks for opinions. If that were true, we should close all threads here on CV that use statistical analysis to compare data--and that would leave us with nothing but lists of references!)
– whuber
May 7 at 13:42
• Compress both strings and see which one comes out shorter. May 7 at 13:58
• @whuber That comment is probably a reference to (approximate) Kolmogorov complexity. See algorithmically random sequence. May 7 at 15:45
• @whuber With very high probability, a truly random sequence cannot be compressed. Compression methods can leverage many kinds of bias, not only if one symbol appears more overall, but also if some subsequences appear more than others (as here, H is more likely to be followed by T and vice versa, per your answer). May 7 at 18:20
This is a variant on a standard intro stats demonstration: for homework after the first class I have assigned my students the exercise of flipping a coin 100 times and recording the results, broadly hinting that they don't really have to flip a coin and assuring them it won't be graded. Most will eschew the physical process and just write down 100 H's and T's willy-nilly. After the results are handed in at the beginning of the next class, at a glance I can reliably identify the ones who cheated. Usually there are no runs of heads or tails longer than about 4 or 5, even though in just 100 flips we ought to see a longer run that that. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
This case is subtler, but one particular analysis stands out as convincing: tabulate the successive ordered pairs of results. In a series of independent flips, each of the four possible pairs HH, HT, TH, and TT should occur equally often--which would be $$(300-1)/4 = 74.75$$ times each, on average.
Here are the tabulations for the two series of flips:
Series 1 Series 2
H T H T
H 46 102 71 76
T 102 49 77 75
The first is obviously far from what we might expect. In that series, an H is more than twice as likely ($$102:46$$) to be followed by a T than by another H; and a T, in turn, is more than twice as likely ($$102:49$$) to be followed by an H. In the second series, those likelihoods are nearly $$1:1,$$ consistent with independent flips.
A chi-squared test works well here, because all the expected counts are far greater than the threshold of 5 often quoted as a minimum. The chi-squared statistics are 38.3 and 0.085, respectively, corresponding to p-values of less than one in a billion and 77%, respectively. In other words, a table of pairs as imbalanced as the second one is to be expected (due to the randomness), but a table as imbalanced as the first happens less than one in every billion such experiments.
(NB: It has been pointed out in comments that the chi-squared test might not be applicable because these transitions are not independent: e.g., an HT can be followed only by a TT or TH. This is a legitimate concern. However, this form of dependence is extremely weak and has little appreciable effect on the null distribution of the chi-squared statistic for sequences as long as $$300.$$ In fact, the chi-squared distribution is a great approximation to the null sampling distribution even for sequences as short as $$21,$$ where the counts of the $$21-1=20$$ transitions that occur are expected to be $$20/4=5$$ of each type.) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
If you know nothing about chi-squared tests, or even if you do but don't want to program the chi-square quantile function to compute a p-value, you can achieve a similar result. First develop a way to quantify the degree of imbalance in a $$2\times 2$$ table like this. (There are many ways, but all the reasonable ones are equivalent.) Then generate, say, a few hundred such tables randomly (by flipping coins--in the computer, of course!). Compare the imbalances of these two tables to the range of imbalances generated randomly. You will find the first sequence is far outside the range while the second is squarely within it.
This figure summarizes such a simulation using the chi-squared statistic as the measure of imbalance. Both panels show the same results: one on the original scale and the other on a log scale. The two dashed vertical lines in each panel show the chi-squared statistics for Series 1 (right) and Series 2 (left). The red curve is the $$\chi^2(1)$$ density. It fits the simulations extremely well at the right (higher values). The discrepancies for low values occur because this statistic has a discrete distribution which cannot be well approximated by any continuous distribution where it takes on small values -- but for our purposes that makes no difference at all. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
• Why do you say, "This case is subtler" (than just looking for runs)? OP's sequence 1 has length 300 (longer than the 100 you mention) and its longest run is a single HHHH. So it doesn't seem subtle at all, but rather a slam dunk for the "at a glance" method you describe. May 7 at 18:11
• It's not proper to apply the chi squared test to the contingency table given since consecutive pairs are overlapping and not independent, so p-values will be exaggerated. I suspect the result will be similar after addressing this though.
– Paul
May 7 at 18:11
• @Paul That's an excellent point, which I have neglected to discuss (and it's no excuse to claim, as I was hoping to do, that it's implicitly handled correctly in the last paragraph, because I did not advertise that fact).
– whuber
May 7 at 18:13
• @klm123 But as long as you don't actually try a bunch of tests before finding an improbable result (p-hacking), the result is still significant. The test(s) should be chosen in advance. There are also ways of correcting p-values if you run multiple tests. Yes, there is the potential to be misleading if you only report the significant test and not the others -- this has contributed to the "replication crisis". May 7 at 23:07
• My answer talks about why this test in particular is well-motivated. People tend to think that non-repeated values are more random than repeated values. (Which is true in some sense, but people believe it to a greater extent / in more generality than is actually true.)
– Paul
May 7 at 23:25
There are two very good answers as of writing this, and so let me add a needlessly complex yet interesting approach to this problem. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
I think one way to operationalize the human generated vs truly random question is to ask if the flips are autocorrelated. The hypothesis here being that humans will attempt to appear random by not having too many strings of one outcome, hence switching from heads to tails and tails to heads more often than would be observed in a truly random sequence.
Whuber examines this nicely with a 2x2 table, but because I am a Bayesian and a glutton for punishment let's write a simple model in Stan to estimate the lag-1 autocorrelation of the flips. Speaking of Whuber, he has nicely laid out the data generating process in this post. You can read his answer to understand the data generating process.
Let $$\rho$$ be the lag 1 autocorrelation of the flips, and let $$q$$ be the proportion of flips which are heads in the sequence. A fair coin should have 0 autocorrelation, so we are looking for our estimate of $$\rho$$ to be close to 0. From there, we only need to count the number of occurrences of $$H,H$$, $$H, T$$, $$T, H$$ and $$T,T$$ in the sequence.
The Stan model is shown below
data{
int y_1_1; //number of concurrent 1s
int y_0_1; //number of 0,1 occurrences
int y_1_0; //number of 1,0 occurrences
int y_0_0; //number of concurrent 0s
}
parameters{
real<lower=-1, upper=1> rho;
real<lower=0, upper=1> q;
}
transformed parameters{
real<lower=0, upper=1> prob_1_1 = q + rho*(1-q);
real<lower=0, upper=1> prob_0_1 = (1-q)*(1-rho);
real<lower=0, upper=1> prob_1_0 = q*(1-rho);
real<lower=0, upper=1> prob_0_0 = 1 - q + rho*q;
}
model{
q ~ beta(1, 1);
target += y_1_1 * bernoulli_lpmf(1| prob_1_1);
target += y_0_1 * bernoulli_lpmf(1| prob_0_1);
target += y_1_0 * bernoulli_lpmf(1| prob_1_0);
target += y_0_0 * bernoulli_lpmf(1| prob_0_0);
}
Here, I've placed a uniform prior on the autocorrelation
$$\rho \sim \mbox{Uniform}(-1, 1)$$
and on the probability of a head
$$q \sim \operatorname{Beta}(1, 1)$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
and on the probability of a head
$$q \sim \operatorname{Beta}(1, 1)$$
Our likelihood is Bernoulli, and I have weighted the likelihood by the number of occurrences of each pair of outcomes. The probabilities of each outcome (e.g. probability of observing a heads conditioned on the previous flip being a heads) is provided by Whuber in his linked answer. Let's run our model and compare posterior distributions for the two sequences
The estimated auto correlation for sequence 1 is -0.36, and the estimated autocorrelation for sequence 2 is -0.02 (close enough to 0). If I was a betting man, I'd put my money on sequence 1 being the sequence generated by a human. The negative autocorrelation means that when we see a heads/tails we are more likely to see a tails/heads! This observation lines up nicely with the 2x2 table provided by Whuber.
### Code
The plot I present is made in R, but here is some python code to do the same thing since you asked
import matplotlib.pyplot as plt
import cmdstanpy
# You will need to install cmdstanpy prior to running this code
# Write the stan model as a string. We will then write it to a file
stan_code = '''
data{
int y_1_1; //number of concurrent 1s
int y_0_1; //number of 0,1 occurences
int y_1_0; //number of 1,0 occurences
int y_0_0; //number of concurrent 0s
}
parameters{
real<lower=-1, upper=1> rho;
real<lower=0, upper=1> q;
}
transformed parameters{
real<lower=0, upper=1> prob_1_1 = q + rho*(1-q);
real<lower=0, upper=1> prob_0_1 = (1-q)*(1-rho);
real<lower=0, upper=1> prob_1_0 = q*(1-rho);
real<lower=0, upper=1> prob_0_0 = 1 - q + rho*q;
}
model{
q ~ beta(1, 1);
target += y_1_1 * bernoulli_lpmf(1| prob_1_1);
target += y_0_1 * bernoulli_lpmf(1| prob_0_1);
target += y_1_0 * bernoulli_lpmf(1| prob_1_0);
target += y_0_0 * bernoulli_lpmf(1| prob_0_0);
}
'''
# Write the model to a temp file
with open('model_file.stan', 'w') as model_file:
model_file.write(stan_code) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
# Compile the model
model = cmdstanpy.CmdStanModel(stan_file='model_file.stan', compile=True)
# Co-occuring counts for heads (1) and tails (0) for each sequence
data_1 = dict(y_1_1 = 46, y_0_0 = 49, y_0_1 = 102, y_1_0 = 102)
data_2 = dict(y_1_1 = 71, y_0_0 = 75, y_0_1 = 76, y_1_0 = 77)
# Fit each model
fit_1 = model.sample(data_1, show_progress=False)
rho_1 = fit_1.stan_variable('rho')
fit_2 = model.sample(data_2, show_progress=False)
rho_2 = fit_2.stan_variable('rho')
# Make a pretty plot
fig, ax = plt.subplots(dpi = 240, figsize = (5, 3))
ax.set_xlim(-1, 1)
ax.hist(rho_1, color = 'blue', alpha = 0.5, edgecolor='k', label='Sequence 1')
ax.hist(rho_2, color = 'red', alpha = 0.5, edgecolor='k', label='Sequence 2')
ax.legend()
$$$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
• +1 I developed my tabular explanation by going through the exercise you lay out here. I plotted the PACF functions of random sequences and compared them, visually, to the PACF functions of the two sequences in the question. One plot--the first sequence--stood out: it had a very negative lag-one partial autocorrelation coefficient. But motivating and explaining the PACF seemed like overkill for this problem ;-). The more enduring lesson, illustrated here and in the post by @COOLSerdash, is that by finding a suitable way to visualize data, we can discover otherwise hidden things about them.
– whuber
May 7 at 13:28
• (+1) Interesting resolution that does not rely on insufficient statistics, contrary to the others!, but I would have gone fully Markov and put a prior distribution on both $(p_{11},p_{10})$ and $(p_{01},p_{00})$ rather than introducing a correlation $\rho$, but it is unlikely the result would differ. More generally, the alternative to being an iid Uniform sequence could be anything, so restricting to an order one Markov is favouring the null. May 9 at 8:09
• @Xi'an You're right in that the result is not much different. The reason I prefer the $\rho$, $q$ parameterization is because we actually have good priors on these (despite what my answer uses lol). Humans have an intuitive sense for when they are acting too correlated and when they are acting too biased, so we know $\rho$ is going to be close to 0 and $q$ close to 0.5. But, you could rewrite this model using a multinomial likelihood and place priors on the probabilities directly too. That's what I love about Bayes! May 9 at 17:48 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
This is a class activity I've first read about in the book Teaching Statistics. A Bag of Tricks, 2nd ed. by Andrew Gelman and Deborah Nolan (they recommend 100 flips, though). Their reasoning to detect the fabricated sequence is based on the combination of the longest run and the number of runs. For the following plot, I simulated 5000 fair coin tosses of length 300 and plotted the longest run on the y-axis and the number of runs on the x-axis (I once asked a question about the explicit joint probability). Each dot represents the result of 300 fair flips. For better visibility, the points are jittered. The numbers for the two sequences are plotted in color. The conclusion is obvious.
For a quick calculation, recall that a rule of thumb for the longest run of either heads or tails in $$n$$ tosses is$$^{[1]}$$ $$l = \log_{1/p}(n(1-p)) + 1$$. For an approximate 95% prediction interval, just add and subtract $$3$$ from this value. Surprisingly, this number (i.e. $$\pm 3$$) does not depend on $$n$$! Applied to a fair coin with $$n=300, p=1/2$$, we have $$l=\log_2(300/2) + 1=8.22$$. So we expect the longest run to be round $$8$$ and reasonably in the range of $$8\pm 3$$, so between $$5$$ and $$11$$. The longest run in sequence 2 is $$8$$, whereas it is $$4$$ in sequence 1. As this is outside the approximate prediction interval, we'd conclude that sequence 1 is suspicious under the assumption of $$p=1/2$$.
$$[1]$$ Schilling MF (2012): The Surprising Predictability of Long Runs. Math. Mag. 85: 141-149. (link)
• Excellent answer and graph. "Surprisingly, this number does not depend on n!" You're talking about +-3, right? I was confused for a while since you define $l$ just before, which obvisouly depends on $n$. May 9 at 14:48
• @EricDuminil Yes, sorry. The value that does not depend on $n$ is the $\pm 3$ for the prediction interval. May 9 at 15:45 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
The runs test (NIST page) is a nonparametric test designed to identify unusual frequencies of runs. If we observe $$n_1$$ heads and $$n_2$$ tails, the expected value and variance of the number of runs are:
$$\mu = {2n_1n_2 \over n_1+n_2} + 1$$ $$\sigma^2 = {2n_1n_2(2n_1n_2 - n_1 - n_2) \over (n_1+n_2)^2(n_1+n_2+1)}$$
As a rule of thumb, for $$n_1, n_2 \geq 10$$ the distribution of the observed number of runs is reasonably well-approximated by a Normal distribution.
Edit: (incorporating Eric Duminil's work below)
For sequence 1, we have 148 heads, 152 tails, 205 runs, and for sequence 2, we have 148 heads, 152 tails and 154 runs. Plugging these numbers into our formulae above give us $$z$$-scores of 6.5 for the first sequence and 0.58 for the second sequence - extremely strong evidence that the first sequence is fake.
When people fake sequences like this, they tend to greatly underestimate the probability of longer runs, so they don't create as many long(ish) runs as they should. This in turn tends to increase the number of runs beyond that which would be expected. Consequently, when testing for faked data, we might prefer a one-sided test of the alternative hypothesis that there are "too many" runs vs. the null hypothesis that the number of runs is average - at least if we think the sequence was created by a human being. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
• Yep, this is a classic application of gambler's fallacy. May 6 at 21:54
• There are 62 runs in the first two rows, AFAICT. For the whole sequence #1 : 148 heads, 152 tails, 205 runs. Vs 148 heads, 152 tails and 154 runs for sequence #2. May 9 at 14:56
• Thanks, @EricDuminil - I've included your efforts in the body of the answer with a citation. May 9 at 16:46
• That's good. But it leaves unanswered why you would formulate a question in terms of longest run and then solve it by looking at an indirect proxy (number of runs). Why not just use the longest run as the test statistic?
– whuber
May 9 at 18:13
• @whuber - it's not just the longest run that's informative, it's the number of longer runs in general, and I don't have a good idea of a cutoff for run length for testing. Having said that, using the longest run as a test statistic with 100,000 randomly generated strings with 148 heads and 152 tails for calculating an approximate p-value gives a p-value of 0.00004 for the first sequence. Maybe I'll expand on that over (my) lunch. May 9 at 18:28
Here's an empirical approach, based on compression as a proxy for algorithmic complexity:
import bz2
import random
import statistics
s1 = "TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHHTTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHHTTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHTTHHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHTHTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTTHHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT"
s2 = "HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTHTHTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHHTTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTTTHTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTHHHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHHHTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT"
def compressed_len(s):
return len(bz2.compress(s.encode()))
trials = []
for x in range(100000):
sr = "".join(random.choice("HT") for _ in range(300))
trials.append(compressed_len(sr)) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
mean = statistics.mean(trials)
stddev = statistics.stdev(trials)
print("Random trials:")
print("Mean:", mean)
print("Stddev:", stddev)
l1 = compressed_len(s1)
l2 = compressed_len(s2)
o1 = l1 - mean
o2 = l2 - mean
d1 = o1 / stddev
d2 = o2 / stddev
print("Selected trials:")
print("Seq", "Len", "Dev", sep="\t")
print("S1", l1, d1, sep="\t")
print("S2", l2, d2, sep="\t")
Roughly speaking:
1. Compress a bunch (100k) of random coinflips.
2. Observe the resulting length distribution. (In this case I'm approximating it as a normal distribution of lengths; a more thorough analysis would check and pick an appropriate distribution instead of blithely assuming normality.)
3. Compress the input sequences.
4. Compare with observed distribution.
Result (note: not exactly reproducible due to the use of random trials; if you want to be reproducible add a random seed):
Random trials:
Mean: 105.05893
Stddev: 2.6729774976956002
Selected trials:
Seq Len Dev
S1 88 -6.381995364609942
S2 109 1.4744119632124217
Based on this, I'd say that S1 is the non-random one here. 6.38 standard deviations below the mean is rather improbable.
The nice thing about this approach is that it's relatively generic, and takes advantage of the pre-existing work of a bunch of smart people.
Just be aware of its limitations and quirks:
1. You want a compression algorithm that's designed for space over compression speed. BZ2 works well enough here.
2. This doesn't work if the compression algorithm simply gives up and writes a raw block to the output.
3. A null result does not mean that the sequence is random. It means that this compression algorithm is unable to distinguish this input from random.
This is probably an overcomplicated way of looking at it, but for me it's fun, so I present to you...
## Moran's I | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
## Moran's I
Now, Moran's I was developed to look at spatial autocorrelation (basically autocorrelation with multiple dimensions), but it can be applied to the 1-dimensional case as well. Some of my interpretations might be a little sketchy, but you can consider your coin flips this way.
To summarize Moran's I, it will consider your neighboring values using a pre-defined matrix. How you define the matrix is up to you, but it can actually be used to consider not just the directly neighboring values, but any values beyond that. Moran's I will produce a value ranging from -1 (perfectly dispersed values) to 1 (perfectly clustered values), with 0 being random.
I wrote up some quick R code. First, setup the data (OP's data and a couple generated data sets to test dispersion and clustering):
seq1 = unlist(strsplit("TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHHTTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHHTTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHTTHHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHTHTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTTHHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT",
split = ""))
seq2 = unlist(strsplit("HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTHTHTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHHTTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTTTHTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTHHHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHHHTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT",
split = ""))
# Alternate T and H. E.g., THTHTHTHT....
# 'perfectly dispersed'
# Moran's I = -1
seq3 = rep(c("T", "H"), times = 50)
# 50 of T followed by 50 of H
# 'perfectly clustered'
# Moran's I approaches 1 as the sample size increases to infinity
seq4 = rep(c("T", "H"), each = 50)
# weights must be a vector with an odd length and the middle value set to 0
# weights are relative and do not have to add to 1
moran <- function(x, weights) {
x = c(T = 0, H = 1)[x] # convert T/H to 0/1
N = length(x)
x_mean = mean(x) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
N = length(x)
x_mean = mean(x)
den = sum((x - x_mean)^2)
W = 0
num = 0
offset = floor(length(weights)/2)
for (i in 1:length(x)) {
W = W + as.numeric(!is.na(x_slice)) %*% weights
num = num + (x[i] - x_mean) * sum((x_slice - x_mean) * weights, na.rm = TRUE)
}
return(unname((N * num)/(as.numeric(W) * den)))
}
Next, I test the generated data sets to illustrate/test that my function is working correctly:
# Test the 'perfect dispersion' scenario (should be -1)
moran(seq3, c(1, 0, 1))
## [1] -1
# Test the 'perfect clustering' scenario (should be ~1)
moran(seq4, c(1, 0, 1))
## [1] 0.979798
Now, let's look at OP's sequences:
# Simple look at seq1. The weights test the idea that the current flip
# is based purely on the last flip (a reasonable model for how a person might react)
moran(seq1, c(1, 0, 0))
## [1] -0.3647031
moran(seq2, c(1, 0, 0))
## [1] -0.02359453
I'm defining my weights matrix such that only the previous flip is considered when testing for autocorrelation. We see that the second sequence is very close to 0 (random), whereas the first sequence seems to lean somewhat toward overdispersion.
But maybe we think someone faking coin flips would consider the last two flips, not just the most recent:
# Maybe the person is looking back at the last two flips
moran(seq1, c(1, 1, 0, 0, 0))
## [1] -0.1726056
moran(seq2, c(1, 1, 0, 0, 0))
## [1] 0.0249505
The second sequence is just as close to 0 as before, but the first sequence had a pretty noticeable shift towards 0. This might be interpretable in a couple of different ways. First, if we know that the first sequence is fake, then maybe it means the person wasn't considering two flips back. A second interpretation is that maybe they were considering the last two flips, and somehow this led them to doing a better job at faking randomization. A third option might just be sheer dumb luck at faking the randomization. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
Now, maybe the person considers the last two coin flips but gives the most recent flip more importance.
# Same idea, but maybe the more recent of the two is twice as important
moran(seq1, c(1, 2, 0, 0, 0))
## [1] -0.2367095
moran(seq2, c(1, 2, 0, 0, 0))
## [1] 0.008750762
Here, we see the two sequences react differently. The second sequence (already pretty close to 0), gets noticeably closer to 0, whereas the first sequence shifts noticeably away. I'm not sure I want to try and interpret this, but it's an interesting result, and a similar thing happens if we try to model a scenario where the person is not only considering their previous flips but also thinking ahead to their next flip:
# Maybe the person was thinking ahead to their next flip as well
moran(seq1, c(1, 2, 0, 1, 0))
## [1] -0.2687347
moran(seq2, c(1, 2, 0, 1, 0))
## [1] 0.0006576715
Some of my application/interpretation of Moran's I to the coin flip problem might be a little off, but it's definitely an applicable measure to use.
A related metric is Geary's C, which is more sensitive to local autocorrelation
When people try to generate random sequences, they tend to avoid repeating themselves more than random processes avoid repeating themselves. Thus, if we look at consecutive pairs of flips, we would expect a human-generated sequence to have too many HT and TH and too few HH and TT compared to a typical random sequence.
The code below explores this hypothesis. It splits each sequence of 300 flips into 150 consecutive pairs and plots the frequency of the four possible results (HH, HT, TH, TT).*
library(tidyverse) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
library(tidyverse)
a <- "TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHHTTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHHTTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHTTHHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHTHTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTTHHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT"
b <- "HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTHTHTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHHTTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTTTHTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTHHHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHHHTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT"
# split each sequence of 300 into 150 consecutive pairs
# e.g. TTHHTHTT... -> TT, HH, TH, TT, ...
n_pairs <- 150
ap <- tibble(pair = character(n))
bp <- tibble(pair = character(n))
for (i in 1:n) {
ap$$pair[i] <- substring(a, 2*i - 1, 2*i) bp$$pair[i] <- substring(b, 2*i - 1, 2*i)
}
# get the frequencies of each possible pair and plot
apc <- count(ap, pair)
bpc <- count(bp, pair)
bind_rows(
Sequence 1 = apc,
Sequence 2 = bpc,
.id = 'source') %>%
ggplot(aes(x = pair, y = n, group = source, fill = source)) +
geom_col() +
facet_grid(vars(source)) +
theme_minimal() +
geom_hline(yintercept = n_pairs/4, linetype = 'dashed') +
ylab('frequency') +
ggtitle('Frequency of consecutive coin flip pairs')
The dotted line at 150/4 = 37.5 is the expected count of each possible pair assuming the coin flips are independent and fair. By the Law of Large Numbers, we expect the bars not to stray too far from the dotted line. Sequence 1 has an above-average number of HT and TH pairs (especially HT), consistent with our hypothesis about human-generated "randomness". The pairs from Sequence 2 are more consistent with average behavior. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
To see how unusual this behavior would be under independent, fair flips, we reformat each sequence's pair count data as a 2x2 contingency table (rows = first flip H/T, columns = second flip H/T) and use Fisher's exact test, which checks whether the data is consistent with a null hypothesis in which the first flip is independent of the second:
for (x in list(apc, bpc)) {
print(x)
x %>%
mutate(f1 = str_sub(pair, 1, 1),
f2 = str_sub(pair, 2, 2)) %>%
select(f1, f2, n) %>%
select(-f1) %>%
as.matrix() %>%
fisher.test() %>%
print()
}
The contingency table for Sequence 1 has a p value of 0.0002842, while the table for Sequence 2 has 0.5127. This means that pair frequencies skewed to the degree seen in Sequence 1 would only occur by random 1/0.0002842 = 1 out of 3,519 times, while something like Sequence 2 would be seen very commonly. It seems sensible to conclude that Sequence 1 is the human-made sequence, since its pair frequency table is not consistent with random chance but is quite consistent with the behavior we'd expect of humans.
There is a caveat to this analysis: we do not expect random sequences to be perfectly consistent with average behavior. In fact, in some contexts people know that long random sequences should follow the Law of Large Numbers, and they create sequences which follow it too perfectly. A different analysis would be needed to explore whether Sequence 2 looks odd from this opposite perspective.
* Other answers look at all 299 consecutive pairs, which gives you more data points but they become dependent, which prevents us from using standard significance tests. (For example in the sequence TTHHT, you can make pairs like this: (TT)HHT, T(TH)HT, TT(HH)T, .... This gives you more pairs but consecutive pairs are not independent of one another, as the second flip of a pair determines the first flip of the next pair.)
# Alternate Analysis | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
# Alternate Analysis
An analysis that uses all 299 pairs of consecutive flips could be more powerful than the one above if the dependency problem can be solved. To do this, @whuber suggests looking at the transitions between consecutive flips, i.e. when H is followed by T or vice versa. If the flips are independent and fair, then after the first flip, each transition can be considered an independent Bernoulli random variable, and there are 299 transitions total. We can use a two-sided test to see whether the number of transitions observed in each sequence is unlikely under fair independent flips. The transitions are counted and the test applied by the code below:
library(tidyverse)
a <- "TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHHTTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHHTTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHTTHHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHTHTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTTHHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT"
b <- "HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTHTHTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHHTTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTTTHTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTHHHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHHHTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT"
# 299 transitions from flip i to i+1 occur in the sequence of 300
# record these transitions in arrays at and bt
n <- 299
at <- logical(n)
bt <- logical(n)
for (i in 1:n) {
at[i] <- str_sub(a, i + 1, i + 1) != str_sub(a, i, i)
bt[i] <- str_sub(b, i + 1, i + 1) != str_sub(b, i, i)
}
# two-sided exact binomial test (analogous to z-test)
# gives probability of transition count more extreme than the one observed
pbinom(sum(at) - 1, n, 1/2, lower.tail = F) + pbinom(n - sum(at), n, 1/2)
pbinom(sum(bt) - 1, n, 1/2, lower.tail = F) + pbinom(n - sum(bt), n, 1/2) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
Running this code, we find that Sequence 1 has 204 transitions out of a possible 299. The probability of observing a number of transitions at least this imbalanced, on either the left or the right side, is equal to the probability of observing at least 204 transitions, plus the probability of observing at most 299 - 204 = 95 transitions. This probability is 2.696248e-10, on the order of 3 in 10 billion. Sequence 2 has 153 transitions, and the probability of observing at least 153 transitions or at most 299 - 153 = 146 transitions is 0.7286639. The number of transitions in Sequence 1 is extremely improbable, more so than the 150 pair test above suggested.
• Your code seems to be doing something more complicated than you describe. It is hard to relate your plots, which are unexplained, to the data: those plots clearly do not report on sequences of length 300.
– whuber
May 7 at 14:43
• I'm splitting each length 300 sequence into 150 pairs of adjacent coin tosses and counting how many of the 150 pairs are HH, HT, TH, or TT. That's what the graphs show. I've added some comments to elaborate on this. If that's not enough, could you be more specific as to what you're struggling to understand?
– Paul
May 7 at 16:55
• I am not struggling to understand anything--I just don't care to have to read through code in order to determine what the content of an answer might be, and I believe most readers will feel the same.
– whuber
May 7 at 17:25
• Thank you: what you are doing is now more apparent. But why? Could you explain what is accomplished with this split?
– whuber
May 7 at 18:10
• I've added a transition-based analysis and it is indeed a more powerful test. Great idea.
– Paul
May 10 at 0:45
This answer is inspired by @user1717828's answer which transforms the sequence of coin flips into a random walk. I don't show the two given sequences as random walks here; see @user1717828's answer for that plot. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
The random walk approach is interesting because it examines long-run features of the sequence rather than short-range ones (such as the overabundance of H-T and T-H flips). In a way the two approaches are complementary as they analyze the sequences at different scales. At the "local" scale the fake sequence oscillates which creates autocorrelation; at the "global" scale it keeps within a limited range of positions for long stretches of time. Both of these aspects are non-random and as one occurs, so does the other: staying in place means not moving around and vice versa.
A (one-dimensional) simple random walk $$S_n$$, defined as the sum of n random variables that take value {-1, 1} with probability ½, has many interesting properties, including:
• The probability that a simple random walk returns to the origin is 1. In fact, it visits every integer infinitely often.
• The mean of a simple random walk is $$\text{E}(S_n) = 0$$ and its variance is $$\text{Var}(S_n) = n$$.
• A random walk with nonzero mean (which corresponds to flipping a biased coin) is transient: it makes finitely many visits to the origin before diverging, to +∞ if the mean is positive and to -∞ in the mean is negative.
These properties imply that a simple random walk spends a lot of time far away from 0 before eventually returning to it.
We can use this intuition founded on theory (as well as any other property of random walks) to propose characteristics for comparing the two sequences. Then we generate many simple random walks and use the observed distribution of the features to estimate how "extreme" the two given sequences are. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
To capture the variance of a simple random walk I use the maximum distance from 0. To capture its tendency to visit every integer I use the number of times the walk crosses the integers from -8 to +8. To make a symmetric grid of scatterplots and to avoid suspicions of HARKing I don't show the crossings of 0. It's important to look at crossing on both sides of 0 (the starting point), so that we don't make assumptions about how the non-randomness manifests in the data. For example, we don't know whether the coin is fair (p = ½), biased towards heads (p > ½) or biased towards tails (p < ½).
Note: HARKing is the practice of performing many analyses to find an interesting hypothesis. I compute many statistics, grounded in the theory of random walks, and report all of them, thus avoiding HARKing.
Here are the results from the simulation of 500 simple random walks. Sequence #1 (in blue) appears as an outlier compared to sequence #2 (in red) in many panels. Due to its overabundance of H-T and T-H pairs, sequence #1 doesn't explore enough and spends too much time between -5 and -8 (shown in the top row). Sequence #1 doesn't advance beyond the band [-9, 9] and it is rare for a true random walk so stay so close to 0 for 300 steps. Visually, sequence #1 is the overall outlier even if it doesn't appear extremely "unusual" is some panels. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
• +1. This explains why I did not examine this statistic in my answer: I had done so, exactly as you have, and came to the same conclusion that the max deviation statistic was suggestive but only weak evidence of a departure from randomness. But in that investigation I noted there were other visual quirks in the plot of the first series and that led to a more effective statistic for assessing the randomness of the series. It's worth noting that extensive computation is unnecessary: you could draw all your conclusions more quickly by simulating as few as 20 random walks..
– whuber
May 9 at 13:44
• @whuber After some (over)thinking, I realized that it works quite well to compute two statistics: one to represent central tendency and the other -- extreme values. Similar to COOLSerdash's solution which looks at number of runs (a kind of average) and length of longest run. With the simple random walk, zero crossings vs maximum distance from zero works very well (visually). But then I don't know how to get a p-value. May 9 at 21:35
• I think the zero crossings observation comes down to HARKing. (For instance, these could well be realizations of Markov processes in which a transition away from a side of the coin is made with probability $p$; $p\approx 2/3$ in one sequence and $p\approx 1/2$ in the other. In general I wouldn't expect zero-crossing counts to distinguish among these.) A better way to approach this would be to do all your exploration on the first half of each sequence; develop a suitable statistic from that; and apply it to the second halves of the sequences.
– whuber
May 9 at 21:39
• @whuber I don't agree it's HARKing. At least not any more than number of runs. A simple random walk returns to the start infinitely often, so given this fact it makes sense to look at zero crossings. Since the fake sequence doesn't move enough any number will do in theory; here because sequences are only 300 long every number between about -10 to 10 will work. May 9 at 22:03 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
• Ask yourself this: would you have focused on counting zero crossings by exploring just the first halves of the sequences? You might have if both of two things occurred: (1) you observed no zero crossings in one and many zero crossings in the other and (2) in simulated iid sequences, you observed a consistent tendency to have positive numbers of zero crossings. In such a case, you likely have a useful statistic. Unfortunately, you would discover that about 6.5% of the time, a Binomial random walk has no zero crossings. That's why I view this as HARKing: it's accidental.
– whuber
May 10 at 14:32 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
In addition to statistical approaches, one visual approach is to plot the sequences as a "drunkards walk". Treat H as a step forwards and T as a step back and plot the sequences. One way in Python is:
import altair as alt
import pandas as pd
seq1 = "HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTHTHTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHHTTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTTTHTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTHHHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHHHTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT"
seq2 = "TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHHTTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHHTTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHTTHHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHTHTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTTHHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT"
def encode(stream):
return [1 if c == "H" else -1 for c in stream]
df = pd.DataFrame({"seq1": encode(seq1), "seq2": encode(seq2)})
df_cumsum = pd.melt(
df.cumsum(), var_name="sequence", value_name="cumsum", ignore_index=False
).reset_index()
chart = alt.Chart(df_cumsum).mark_line().encode(x="index", y="cumsum", color="sequence")
chart.show()
When comparing a truly random sequence to a human generated one, it is often easy to tell them apart based on inspection of the walk. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
• This is a good approach. It was the first thing I tried. However, I created a context for evaluating these random walks: I also generated 18 more sequences using iid flips of a fair coin and plotted all 20. Generally, whenever I repeated this procedure, there was a truly random walk that looked like the orange one here, at least in terms of the relatively small range. Exactly which characteristic(s) suggest to you that the orange curve is not random but the blue is?
– whuber
May 8 at 12:53
• The orange one is what I think is the truly random one based on this visual. I would have guessed based on just the number of zero-crossings alone that blue is human-generated. But you're right, there's always going to be a chance that any sequence is randomly-generated, and the analytical methods are better for quantifying the odds of that. May 8 at 20:17
• Unfortunately for your theory, the orange one is the non-random one. It has an unusually low range; but more to the point, its thickened appearance is due to a huge overabundance of H-T-H oscillations.
– whuber
May 8 at 20:32
• Ahh! In that case, I'm going to rethink my approach of visualizing these things before looking at the statistics next time! May 8 at 22:29
• The thickened appearance is the feature analyzed in the answers by whuber, Dmetri Pananos and Paul. The distance from 0 in a simple random walk (which I think is what this answer is getting at) would be a different feature altogether. A (true) simple random walk will spend a lot of time away from zero until eventually returning (with probability 1). The sequences in this exercise though seem too short for this kind of argument. May 8 at 23:55 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
Looking at the HH, HT, TH, TT frequencies is probably the most straightforward way to approach the two series presented, given people's tendency to apply HT and TH more frequently when trying to appear random. More generally, however, that approach will fail to detect non-randomness even in sequences with obvious patterns. For instance, a repeating sequence of HHHTHTTT will produce balanced counts of pairs as well as triples (HHH, HHT, etc.).
Here's an idea for a more general solution that was initially inspired by answers discussing random walks. Start with the observation that for a random sequence, the number of heads in any given subsequence is binomially distributed. We can count the number of heads, $$n_{i,j}$$, between flip number $$i$$ and flip number $$j>i$$ for all values of $$i,j$$. Then compare these to the expected number of counts if all the $$n_{i,j}$$ were independent. Although they are obviously not independent, the comparison gives rise to a useful statistic: the maximum absolute difference between the observed counts and the expected counts.
Applying this approach to sequence 1 gives us 98.26 as our test statistic: there are 257 subsequences of length 44. If they were all composed of independent Bernoulli trials, the expected number of the 257 that contained exactly 22 heads is ~30.74, whereas sequence 1 contains 129 subsequences with exactly 22 heads (very underdispersed). 129 - 30.74 = 98.26, which is the maximum of these differences for sequence 1.
Performing the same calculations on sequence 2 gives a test statistic of 48.30: there are 197 subsequences of length 104. The expected number containing exactly 54 heads would be ~13.70. Sequence 2 contains 62, so the test statistic is 62 - 13.70 = 48.30. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
The test statistics can be compared to those from a large number of random sequences of the same size. In this case, no samples are greater than the test statistic from sequence 1, and about 14% of samples are greater than the statistic from sequence 2.
Here it is all together with R code:
library(parallel)
set.seed(16)
seq1 <- utf8ToInt("TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHHTTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHHTTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHTTHHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHTHTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTTHHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT") == utf8ToInt("H")
seq2 <- utf8ToInt("HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTHTHTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHHTTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTTTHTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTHHHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHHHTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT") == utf8ToInt("H")
# function to calculate test statistic S
fS <- function(m, p = 0.5) {
if (!is.matrix(m)) m <- matrix(m, ncol = 1)
n <- nrow(m)
steps <- rep.int(1:(n - 1L), 2:n)
nEx <- dbinom(sequence(2:n, from = 0L), steps, p)*(n - steps)
idx <- sequence((n - 1L):1)
idx <- idx*(idx + 1L)/2L
S <- numeric(ncol(m))
for (i in 1:ncol(m)) S[i] <- max(abs(nEx - tabulate(idx + dist(cumsum(m[,i])), length(nEx))))
S
}
(S1 <- fS(seq1))
#> [1] 98.26173
(S2 <- fS(seq2))
#> [1] 48.30014
# calculate S from 1e6 random sequences of length n (probably overkill)
n <- length(seq1)
cl <- makeCluster(detectCores() - 1L)
clusterExport(cl, list("fS", "n"))
system.time(simS <- unlist(parLapply(cl, 1:100, function(i) fS(matrix(sample(0:1, 1e4L*n, TRUE), n)))))
#> user system elapsed
#> 0.00 0.03 339.42
stopCluster(cl)
nsim <- 1e6L
# calculate approximate p-values
sum(simS > S1)/nsim
#> [1] 0
sum(simS > S2)/nsim
#> [1] 0.139855
max(simS)
#> [1] 91.01078 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
This problem specifies that we have the following information:
• We observed two coin flip sequences: sequence $$S_1$$ and sequence $$S_2$$.
• Each of these sequences could have been generated by either mechanism $$R$$ corresponding to independent flips of a fair coin or some other mechanism $$\bar{R}$$.
• Exactly one of these two sequences was generated by the mechanism $$R$$.
Since both sequences $$S_1$$ and $$S_2$$ could possibly have been generated by $$R$$ or $$\bar{R}$$, we cannot be sure which of these two sequences was generated by $$R$$. However, probability theory provides us with the tools to quantify our belief $$P(R_i|S_i)$$ that sequence $$S_i$$ was generated by mechanism $$R$$. Then, given that we have been provided with the information $$I$$ that exactly one of these two sequences has been generated by mechanism $$R$$, then the probability that sequence 1 was generated by mechanism $$\bar{R}$$ and sequence 2 was generated by mechanism $$R$$ is:
$$P(\bar{R_1}R_2|S_1 S_2 I) = \frac{P(R_2|S_2)}{P(R_1|S_1) + P(R_2|S_2)}$$
This problem explicitly specifies what it means for a sequence to have been generated by mechanism $$R$$: the sequence $$S_i$$ is described by independent flips $$y_{ij}$$ of a fair coin, such that the likelihood is:
$$P(S_i|R_i) = \prod_j \mathrm{Bernoulli}(y_{ij} | 0.5)$$
However, in order to determine the probability that a given sequence was generated by mechanism $$R$$, $$P(R_i|S_i)$$, we also need to specify alternative mechanisms $$\bar{R}$$ by which the sequences may have been generated. At this point we have to use our own creativity and external information to develop models that could reasonably describe how these sequences might have been generated, if they were not generated by mechanism $$R$$.
The other answers to this question do a great job at describing various mechanisms $$\bar{R}$$ that describe how sequences could be generated: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
• Sequences are generated by sampling pairs of coin flips from a distribution where the probability of different pairs of coin flips deviates from uniform: 1 2 3
• Sequences are generated in a way such that they do not have long runs of only heads or tails: 1
• Sequences are generated in such a way so that a given compression algorithm results in a small compressed size: 1
• Sequences are generated by a random walk such that a given coin flip outcome is affected by recent coin flip outcomes: 1 2 3
Note: we can always develop a hypothesis that appears to result in our observed sequence having been "inevitable", according to our likelihood, and if our prior probability for that mechanism of sequence generation is high enough, then using this hypothesis can always result in a low probability that the sequence had been generated by mechanism $$R$$. This practice is also referred to as HARKing, and Jaynes refers to this as a "sure-thing hypothesis". In general, we may have multiple hypotheses that can describe how a sequence may be generated, but the more contrived hypotheses such as "sure-thing hypotheses" should generally have sufficiently low prior probabilities such that we generally would not infer that those hypotheses have the highest probability of having generated a given sequence. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
Here's an example using this procedure with one possible model for $$\bar{R}$$ sequence generation to quantify the probability that sequence 2 was the sequence that was generated by mechanism $$R$$. This stan model defines model_r_lpmf as the log likelihood for sequence generation mechanism $$R$$, and model_not_r_lpmf as the log likelihood for sequence generation mechanism $$\bar{R}$$. In this case, we are testing a hypothesis $$\bar{R}$$ in which coin flips can be correlated, and there is a fairly well defined correlation length. Then, we are modeling the probability that the sequence was generated by model $$R$$ as p_model_r, such that our prior probability considers mechanisms $$R$$ and $$\bar{R}$$ sequence generation equally probable.
// model for hypothesis testing whether a sequence of coin flips is generated by either:
// - model R: independent flips of a fair coin, or
// - model not R: unfair coin with correlations
functions {
// independent flips of a fair coin
real model_r_lpmf(int[] sequence, int N) {
return bernoulli_lpmf(sequence | 0.5);
}
// unfair coin with correlations
real model_not_r_lpmf(int[] sequence, int N, int n, vector beta) {
real tmp = 0; | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
real offset = 0;
for (i in 1:N) {
offset = beta[1];
for (j in 1:min(n - 1, i - 1)) {
offset += beta[j + 1] * (2 * sequence[i - j] - 1);
}
tmp += bernoulli_logit_lpmf(sequence[i] | offset);
}
return tmp;
}
}
data {
int N; // the length of the observed sequence
int<lower=0, upper=1> sequence[N]; // the observed sequence
}
transformed data {
int n = N / 2 + 1; // number of correlation parameters to model
}
parameters {
real<lower=0, upper=1> p_model_r; // probability that the sequence was generated by model R
// not R model parameters
real log_scale; // log of the scale of the correlation coefficients beta
real log_decay_rate; // log of the decay rate for the correlation coefficients beta
vector[n] alpha; // pretransformed correlation coefficients
}
transformed parameters {
// transformed not R model parameters
real scale = exp(log_scale); // typical scale of the correlation coefficients
real decay_rate = exp(log_decay_rate); // typical decay rate of correlation coefficients
vector[n] beta; // correlation coefficients
for (j in 1:n) {
beta[j] = alpha[j] * scale * exp(-(j - 1) * decay_rate);
}
}
model {
// uninformative haldane prior for the probability that the sequence was generated by model R
target += - log(p_model_r) - log1m(p_model_r);
// priors for not R model parameters
log_scale ~ normal(-1, 1);
log_decay_rate ~ normal(-1, log(n + 1) / 2.0);
alpha ~ normal(0, 1);
// the sequence is was generated by model R with probability p_model_r, otherwise it was generated by model not R
target += log_mix(
p_model_r,
model_r_lpmf(sequence | N),
model_not_r_lpmf(sequence | N, n, beta)
);
}
Using pystan with this model, we can evaluate the probability p_model_r that each of the two provided sequences were generated by mechanism $$R$$.
model = pystan.StanModel(model_code=MODEL_CODE) | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
model = pystan.StanModel(model_code=MODEL_CODE)
sequence_1 = "TTHHTHTTHTTTHTTTHTTTHTTHTHHTHHTHTHHTTTHHTHTHTTHTHHTTHTHHTHTTTHHTTHHTTHHHTHHTHTTHTHTTHHTHHHTTHTHTTTHHTTHTHTHTHTHTTHTHTHHHTTHTHTHHTHHHTHTHTTHTTHHTHTHTHTTHHTTHTHTTHHHTHTHTHTTHTTHHTTHTHHTHHHTTHHTHTTHTHTHTHTHTHTHHHTHTHTHTHHTHHTHTHTTHTTTHHTHTTTHTHHTHHHHTTTHHTHTHTHTHHHTTHHTHTTTHTHHTHTHTHHTHTTHTTHTHHTHTHTTT"
samples_1 = model.sampling(
data=dict(N=len(sequence_1), sequence=[int(c == "H") for c in sequence_1]),
chains=16,
)
p_model_r_1 = samples_1["p_model_r"].mean()
# p_model_r_1 = 0.027
sequence_2 = "HTHHHTHTTHHTTTTTTTTHHHTTTHHTTTTHHTTHHHTTHTHTTTTTTHTHTTTTHHHHTHTHTTHTTTHTTHTTTTHTHHTHHHHTTTTTHHHHTHHHTTTTHTHTTHHHHTHHHHHHHHTTHHTHHTHHHHHHHTTHTHTTTHHTTTTHTHHTTHTTHTHTHTTHHHHHTTHTTTHTHTHHTTTTHTTTTTHHTHTHHHHTTTTHTHHHTHHTHTHTHTHHHTHTTHHHTHHHHHHTHHHTHTTTHHHTTTHHTHTTHHTHHHTHTTHTTHTTTHHTHTHTTTTHTHTHTTHTHTHT"
samples_2 = model.sampling(
data=dict(N=len(sequence_2), sequence=[int(c == "H") for c in sequence_2]),
chains=16,
)
p_model_r_2 = samples_2["p_model_r"].mean()
# p_model_r_2 = 0.790
`
Here we have quantified the probability that each sequence was generated according to the sequence generating model $$R$$ as the following:
\begin{aligned} P(R_1|S_1) &= 0.027 \\ P(R_2|S_2) &= 0.790 \\ P(\bar{R_1}R_2|S_1 S_2 I) &= 0.967 \\ \end{aligned} | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
So, we are fairly certain that sequence 2 was generated by independent coin flips and sequence 1 was not, relative to the model of sequence generation $$\bar{R}$$ that we defined, and we quantify this belief with a probability of 0.967. This is a high probability, but of course we could still be wrong -- both sequences could have been generated by either model. Additionally, we could have selected a model of sequence generation for $$\bar{R}$$ that can not describe the procedure that was actually used to generate the sequences. This process for quantifying our belief that one of these two sequences was generated by a fair coin with independent flips is the piece of reasoning that currently appears to be missing from the other answers that are currently available.
• I have to reject your initial dichotomy, because it (a) is too vague to be actionable (what can one do, in any objective and quantifiable way, to characterize any "non-random process"?) and (b) ignores a huge set of other possible mechanisms: namely, random mechanisms that are not iid.. In fact, it is almost surely the case that whoever generated these sequences used a random mechanism for both--they are just different random mechanisms.
– whuber
May 31 at 12:00
• @whuber I framed this problem in terms of hypothesis testing between a model $R$ by which sequences are generated by independent flips of a fair coin, and models of other possible ways that we might believe that sequences could be generated $\bar{R}$. I used labels "random", and "not random" to describe these models, which appears to have been confusing, so I have edited the post to remove that terminology. Jun 8 at 3:18 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446456243805,
"lm_q1q2_score": 0.8607401087317024,
"lm_q2_score": 0.8840392771633079,
"openwebmath_perplexity": 1067.4501979938352,
"openwebmath_score": 0.7305430769920349,
"tags": null,
"url": "https://stats.stackexchange.com/questions/574333/how-can-i-determine-which-of-two-sequences-of-coin-flips-is-real-and-which-is-fa/574425"
} |
Arrange first N natural numbers such that absolute difference between all adjacent elements > 1?
We have the first N natural numbers. Our task is to get one permutation of them where the absolute difference between every two consecutive elements is > 1. If no such permutation is present, return -1.
The approach is simple. We will use the greedy approach. We will arrange all odd numbers in increasing or decreasing order, then arrange all even numbers in decreasing or increasing order
Algorithm
arrangeN(n)
Begin
if N is 1, then return 1
if N is 2 or 3, then return -1 as no such permutation is not present
even_max and odd_max is set as max even and odd number less or equal to n
arrange all odd numbers in descending order
arrange all even numbers in descending order
End
Example
#include <iostream>
using namespace std;
void arrangeN(int N) {
if (N == 1) { //if N is 1, only that will be placed
cout << "1";
return;
}
if (N == 2 || N == 3) { //for N = 2 and 3, no such permutation is available
cout << "-1";
return;
}
int even_max = -1, odd_max = -1;
//find max even and odd which are less than or equal to N
if (N % 2 == 0) {
even_max = N;
odd_max = N - 1;
} else {
odd_max = N;
even_max = N - 1;
}
while (odd_max >= 1) { //print all odd numbers in decreasing order
cout << odd_max << " ";
odd_max -= 2;
}
while (even_max >= 2) { //print all even numbers in decreasing order
cout << even_max << " ";
even_max -= 2;
}
}
int main() {
int N = 8;
arrangeN(N);
}
Output
7 5 3 1 8 6 4 2
Published on 01-Aug-2019 07:36:08 | {
"domain": "tutorialspoint.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9736446440948806,
"lm_q1q2_score": 0.8607401044049336,
"lm_q2_score": 0.8840392741081575,
"openwebmath_perplexity": 1346.7502711889088,
"openwebmath_score": 0.30733564496040344,
"tags": null,
"url": "https://www.tutorialspoint.com/arrange-first-n-natural-numbers-such-that-absolute-difference-between-all-adjacent-elements-1"
} |
1. ## Solving Congruences
If you are to solve for x in the congruence $7x=20(mod50)$
What is the easier way to do it without using a calculator or any other type of electronic device. I know you can add 7 to 20 until the number is divisible by 7 and then divide by 7 to reduce it to a solution but that takes a while. I need to figure out how to get it done in just a minute or two. Thanks.
2. Originally Posted by diddledabble
If you are to solve for x in the congruence $7x=20(mod50)$
What is the easier way to do it without using a calculator or any other type of electronic device. I know you can add 7 to 20 until the number is divisible by 7 and then divide by 7 to reduce it to a solution but that takes a while. I need to figure out how to get it done in just a minute or two. Thanks.
You mean 50 (the modulus).
For small moduli and $(a,m) = 1$, adding the modulus until cancellation is probably the best way to solve $ax \equiv b \ (\text{mod } m)$. For this particular congruence, add the modulus once to 20 to get: $7x \equiv 70 \ (\text{mod } 50)$
Since $(7, 50) = 1$, you can 'divide' by 7 to get your solution.
_____________
For a more general case where $(a,m) \neq 1$, as long as $(a,m) \mid b$, then we can always use the Euclidean algorithm to find one solution modulo $\tfrac{m}{(a,m)}$ and use it to find all solutions modulo m. Here's an example in this wiki entry: Linear congruence theorem
3. ## @dibbledabble
Well, I guess I have an easier method to solve this congruence equation.
7x=20(mod50)
The equation simply means that 7x, a multiple of 7, is 20 more than a multiple of 50 [By modulo logic]
If we list down numbers which are 20 more than a multiple of 50, we get
70, 120, 170, 220, 270, 320, 370, 420, and so on... From this which it is quite evident that 70, 420, 770, 1120... etc are multiples of 7 which are 20 more than multiples of 50. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9886682458008672,
"lm_q1q2_score": 0.8607318874339769,
"lm_q2_score": 0.8705972818382005,
"openwebmath_perplexity": 344.0861313507526,
"openwebmath_score": 0.8243153095245361,
"tags": null,
"url": "http://mathhelpforum.com/number-theory/96768-solving-congruences.html"
} |
So, the smallest positive number is 70. 7x = 70 which means x = 10.
In fact, 350n - 280 would be the general form for the number 7x.
So, the general solution of x would be 50n - 40 where n can range from 1,2,3,.. and so on.
Hope it helped,
MAX
4. ## General theory
An equation of the form
$ax\equiv b$ (mod n)
has a solution if and only if $gcd(a,n)|b$.
Here is how you do it in general when these requirements are met.
Let $d=gcd(a,n)$ and by assumption $d|b \Rightarrow b=dk$ for some integer $k$. Then by the Euclidean Algorith, there exist integers $s$ and $t$ such that
$as+nt=d$.
We now multiply through by k to get.
$ask+ntk=dk=b$
reduce mod n to see
$a(sk)\equiv b$ (mod n).
There is your $x$, namely, $x=sk$ (mod n).
5. 7x7=49=-1 (mod 50)
so -x=140 (mod 50)=-10 (mod 50)
hence x=...
6. Helo, diddledabble!
Solve: . $7x \:\equiv\:20\text{ (mod 50)}$
Your "brute force" method is tedious, but it is commendable.
It shows that you understand the congruence statement.
Here is a primitive method . . .
We have: . $7x \:\equiv\:20 \text{ (mod 50)}$
This means: . $7x - 20 \:=\:50a\;\text{ for some integer }a.$
Solve for $x\!:\quad x \:=\:\frac{50a+20}{7} \quad\Rightarrow\quad x \:=\:7a + 2 + \frac{a+6}{7}$
Since $x$ is an integer, $a+6$ must be divisible by 7.
The first time this happens is $a = 1.$
So we have: . $x \;=\;7(1) + 2 + \frac{1+6}{7}\;=\;10$
Therefore: . $x \:\equiv\:10\text{ (mod 50)}$
7. ## @dibbledabble
Hi,
I think the solution offered by Soroban is the closest to the perfect procedure for your question. I guess mine was a bit too illustrative.
8. So using Soroban's method and a different congruence 35x=20(mod50) I get x=2(mod50) right?
9. ## Yes
If you haven't checked already, values of 'x' such as 52 and 102 satisfy the equation as, in 52 * 35 = 1820
= 1800 + 20
= 36*50 + 20
Similarly, 102*35 = 3570
= 3550 +20
= 71*50 + 50
MAX | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9886682458008672,
"lm_q1q2_score": 0.8607318874339769,
"lm_q2_score": 0.8705972818382005,
"openwebmath_perplexity": 344.0861313507526,
"openwebmath_score": 0.8243153095245361,
"tags": null,
"url": "http://mathhelpforum.com/number-theory/96768-solving-congruences.html"
} |
MAX
10. Given the congruence $ax \equiv b \ (\text{mod } m)$, if $(a,m) \mid b$, then there are $(a,m)$ solutions exactly.
So for the congruence $35x \equiv 20 \ (\text{mod } 50)$, we can see that there should be 5 solutions modulo 50.
___________
Reduce your congruence: $5 \cdot 7x \equiv 5 \cdot 4 \equiv (\text{mod } 50) \ \Rightarrow \ 7x \equiv 4 (\text{mod } \tfrac{50}{(5, 50)}) \ \Leftrightarrow \ 7x \equiv 4 \ (\text{ mod} 10)$
Quickly by inspection, by adding the modulus to 4, we get: $7x \equiv 14 \ (\text{mod } 10)$
which is satisfied by all integers such that $x \equiv 2 \ (\text{mod } 10) \ \ (\star)$.
Returning to our original congruence, all 5 solutions are least residues that satisfy $(\star)$. Therefore, modulo 50: 2, 12, 22, 32, 42 are all solutions. | {
"domain": "mathhelpforum.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9886682458008672,
"lm_q1q2_score": 0.8607318874339769,
"lm_q2_score": 0.8705972818382005,
"openwebmath_perplexity": 344.0861313507526,
"openwebmath_score": 0.8243153095245361,
"tags": null,
"url": "http://mathhelpforum.com/number-theory/96768-solving-congruences.html"
} |
# Expected number of people sitting in the right seats.
There was a popular interview question from a while back: there are $n$ people getting seated an airplane, and the first person comes in and sits at a random seat. Everyone else who comes in either sits in his seat, or if his seat has been taken, sits in a random unoccupied seat. What is the probability that the last person sits in his correct seat?
The answer to this question is $1/2$ because everyone looking to sit on a random seat has an equal probability of sitting in the first person's seat as the last person's.
My question is: what is the expected number of people sitting in their correct seat?
My take: this would be $\sum_{i=1}^n p_i$ where $p_i$ is the probability that person $i$ sits in the right seat..
$X_1 = 1/n$
$X_2 = 1 - 1/n$
$X_3 = 1 - (1/n + 1/n(n-1))$
$X_4 = 1 - (1/n + 2/n(n-1) + 1/n(n-1)(n-2))$
Is this correct? And does it generalize to $X_i$ having an $\max(0, i-1)$ term of $1/n(n-1)$, a $\max(0, i-2)$ term of $1/n(n-1)(n-2)$ etc?
Thanks.
-
Could the general probability not be, for $m>1$, $X_m=1-\left(\sum_{k=0}^{m-2}\binom{m-2}{k}\frac{(n-k-1)!}{n!}\right)$? Perhaps prove by induction? – Alyosha Aug 10 '13 at 23:19
The MSE treatment of the original problem: math.stackexchange.com/questions/5595/taking-seats-on-a-plane – Byron Schmuland Aug 23 '13 at 17:41
Sorry for the second answer (I will delete the first one):
I will aim to show that the expected number of people sitting in their correct seats is given by:
$$n-1-\frac12-\frac13-\dots-\frac1{n-1}=n-H_{n-1}$$
To do this, we will first find the expected number of people in the wrong seats, which we shall call $s_n$.
Suppose passenger number $1$ sits in seat $i\ne1$. At this point, passengers $2,\dots,i-1$ all sit in their correct seats. We now have a situation where there are $n-i+1$ empty seats left, and passenger $i$ is going to sit in a random seat. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
This is very similar to the situation we had at the start, just with fewer seats. The only difference is that passenger $i$'s seat is taken, and there's a seat (seat $1$) which belongs to none of the people standing up.
This is a bit of a problem, so we'll change things around a bit. We'll pretend that seat number $1$ doesn't, in fact, belong to any of the passengers. So wherever passenger $1$ sits, they're in the wrong seat. We'll use the letter $t_n$ to denote the expected number of people sitting in the wrong seat if seat $1$ doesn't belong to anybody.
What we now get, is that the situation after passenger $1$ has sat in seat $i\ne1$, and passengers $2,\dots,n-1$ have sat in their correct seats is exactly the same as the situation at the beginning, but with $n-i+1$ seats rather than $n$: there's a passenger about to choose a random seat which doesn't belong to him (I decided the sex of passenger $i$ by tossing a coin): there's a seat ($1$) which doesn't belong to anybody, and the rest of the seats belong to the remaining passengers. So at this point, the expected number of passengers sitting in the wrong seats is $1+t_{n-i+1}$: $1$ for passenger $1$, who's sat in the wrong seat, and $t_{n-i+1}$ because afterwards we're in exactly the same situation as before, but with $n-i+1$ seats.
What if passenger $1$ sits in seat $1$? Then all the remaining passengers sit in the right seats, so the expected number of people sitting in the wrong seats at the end is just $1$ (remember, passenger $1$ no longer owns seat $1$).
Passenger $1$ chooses between the $n$ seats at random, so this gives us the recurrence:
\begin{align} t_1 &= 1\\ t_n &= 1+\frac1n\sum_{i=2}^nt_{n-i+1} = 1+\frac1n\sum_{i=1}^{n-1}t_i \end{align}
We are now ready to prove the following:
Claim: $t_n=H_n$
Proof of claim: induction on $n$. $\mathbf{n=1}$ : $t_1=1=H_1$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
Claim: $t_n=H_n$
Proof of claim: induction on $n$. $\mathbf{n=1}$ : $t_1=1=H_1$.
$\mathbf{n>1}$ : $t_n=1+\frac1n\sum_{i=1}^{n-1}t_i=1+\frac1n\sum_{i=1}^{n-1}H_i$ (by the inductive hypothesis). A well known identity involving harmonic numbers tells us that:
$$\sum_{i=1}^{n-1}H_i = nH_{n-1}-(n-1)$$
So $t_n=1+H_{n-1}-1+\frac1n=H_n$. $\Box$
How do we get from here to $s_n$? The difference now is that passenger $1$ does own seat $1$, which means that the answer will be smaller by $1$ if and only if passenger $1$ sits in seat $1$. Since passenger $1$ sits in seat $1$ with probability $\frac1n$, we need to subtract $\frac1n$ from $t_n$ to get $s_n$:
$$s_n=t_n-\frac1n=H_n-\frac1n=H_{n-1}$$
Finally, to get the expected number of people in the right seats, we subtract $s_n$ from $n$ to get:
$$n-H_{n-1}$$
Note 1: Since $H_n$ grows logarithmically, the proportion of people sitting in their correct seats converges to $1$ as $n\to\infty$.
Note 2: I still find this proof rather unsatisfying, since it uses the identity $\sum_{i=1}^{n-1}H_i = nH_{n-1}-(n-1)$, which I still don't really understand. I'm sure it's easy enough to prove by induction, but if someone could come up with a really nice explanation of why that works, it might yield an even slicker proof of this fact. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
-
There are a few things I do not follow in your explanation. Firstly, if passenger 1 sits in seat 1, the expected number of correct seats is n, because everyone sits in their correct seat if it is available, so excluding that possibility materially affects the answer. Secondly, it can be shown (see below where I answered the wrong question) that regardless of of the number of people, the probability that the last person sits in his or her proper seat is \frac{1}{2}. As any one person could be the last one, the long-term proportion should approach 1/2. In my attempt at a correct answer it does. – Avraham Aug 23 '13 at 19:19
What do you mean by 'any one person could be the last one'? And why does that mean that the long term proportion should approach $1/2$? – Donkey_2009 Aug 24 '13 at 10:54
If you read my answer carefully, you will see that I do not exclude the possibility that passenger $1$ sits in seat $1$; instead, I treat it separately. The long term proportion approaches $1$, so I think you might be answering a different question. – Donkey_2009 Aug 24 '13 at 10:55
Your overall approach looks technically correct, you are using linearity of expectation for counting and then writing down a formula for each $p_i$ (although it seems you switched notation and started using $X_i$ in your formulas instead of $p_i$). However I believe the equation for $X_4$ i.e. $p_4$ is actually
$$X_4 = 1 - (1/n + 1/n(n-1) + 1/n(n-2) + 1/n(n-1)(n-2))$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
$$X_4 = 1 - (1/n + 1/n(n-1) + 1/n(n-2) + 1/n(n-1)(n-2))$$
and the generalization for $X_i$ for arbitrary $i$ is obtained by your basic reasoning, just writing down the probability for each way the $i$th person's seat might already be taken, taking into account each case e.g. for $X_4$ the term $1/n(n-2)$ corresponds to the case that the first person takes the third person's seat, and the third person takes the fourth person's seat. I'm not sure if/what an easy formula would be for when you add up all the $X_i$ terms to get the total answer. However it is easy to see that the general rule to get the equation for $X_i$ when $i > 1$ is to have $X_i = 1 - q_i$ where $q_i$ is the sum of all terms you can make of the form $1/n(n-k_1)(n-k_2)\ldots$ where you have $0$ or more distinct values $k_j$, and $k_1 < k_2 \ldots < i-1$.
-
Oops, sorry about the $p_i \rightarrow X_i$ change. And you are write about $X_4$. Thanks for your answer, that seems correct. – narcissa Aug 10 '13 at 23:59
I found this question and the answer might be relevant.
Seating of $n$ people with tickets into $n+k$ chairs with 1st person taking a random seat
The answer states that the probability of a person not sitting in his seat is $\frac{1}{k+2}$ where $k$ is the number of seats left after he takes a seat. This makes sense because for person $i$, if anyone sits in chairs $1, i+1, ... n$ then he must sit in his own seat, so the probability of that happening is $\frac{n-i+1}{n-i+2}$. So $k = 0$ for the last person and $k = n-1$ for the second person. The answer then should just be
$1/n + \sum_{i = 2}^{n} \frac{n-i+1}{n-i+2}$
-
The answer (see my post) is $n-H_{n-1}$, but this is probably the right way to go. – Donkey_2009 Aug 11 '13 at 0:56
The answer is $\frac{1}{2}$ as was said. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
The answer is $\frac{1}{2}$ as was said.
The general pattern is that for $n$ people, there is a $\frac{1}{n}$ probability of success, $\frac{1}{n}$ probability of failure, and an $\frac{n-2}{n}$ probability that the problem repeats itself on the $n-1$ scale.
Case $n=2$: The probability that the first picks the correct seat is $\frac{1}{2}$, and then the last person sits in proper seat with probability 1. The probability that the first picks the wrong seat is $\frac{1}{2}$, and then the last person sits in proper seat with probability 0. So the probability in total is: $$\frac{1}{2}\cdot1+\frac{1}{2}\cdot0=\frac{1}{2}$$
Case $n=3$: The probability that the first picks the correct seat is $\frac{1}{3}$, and then the last person sits in proper seat with probability 1. The probability that the first picks the last person's seat is $\frac{1}{3}$, and then the last person sits in proper seat with probability 0. The probability that the first picks the middle person's seat is $\frac{1}{3}$, and now there is a $\frac{1}{2}$ that the second person picks the last seat or the first seat (Case 2) since two non-last people switching seats means everyone else takes their own seat. So: $$\frac{1}{3}\cdot1+\frac{1}{3}\cdot0+\frac{1}{3}\cdot\frac{1}{2} = \frac{2}{6} + \frac{1}{6} = \frac{3}{6} = \frac{1}{2}$$
Proof by induction.
Assume it holds true for $n$ that the probability of the last person sitting in the proper seat is $\frac{1}{2}$. Now if there are $n+1$ people, we have a $\frac{1}{n+1}$ chance that the last-seat probability is 1 (correct seat), a $\frac{1}{n+1}$ chance that the last-seat probability is 0 (last seat), and an $\frac{n-1}{n+1}$ chance that the probability is $\frac{1}{2}$, since we know the $n$ case. $$\frac{1}{n+1} + \frac{0}{n+1} + \frac{n-1}{2(n+1)}\\ =\frac{2}{2(n+1)}+\frac{n-1}{2(n+1)}\\ =\frac{n+1}{2(n+1)}\\ =\frac{1}{2}$$ QED | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
-
I feel bad for all your work, but the question was the expected number of people in correct seats. – Lord_Farin Aug 23 '13 at 8:17
Now that I have cleaned my glasses, I'll try again. Thank you, Lord Farin.
Some observations.
The answer must be greater than 1. The probability that the first person, regardless of the number of people, sits in the proper seat is $\frac{1}{n}$, and there are $n$ people, so that expectation is 1. Even if the first person sits in the wrong seat, there is non-zero probability of other people sitting in the correct seat, so the answer must be greater than or equal to 1, and I'm pretty sure equality only exists in the case $n=2$. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
There is some form of recurrence going on here. Enumerating the possibilities, I get (if I haven't erred): $$E_2 = \frac{1}{2}\cdot 2 + \frac{1}{2}\cdot 0 = 1\\ E_3 = \frac{1}{3}\cdot 3 + \frac{2}{3}\left[\frac{1}{2}\cdot 1 + \frac{1}{2}\cdot 0\right] = 1+\frac{1}{3}=\frac{4}{3}\\ E_4 = \frac{1}{4}\cdot 4 + \frac{3}{4}\left[\frac{1}{3}\cdot2 + \frac{2}{3}\left[\frac{1}{2}\cdot 1 + \frac{1}{2}\cdot 0\right]\right] = 1+\frac{3}{4}\cdot\left(\frac{2}{3}+\frac{1}{3}\right)=\frac{7}{4}\\ E_5 = \frac{1}{5}\cdot 5 + \frac{4}{5}\left[\frac{1}{4}\cdot3 + \frac{3}{4}\left[\frac{1}{3}\cdot2 + \frac{2}{3}\left[\frac{1}{2}\cdot 1 + \frac{1}{2}\cdot 0\right]\right]\right] = 1+\frac{4}{5}\left(\frac{3}{4} + \frac{3}{4}\cdot\left(\frac{2}{3}+\frac{1}{3}\right)\right)=\frac{11}{5}\\$$ Let $E_k$ be the expected number of people in the correct seats when the starting population is k. The relationship seems to be: $$E_k = 1 + \left(E_{k-1} - 1 + \frac{k-2}{k-1}\right)\frac{k-1}{k}$$ The first 1 is the expected value of person 1 taking the correct seat. The next term is broken into two parts. If the first person did not take the correct seat, then the second person can "fix" the error by swapping and taking the previous person's seat, leaving the remaining $n-2$ people their proper seats. If the second person also takes the wrong seat, the problem restarts on the $n-1$ scale. In both the latter two cases, there is "one less" correct seat than the initial, since the previous term used up a seat with an incorrect choice. If the above supposition is correct, the expected value would just be the sum of the recurrence relation applied to $n$ or $\sum_{k=1}^n E_k$.
Generating the first few terms using this relationship gives: $$1, 1, \frac{4}{3}, \frac{7}{4}, \frac{11}{5}, \frac{16}{6}, \frac{22}{7}, \frac{29}{8}, \frac{37}{9}, \frac{46}{10}, \ldots$$
The numerator is a quadratic and the denominator is just $n$ so the expected value should be: $$E_n = \frac{n^2-n+2}{2n}$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
Edit: The long-term proportion of people sitting in the proper seats intuitively would be $$\lim_{n \to \infty} \frac{E_n}{n}\\ =\lim_{n \to \infty} \frac{n^2-n+2}{2n^2}\\ =\frac{1}{2}$$ Which dovetails nicely with the long-term probability of the last person sitting in his or her proper seat.
-
Your recurrence is wrong, as are your values for $E_k$ where $k\ge3$. I'm not really sure what your argument is; are you free to take this to chat some time today? – Donkey_2009 Aug 24 '13 at 12:06
Sure. If I'm wrong, I'm eager to learn why and how to correct it. If you want, you can e-mail me directly as well; thank you. – Avraham Aug 26 '13 at 1:18
It's 1. The probability that the $i$th person is in the right seat is $1/n$ for every $i$. This is clearly true for $i=1$, for $i=2$ you get $$P(\text{1st person not in 2nd person's seat, 2nd person in right seat}) = \frac{n-1}{n} \frac{1}{n-1} = 1/n,$$ and so on down the line as you can check for yourself.
This answer is wrong. The probability that the second person is in the right seat is $1$ if the first person didn't sit in their seat. I think kilgol was assuming that people just sit in their seats randomly, whereas they in fact always sit in their own seat if it is free (and they're not the first person). – Donkey_2009 Aug 11 '13 at 0:49 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.988668248138067,
"lm_q1q2_score": 0.8607318662328379,
"lm_q2_score": 0.8705972583359805,
"openwebmath_perplexity": 281.9892079216284,
"openwebmath_score": 0.8596817255020142,
"tags": null,
"url": "http://math.stackexchange.com/questions/464625/expected-number-of-people-sitting-in-the-right-seats"
} |
# Why is the answer to this probability question not $\frac{1}{2}$?
I was trying to solve the following homework probability question which has the following setup:
We have $$2$$ dice: $$A$$ and $$B$$. Die $$A$$ has $$4$$ red faces and $$2$$ white faces, whereas die $$B$$ has $$2$$ red faces and $$4$$ white faces. On each turn, a fair coin is tossed. If the coin lands on heads then die $$A$$ is thrown, but if the coin lands on tails then die $$B$$ is thrown. After this the turn ends, and on the next turn the coin is once again tossed to determine the die (i.e. we throw the coin and the corresponding die on each turn).
From this game I'm asked to answer $$2$$ questions:
1. Show that the probability of obtaining a red face on any $$n$$-th throw is $$\frac{1}{2}$$.
2. If the first $$2$$ consecutive die throws result in red faces, what is the probability that the third throw is also red?
To answer part $$1$$ I used the law of total probability. Denoting obtaining a red face on the $$n$$-th die throw as $$P(R_n)$$ I get
\begin{align*} P(R_n) &= P(R_n \vert A) P(A) + P(R_n \vert B) P( B) \\ & = \left(\frac{4}{6}\right)\left(\frac{1}{2}\right) + \left(\frac{2}{6}\right)\left(\frac{1}{2}\right)\\ & = \frac{1}{2} \end{align*}
But on question $$2$$ is where I started running into trouble. Using the same notation, what I want to calculate is $$P(R_3 \vert R_2 R_1)$$. And recalling that for events $$E_1$$ and $$E_2$$ we can say that $$P(E_2 \vert E_1) = \frac{P(E_2E_1)}{P(E_1)}$$ I get that $$P(R_3 \vert R_2 R_1) = \frac{P(R_3 R_2 R_1)}{P(R_2 R_1)} \tag{1}$$ and from here I obtain 2 different solutions using $$2$$ distinct methods: | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8607161292243346,
"lm_q2_score": 0.8791467722591728,
"openwebmath_perplexity": 480.8887045995353,
"openwebmath_score": 0.9856621026992798,
"tags": null,
"url": "https://math.stackexchange.com/questions/4072871/why-is-the-answer-to-this-probability-question-not-frac12"
} |
Using that on the first part of the question we showed that $$P(R_n) = \frac{1}{2}$$, and noticing that the die throws are independent since what I threw before does not affect how I throw the next coin toss or how I roll the next die, from equation $$(1)$$ I get \begin{align*} P(R_3 \vert R_2 R_1) &= \frac{P(R_3 R_2 R_1)}{P(R_2 R_1)}\\ &= \frac{P(R_3) P(R_2) P(R_1)}{P(R_2) P(R_1)}\\ & = P(R_3) = P(R_n) = \frac{1}{2} \end{align*}
Using the law of total probability on $$(1)$$ I get \begin{align*} P(R_3 \vert R_2 R_1) & = \frac{P(R_1 R_2 R_3 \vert A)P(A)+ P(R_1 R_2 R_3 \vert B)P(B)}{P(R_1 R_2 \vert A ) P(A)+ P(R_1 R_2 \vert B) P(B)}\\ &= \frac{\left[\left(\frac{2}{3}\right)\left(\frac{2}{3}\right)\left(\frac{2}{3}\right)\right]\frac{1}{2}+ \left[\left(\frac{1}{3}\right)\left(\frac{1}{3}\right)\left(\frac{1}{3}\right)\right]\frac{1}{2}}{\left[\left(\frac{2}{3}\right)\left(\frac{2}{3}\right)\right]\frac{1}{2}+\left[\left(\frac{1}{3}\right)\left(\frac{1}{3}\right)\right]\frac{1}{2}}\\ & = \frac{3}{5} \end{align*}
To me both of the previous answers seem to be following coherent logic, but since I didn't get the same answer I knew one of them was wrong. I decided to write a program to simulate the game and I found out that the correct solution was $$P(R_3 \vert R_2 R_1) = \frac{3}{5}$$. But even though I verified this answer to be correct I couldn't seem to understand what part of my analysis is wrong on Answer 1.
So my question is, why is $$P(R_3 \vert R_2 R_1) \neq \frac{1}{2}\quad ?$$ | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8607161292243346,
"lm_q2_score": 0.8791467722591728,
"openwebmath_perplexity": 480.8887045995353,
"openwebmath_score": 0.9856621026992798,
"tags": null,
"url": "https://math.stackexchange.com/questions/4072871/why-is-the-answer-to-this-probability-question-not-frac12"
} |
So my question is, why is $$P(R_3 \vert R_2 R_1) \neq \frac{1}{2}\quad ?$$
• I'm confused about the nature of this experiment. Are you repeatedly tossing a coin then rolling the corresponding die $n$ times (i.e. $n$ coin tosses and $n$ dice rolls), or are you tossing a coin once, then rolling the designated die $n$ times (i.e. $1$ coin toss, and $n$ die rolls)? – Theo Bendit Mar 23 at 5:56
• It's the first option. We have one coin toss and one dice roll per turn. I'll edit the problem to clarify this, thank you! – Robert Lee Mar 23 at 5:59
• In your computation, $A$ determines the successive $3$ roll of the die. – Oolong milk tea Mar 23 at 6:07
• If it's one coin toss and one dice roll per turn, then every (coin toss + dice roll) is independent of all the others, and the probability is $1/2$ every time. If one coin toss determined multiple dice rolls, then those dice rolls would not be mutually independent, and you would get something greater than $1/2$ (because there would be a positive correlation between rolls using the same coin toss). But if you're saying it's one coin toss and one dice roll per turn, then your simulation is wrong. – mjqxxxx Mar 23 at 6:24
• I don’t quite get the logic in answer 2. To get consecutively 2 times red, you have AA, BB, AB, BA 4 paths with their own probabilities, would expect 1/2x1/2x2/3x2/3 for AA path,... and we should have 4 terms in the denominator. Do I miss something? – BStar Mar 23 at 6:38
The flaw in your second answer is that it is not necessarily the same die that is thrown after each coin toss. The way you have written the law of total probability is acceptable in your first answer, but not in the second, because it is only in the second answer that you conditioned on the events $$A$$ and $$B$$, which represent the outcomes of the coin toss. Consequently, the result is incorrect because it corresponds to a model in which the coin is tossed once, and then the corresponding die is rolled three times. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8607161292243346,
"lm_q2_score": 0.8791467722591728,
"openwebmath_perplexity": 480.8887045995353,
"openwebmath_score": 0.9856621026992798,
"tags": null,
"url": "https://math.stackexchange.com/questions/4072871/why-is-the-answer-to-this-probability-question-not-frac12"
} |
First, let us do the calculation the proper way. We want $$\Pr[R_3 \mid R_1, R_2] = \frac{\Pr[R_1, R_2, R_3]}{\Pr[R_1, R_2]}$$ as you wrote above. Now we must condition on all possible outcomes of the coin tosses, of which there are eight: \begin{align} \Pr[R_1, R_2, R_3] &= \Pr[R_1, R_2, R_3 \mid A_1, A_2, A_3]\Pr[A_1, A_2, A_3] \\ &+ \Pr[R_1, R_2, R_3 \mid A_1, A_2, B_3]\Pr[A_1, A_2, B_3] \\ &+ \Pr[R_1, R_2, R_3 \mid A_1, B_2, A_3]\Pr[A_1, B_2, A_3] \\ &+ \Pr[R_1, R_2, R_3 \mid A_1, B_2, B_3]\Pr[A_1, B_2, B_3] \\ &+\Pr[R_1, R_2, R_3 \mid B_1, A_2, A_3]\Pr[B_1, A_2, A_3] \\ &+ \Pr[R_1, R_2, R_3 \mid B_1, A_2, B_3]\Pr[B_1, A_2, B_3] \\ &+\Pr[R_1, R_2, R_3 \mid B_1, B_2, A_3]\Pr[B_1, B_2, A_3] \\ &+ \Pr[R_1, R_2, R_3 \mid B_1, B_2, B_3]\Pr[B_1, B_2, B_3] \\ \end{align} and since each of the $$2^3 = 8$$ triplets of ordered coin tosses has equal probability of $$1/8$$ of occurring, $$\Pr[R_1, R_2, R_3] = \tfrac{1}{8}\left((\tfrac{2}{3})^3 + 3(\tfrac{2}{3})^2(\tfrac{1}{3}) + 3(\tfrac{2}{3})(\tfrac{1}{3})^2 + (\tfrac{1}{3})^3\right) = \tfrac{1}{8}.$$ A similar (but simpler) calculation for the denominator yields $$1/4$$, and the result follows.
Of course, none of this is necessary; it is only shown here to illustrate how the calculation would be done if it were to be done along the lines of your second answer. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8607161292243346,
"lm_q2_score": 0.8791467722591728,
"openwebmath_perplexity": 480.8887045995353,
"openwebmath_score": 0.9856621026992798,
"tags": null,
"url": "https://math.stackexchange.com/questions/4072871/why-is-the-answer-to-this-probability-question-not-frac12"
} |
• I think I'm starting to understand where my lack of understanding is. I believe I may not understand what $P(R_3 \vert R_2 R_1)$ is to begin with. Let's say I list all my throws as red or white accordingly. If I then count how many chains of 3 consecutive reds there are on my list, and I also count the number of times 2 reds are succeded by a white, is $$P(R_3 \vert R_2 R_1) \sim \frac{\text{#RRR}}{\text{#RRW} + \text{#RRR}}$$ in the sense that $\sim$ means the RHS approaches $P(R_3 \vert R_2 R_1)$ as I take more throws? Or does $P(R_3 \vert R_2 R_1)$ mean something else? – Robert Lee Mar 23 at 7:41
• I ran out of space in my previous comment, but #RRR stands for the number of chains of 3 consecutive reds on my list of throws, and #RRW is the number of chains where the first 2 places are red and the third consecutive throw is white, again on my list of throws. Just to clarify what I meant in the last comment. – Robert Lee Mar 23 at 7:46
• @RobertLee It is unnecessary and mathematically inappropriate to think of the problem in terms of long-run averages of more than three rolls, because the entire question can be answered precisely under a strict interpretation of the model, in which there are only ever three rolls, each of which is preceded by a coin toss. – heropup Mar 23 at 7:57
• I agree that it's not necessary to think of this mathematically. I only ask this because of my previously described attempt to verify the theoretical result with a simulation, which led me to an incorrect result. I'm trying to understand if what I programmed is in fact not trying to calculate the probability $P(R_3 \vert R_2 R_1)$ that I want, or if I'm still not understanding what the probability in itself means. – Robert Lee Mar 23 at 8:07 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8607161292243346,
"lm_q2_score": 0.8791467722591728,
"openwebmath_perplexity": 480.8887045995353,
"openwebmath_score": 0.9856621026992798,
"tags": null,
"url": "https://math.stackexchange.com/questions/4072871/why-is-the-answer-to-this-probability-question-not-frac12"
} |
• @RobertLee The frequentist approach via simulation would be as follows. [1] Locate all occurrences of two consecutive red dice rolls. [2] For each such occurrence, look at the outcome of the die roll immediately after the pair of reds. [3] Tally the number of outcomes where the third die is red. Divide the number obtained in step 3 by the total number of red pairs observed in step 1. – heropup Mar 23 at 8:18 | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8607161292243346,
"lm_q2_score": 0.8791467722591728,
"openwebmath_perplexity": 480.8887045995353,
"openwebmath_score": 0.9856621026992798,
"tags": null,
"url": "https://math.stackexchange.com/questions/4072871/why-is-the-answer-to-this-probability-question-not-frac12"
} |
With the second approach:
To have first two die throws resulting in red, there are 2x2 paths: AA,AB,BA, BB $$\to$$
$$P(R1\cap R2)=(\frac{1}{2})^2(\frac{2}{3})^2$$+2$$(\frac{1}{2})^2\frac{2}{3}\frac{1}{3}$$+$$(\frac{1}{2})^2(\frac{1}{3})^2$$ =$$\frac{1}{4}$$
To have three die throws resulting in red, there are 2x2x2 paths:AAA,BBB,AAB,ABA,BAA,BBA,BAB,ABB $$\to$$
$$P(R1\cap R2\cap R3)= (\frac{1}{2})^3(\frac{2}{3})^3$$+3$$(\frac{1}{2})^3(\frac{2}{3})^2\frac{1}{3}$$+3$$(\frac{1}{2})^3(\frac{1}{3})^2\frac{2}{3}$$+ $$(\frac{1}{2})^3(\frac{1}{3})^3$$ =$$\frac{1}{8}$$
$$\frac{P(R1\cap R2\cap R3)}{P(R1\cap R2)}$$ =$$\frac{1}{2}$$
In this way, you get consistent result compared to first approacch. | {
"domain": "stackexchange.com",
"id": null,
"lm_label": "1. YES\n2. YES",
"lm_name": "Qwen/Qwen-72B",
"lm_q1_score": 0.9790357610169274,
"lm_q1q2_score": 0.8607161292243346,
"lm_q2_score": 0.8791467722591728,
"openwebmath_perplexity": 480.8887045995353,
"openwebmath_score": 0.9856621026992798,
"tags": null,
"url": "https://math.stackexchange.com/questions/4072871/why-is-the-answer-to-this-probability-question-not-frac12"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.