brain
tamnd's digital brain — notes, problems, research
41333 notes
Algorithm R uses the reservoir only because the final sample must ultimately be written in the same order as the corresponding records appeared in the input file.
Let $S$ be any fixed subset of $n$ records chosen from the $N$ available records.
Let $T$ be the value of $t$ when Algorithm S terminates.
Let $X$ denote the number of input records skipped before the first selection in Algorithm S.
Let $p(m,t)$ denote the probability that exactly $m$ items are selected from among the first $t$ in Algorithm S, where $0 \le t \le N$.
We are asked to determine if an array of integers is 3SUM-closed, which means that for every triple of distinct elements in the array, the sum of those three elements is itself present somewhere in th...
Let $T$ denote the value of $t$ when Algorithm S terminates.
We are asked to **explain Eq.
Algorithm S proceeds by examining the input file sequentially, maintaining two counters: $t$, the number of records remaining in the input file, and $n$, the number of additional records still to be s...
Let $N(0,1)$ denote the normal distribution with mean $0$ and variance $1$.
Algorithms P, M, F, and R generate a normal deviate by reading a sequence of independent uniform random variables U_1,U_2,U_3,\ldots, stopping after a random number of them has been examined.
**Problem.
Let $\mu > 0$ be a given constant.
We seek $n$ random variables $X_1, \ldots, X_n$ satisfying $0 \le X_1 \le \cdots \le X_n \le 1$, such that the joint distribution is uniform over all nondecreasing sequences in $[0,1]^n$.
Let $N_1$ and $N_2$ be independent Poisson random variables with parameters $\mu_1$ and $\mu_2$, where $\mu_1 > \mu_2 \ge 0$.
The previous solution failed because it did not analyze the logistic map V_{n+1} = 4V_n(1 - V_n) under finite precision.
Let E_t=X_1\mid\bigl(X_2\mathbin{\&}(X_3\mid(X_4\mathbin{\&}X_5)\cdots )\bigr) denote the given bitwise expression.
Two constructions are proposed for generating a random variable $X$ with a nontrivial distribution on $[-1,1]$.
We are asked to determine whether the exact Poisson distribution with mean $\mu$, for large $\mu$, can be obtained by generating a suitable normal deviate, converting it to an integer, and applying a...
Let $A$, $R$, $I$, and $E$ denote the areas defined in Exercise 3.
Algorithm R is a rejection method based on a rectangle of area $R$ containing the desired region of area $A$.
We are asked to count, for every interval $[l, r]$, how many triples of distinct integers $i < j < k$ inside this interval satisfy a structural inequality involving their least common multiple: the LC...
We are asked to generate a random integer $N$ with distribution $\Pr\{N = n\} = n p^2 (1-p)^{n-1}, \qquad n \ge 0, \; 0 < p \le 1.$ We first verify that this is a proper probability distribution.
The provided solution is not failing because of a small implementation bug.
Let $a$ be a given constant with $0 < a \le 1$.
The solution explicitly constructs all the auxiliary constants $S_s, Q_s, P_s, Y_s, Z_s, D_s, E_s$ in a way that mirrors Algorithm M’s two-stage sampling procedure.
Let $X_1$ and $X_2$ be independent random variables with distribution functions $F_1(x)$ and $F_2(x)$, and densities $f_1(x) = F_1'(x)$ and $f_2(x) = F_2'(x)$.
The statement of the exercise contains an obvious typographical error, since \int_x^\infty e^{-t^2/2}\,dt \bigg/ \int_x^\infty e^{-t^2/2}\,dt = 1.
Let f(x)=e^{-x^{2}/2}.
A correct solution must explicitly construct the tables from the given target distribution and show that Algorithm M’s two-stage selection reproduces those probabilities.
To determine why the curve $f(x)$ is concave for $x < 1$ and convex for $x > 1$, we analyze its second derivative.
The target is to generate a random variable $X$ whose distribution function is a cubic polynomial in $x$: F(x) = px + qx^2 + rx^3, where $p, q, r \ge 0$ and $p + q + r = 1$.
Let there be $k$ distinct colors of cubes, denoted $C_1, \ldots, C_k$, and for each $j$, there are $n_j$ cubes of color $C_j$, with $1 \le j \le k$.
Let $N$ denote the number of times step 1 is performed until the procedure terminates.
The target is to generate a random variable $X$ whose distribution function is a cubic polynomial in $x$: F(x) = px + qx^2 + rx^3, where $p, q, r \ge 0$ and $p + q + r = 1$.
Let Y=\max(X_1,X_2), where $X_1$ and $X_2$ are independent random variables having distribution functions
Let $R = mU$ be an integer uniformly distributed on ${0,1,\dots,m-1}$.
Let $U$ be a uniform random variable on $[0,1)$, and let $m$ be a positive integer such that $mU$ is interpreted as a random integer between $0$ and $m-1$; that is, we define I = \lfloor mU \rfloor, \...
Let $U$ be a random variable uniformly distributed on $[0,1)$.
Let \frac{a}{m}=[0;a_1,a_2,\ldots,a_s] be the simple continued fraction expansion of $a/m$, where $(a,m)=1$ and $0<a<m$.
Let $m_1 = 2^{31} - 1$ and $m_2 = 2^{31} - 249$.
Let $r_{\max}$ denote the maximum value of the function $r(u_1,\ldots,u_t)$ among all nonzero vectors satisfying the congruence (46).
The crash is very specific: IndexError: list index out of range if b[i] > a[i]: This means the code assumes that for every test case:
Let $m$ be a prime, let $a$ be a primitive root modulo $m$, let $c=0$, and let X_{n+1}\equiv aX_n\pmod m, with $X_0\not\equiv0\pmod m$.
Exercise 25 established a bound for the exponential sums S_N(u)=\sum_{0\le n<N} e^{2\pi i uX_n/m}, where $u\not\equiv0\pmod m$.
The previous argument fails because it incorrectly replaces a structured analytic sum by a sparsity count and incorrectly assumes sign and support properties.
Let $U_1,\ldots,U_t$ and $V_1,\ldots,V_t$ be vectors in a real inner-product space such that U_i \cdot V_j = \delta_{ij}, \qquad 1 \le i,j \le t, U_i \cdot U_i = 1, \qquad 2|U_i \cdot U_j| \le 1 \ \te...
The failure here is not algorithmic at all.
For $t=1$, Eq.
Let $\mu_2$ and $\mu_3$ denote the $2$-dimensional and $3$-dimensional spectral radii, respectively, as defined in Section 3.
We are asked to study the lattice structure of the points $\left\{\frac{1}{m}\bigl(X_{4n}, X_{4n+2}, X_{4n+3}\bigr) \;\Big|\; 0 \le n < m/4 \right\},$ where $(X_n)$ is a linear congruential sequence o...
Let $X_{n+1} = aX_n \bmod 2^e$ with $c = 0$, $X_0$ odd, and $a \bmod 8 \in \{3,5\}$.
We are asked to construct a worst-case example for **Algorithm S**: 1.
We consider the modification proposed in Exercise 3.
**Exercise 3.
The previous submission fails because it does not engage with the actual content of Algorithm S or the mathematical structure of the problem.
Connection interrupted.
Solution to TAOCP 3.3.4 Exercise 14.
Let the quadratic form in $t$ variables be $f(x_1, \ldots, x_t) = \sum_{i=1}^t \sum_{j=1}^t a_{ij} x_i x_j, \eqno(19)$ with symmetric coefficient matrix $U = (a_{ij})$.
The earlier argument fails because it replaces a simple finite-generation observation with an incorrect lattice construction.
Let $m = 2^e$.
Let y = (y_1,y_2), \quad u = (u_1,u_2) with integer components.
Edit We have a collection of planets, and every planet belongs to some orbit.
**Corrected Solution to Exercise 3.
**Exercise 3.
There is not enough information to diagnose the bug.
Let Algorithm S be the two-dimensional spectral-test algorithm of Section 3.
Let $L = \{(y_1,y_2)\in \mathbb{Z}^2 \mid y_1 + a y_2 \equiv 0 \pmod m\}.$ Define the column vectors $v_1 = (u_{11},u_{12}), \quad v_2 = (u_{21},u_{22}), \quad U = (v_1\ v_2).$ The hypotheses are $u_{...
The previous solution fails in the 6-dimensional step because it incorrectly assumes that coordinate-difference vectors such as $(1,-1,0,0,0,0)$ lie in the dual lattice.
Let $L_0\subset \mathbb{R}^t$ be the lattice generated by the linearly independent vectors $V_1,\ldots,V_t$, so every point of $L_0$ has the form L_0=\left\{\sum_{i=1}^t n_i V_i \;:\; n_i\in\mathbb{Z}...
When $t = 1$, the spectral test considers the set of points $\left\{\frac{1}{m} x \;\Big|\; 0 \le x < m\right\}$ in one-dimensional space, which is simply the set of equally spaced multiples of $1/m$...
Producing a complete editorial of the quality requested requires first reconstructing and proving the underlying greedy graph construction used in Codeforces 1735C.
Edit We are given an array `a`.
Let $s(x)=\{ax\}, \qquad a\in \mathbb Z,\ a\ge 1,$ and let $U_{n+1}=s(U_n)=\{aU_n\},$ with $U_n$ uniformly distributed on $[0,1)$.
We are asked to consider the Fibonacci generator U_{n+1} = \{ U_n + U_{n-1} \}, \quad n \ge 2, with $U_1, U_2$ independently uniform on $[0,1)$, and to compute the probabilities of the six possible st...
We are asked to compute the probability that a uniformly distributed real number $x \in [0,1)$ satisfies both $\alpha \le x < \beta$ and $\alpha' \le s(x) < \beta'$, under the assumptions of Exercise...
The flawed solution fails at a structural point: it tries to import permutation symmetry of the joint vector $(U_n,U_{n+1},U_{n+2})$, which does not exist for a deterministic dynamical system.
Let $s(x)=\{ax+\theta\}, \qquad 0\le \theta<1,$ where $a$ is an integer and $x$ is uniformly distributed on $[0,1)$.
Let X_{n+1}\equiv aX_n+c \pmod m, and assume that the generator has full period $m$.
Let $X_n$ be a linear congruential sequence X_{n+1} \equiv a X_n + c \pmod m, \quad 0 \le X_n < m, and define the iterates
C=\frac{\displaystyle \int_0^1 x\,\{ax+\theta\}\,dx-\left(\int_0^1x\,dx\right)^2} {\displaystyle \int_0^1x^2\,dx-\left(\int_0^1x\,dx\right)^2}, \qquad 0\le \theta<1, where $a$ is a positive integer an...
The previous solution does not solve the exercise that was asked.
Let S(h,k,c,z)=\sum_{0\le j<z}\left(\!
We are asked to generalize Lemma B to all real values of $c$, $0\le c<k$.
We are asked to prove the identity \sum_{j=1}^{t} (-1)^{j+1} \frac{c_j^2}{m_j m_{j+1}} = \frac{1}{m_1} \sum_{j=1}^{t} (-1)^{j+1} b_j (c_j + c_{j+1}) p_{j-1}, where the sequences $(m_j)$ and $(p_j)$ co...
We are asked to determine the serial correlation coefficient $C$ of the linear congruential generator $X_{n+1} = (a X_n + c) \bmod m$ with parameters $m = 2^{35}, \quad a = 2^{17} + 1, \quad c = 1,$ o...
The issue is not with the core idea of sweeping and using endpoint extrema per color.
Equation (28) in Section 3.
Hmm.
Let $\sigma(h,k,c)$ be the sawtooth sum used in the TAOCP context, where the key structure is a sum over a complete residue system modulo $k$ of a shifted sawtooth expression of the form \sigma(h,k,c)...
Let (x)=x-\lfloor x\rfloor-\tfrac12 be the centered sawtooth function and
Let D(a,b;c)=\sum_{j=0}^{c-1} \left(\!
Let $h h' + k k' = 1$.
Hmm.
From Eq.
The problem asks for the maximum possible value of $d$ in the notation of Theorem P, given that $m = 10^{10}$ and the potency of the generator is 10.
**Exercise 3.
Let ${Y_n}$ be a binary sequence generated by the linear recurrence over $\mathbb{F}_2$ Y_n = (a_1 Y_{n-1} + \cdots + a_k Y_{n-k}) \bmod 2, with period $2^e - 1$, and initial state not the all-zero st...
The previous implementation fails because it blindly alternates the column in a zigzag without checking **preexisting cacti** in adjacent cells.
Let the sequence $(Y_n)$ satisfy the recurrence Y_n = (Y_{n-21} + Y_{n-55}) \bmod 2 over $\mathbb{F}_2$.