1

Let $(A,B,C)$ follow a multinomial distribution: $$(A,B,C) \sim \text{MultiNom}\left(n=100,p_1=p_2=p_3=\frac13\right).$$ Define $X$, a discrete random variable as $$X = f(A,C) = 2A + 3B + 4C = 2A + 3(100-A-C) + 4C = 300 + C - A$$ where $X$ has integer support from $[200,400]$.

If you wish to find the probability for $X$ being at or above a given value: $$Pr(X \ge x)$$ you can use the following code to sum the different multinomial events

n <- 100
probs <- rep.int(0,n+1)
for(X in n:0) {
    ctr_x = n-X+1
    for(ctr_j in 1:ceiling(ctr_x/2)) {
        a <- ctr_j-1
        c <- X+a
        b <- n - a - c
        probs[ctr_x] <- probs[ctr_x] + dmultinom(c(a,b,c),prob=c(1,1,1))
    }
}
cumsum(probs)

(This code only calculates the probabilities for $X$ 300 or above, but the idea carries for any value of $X$.)

You can also obtain these values using a Fast Fourier Transform (code written by whuber). Here is the code for this

f <- fft(c(c(1/3,1/3,1/3), rep(0,253)))
fn <- Re(fft(f^100, inverse=TRUE))/length(f)
x <- seq_along(fn)+2*100-1
plot(x, cumsum(fn), xlim=c(270, 330))

And you can confirm that the results are the same:

cbind(1-cumsum(fn)[100:120],cumsum(probs)[101:81])

From this, I have a number of questions. First and foremost, ¿how does a fast Fourier transform yield the probabilities for a multinomial random variable?

Follow-up queries are...

  1. ¿why are there 253 zeros in the argument for fft(·)?
  2. ¿why is f raised to the power 100?
  3. ¿how does the real part of this result given the result?
  4. and, ¿does the imaginary part mean anything at all?

Any assistance in how to better understand this strategy would be appreciated.

Gregg H
  • 5,474
  • There are several questions here. Fortunately, the hard ones already have answers on CV. https://stats.stackexchange.com/questions/331973 explains why the distribution of the sum is a convolution. The FFT transforms convolution of functions into point-by-point multiplication: that explains raising to the power 100 to perform 100 sums. The result must be real, but numerical imprecision in the calculations can cause small imaginary terms to creep in: remove the call to Re to see. Finally, 253 is not magical, but the total length, 3+253 = 256, is: it's a power of 2. Type ?fft to understand. – whuber Jun 12 '23 at 18:37
  • For a few more details on fft -- which really computes the characteristic function of the distribution -- see the section "Intuition from Characteristic Functions" at https://stats.stackexchange.com/a/43075/919. – whuber Jun 13 '23 at 14:40
  • Another related query: ¿why weren't the coefficients 2, 3 & 4 included in the linear combination of the random variables? and in turn, ¿why these coefficients can be excluded from the ftt(·) call? – Gregg H Jun 14 '23 at 17:57
  • The probability distribution is represented as a vector of probabilities $(p_2,p_3,p_4):$ that is, the values are implicitly represented by the subscripts. Generally, you apply the FT to discrete versions of distributions. When $F$ is a distribution supported on an interval $(0,b],$ you can divide that interval into $N$ bins $(0,d],$ $(d,2d],$ $\ldots ((N-1)d,Nd]$ with $d=b/N$ and represent $F$ as the vector $(F((i+1)d)-F(id))$ for $i=0,1,\ldots, N-1.$ When $F$ is supported on $(a,c],$ work with the shifted distribution $F-a$ supported on $(0,b]=(0,c-a],$ as I did here. – whuber Jun 14 '23 at 18:29
  • For concrete examples see the code I have posted at https://stats.stackexchange.com/a/291571/919 and https://stats.stackexchange.com/a/113662/919. – whuber Jun 14 '23 at 18:32

0 Answers0