Thursday, 6 July 2017

From Binomial to Poisson

There's nothing special about this post. Once again, I'm practising my LaTeX skills and reminding myself at the same time of the connection between the Binomial and Poisson probability distributions. Let's start with a binomial distribution with number of trials \( n \) and probability of success \( \lambda/n \). Let's say that \( n \) is the number of equal intervals into which a unit of time has been divided. The unit of time might be one hour and this interval is divided into 10 equal intervals each of 6 minutes duration. Suppose that there are on average 7 calls during the hour. The probability of a call being received during any one of the intervals is thus 7/10 or 0.7.

Suppose X is a random variable that is binomially distributed with probability of success \( \lambda/n \) and number of trials \( n \), that is \(X \sim B(n, \lambda/n) \). The probability that X takes a special value \( x \) is then given by:\[ P(X=x)=\binom{n}{x} \left( \frac{ \lambda}{n} \right)^x \left( 1-\frac{\lambda}{n} \right)^{n-x} \]This can be written as:\[ P(X=x)=\frac{n(n-1)(n-2) ... (n-x+1)}{x!} \times \frac{\lambda^x}{n^x}\left(1-\frac{\lambda}{n} \right)^{n-x} \]Again, this can be rearranged to:\[ P(X=x)=\frac{\lambda^x}{x!} \times \frac{n-1}{n} \times \frac{n-2}{n} \times ... \times \frac{n-x+1}{n} \times \left(1-\frac{\lambda}{n} \right)^{n-x} \]An \( n  \to \infty \), the expression becomes: \[P(X=x)=\frac{\lambda^x}{x!}e^{-\lambda} \]This formula then represents the Poisson distribution, a suitable model for events which:

  • occur randomly in space or time
  • occur singly, that is events cannot occur simultaneously
  • occur independently
  • occur at a constant rate, that is a mean number of events in a given time interval is proportional to the size of the interval

A discrete random variable that follows a Poisson distribution with parameter \( \lambda \) is written as \(X \sim Po(\lambda) \) and the mean of this distribution is \( \lambda \) and the variance is also \( \lambda \). Thus the mean and variance of a Poisson distribution are equal.

In Google Sheets, the syntax for the Poisson distribution function is shown below:

Thursday, 29 June 2017

A Difficult Integral

I'm wanting to keep up my LaTeX skills so I'm returning to an integral, specifically: $$  \int\limits_0^1 \, \frac{x}{x^3+1}\text{d}x$$The integral is not all that difficult really but it does involve a fair number of steps to get it right. Here is a graph of what is being attempted:


I used symbolab to work through the solution which turns out to be:\[\frac{1}{9}(\sqrt{3}\pi-\ln{(8)})\]The first step in the solution is to factorise the denominator. This is easy because \(x^3+1 \) is a sum of two cubes and so can be written as \((x+1)(x^2-x+1)\). Using partial fractions, the integral can be converted into the following form:\[ \frac{1}{3} \int\limits_0^1 \frac{x+1}{x^2-x+1} \text{d}x-\frac{1}{3} \int\limits_0^1 \frac{1}{x+1} \text{d}x \]The RHS integral is straightforward but the LHS one poses more difficulties. The way forward with the former is to write the quadratic in the denominator as a sum of two squares:\[ \frac{1}{3} \int\limits_0^1  \frac{x+1}{(x-\frac{1}{2})^2+\frac{3}{4}} \text{d}x \]This newly changed denominator can then be divided into the two parts of the numerator to yield:\[ \frac{1}{3} \int\limits_0^1 \frac{x}{(x-\frac{1}{2})^2+\frac{3}{4}}+\frac{1}{3} \int\limits_0^1 \frac{1}{(x-\frac{1}{2})^2+\frac{3}{4}} \]I'm not going to go into the details here but, with the appropriate substitutions, the LHS of this integral can be integrated to a logarithm and the RHS to an arctan using the formulae:\[ \int \frac{2t}{t^2+1} \text{d}t = \ln|t^2+1| + C \text{ and }\int \frac{1}{t^2+1} \text{d}t=\tan \!^{-1}{t}+C \]The indefinite integral for \( x/(x^3+1) \) turns out to be: \[ \frac{1}{6} \Big( \ln|4x^2-4x+4|+2\sqrt{3} \, \tan^{-1} \big( \frac{2}{\sqrt{3}}(x-\frac{1}{2}) \big) \Big)-\frac{1}{3}\ln|x+1|+C \]The definite integral for the limits of 0 and 1 is what was quoted earlier at the beginning of this post. In conclusion, I must say that Blogger is still inconsistently handling the display mode for LaTeX: sometimes it renders the LaTeX using the Javascript and other times it returns an image of the rendered code. Annoying.

Thursday, 22 June 2017

Gaps between Twin Primes

Today I turned 24917 days old. This number is prime and forms a twin prime with 24919. One claim that 24917 has to fame is that it marks the end of a gap of 496 between consecutive twin primes. After 24421 (the larger of twin pairs), there is a gap of 496 numbers until 24917 (the smaller of twin primes).

Source
At the right is a list of the record breaks. Of course, I won't live to experience the next record gap of 628 days between 62299 and 62927. However, I won't have to wait long until the next twin prime pair: 24917 and 24919. There is a gap of only 58 days between 24919 and 24977.

Of course, there's a lot of interest as to whether twin primes go on forever. It's very likely of course but it hasn't been proven. Progress has been made recently however, by Yitang Zhang, James Maynard and Terence Tao with his Polymath Project. The breakthrough relates specifically to the gaps between prime numbers rather than the gaps between successive pairs of twin prime numbers. There's a good account of these developments in this article from quantamagazine.

In any case, I felt it was important to celebrate the end of this latest record gap as my endless, numbered days unravel.

Wednesday, 31 May 2017

Oz Lotto


Last night for $1.30, I bought a single game in Oz Lotto. The winning numbers were 1, 4, 13, 19, 26, 31, 35 and the numbers in bold were the matching numbers that I had in my game. I got three out of the seven numbers which didn't win me a prize but it was impressive nonetheless I thought. What were the odds of this happening?

The number of ways that seven numbers can be selected from 45 numbers, disregarding order, is given by \( ^{45}C_7  = 45,379,620 \). Thus there is only one chance in 45,379,620 that the combination 1, 4, 13, 19, 26, 31, 35 will appear. Given those seven numbers, in how many ways can three of them be chosen? Clearly, in \( ^7C_3 \) = 35 ways.

This means that the number of ways in which three winning numbers can occur out of seven numbers is  \( \text{35 x }  ^{38}C_4 \). This is because none of the remaining four numbers can contain a winning number, thus it is a choice of any four of the remaining 38 non-winning numbers. The probability of choosing three winning numbers in a single game is thus: \[ \text{35 x } \frac{^{38}C_4}{^{45}C_7} = \frac{172235}{3025308} \approx 0.05693 \]Thus the figure as a percentage is about 5.7%. I dithered around trying to work this out but I'm fairly certain that this is the correct approach. For the sake of completeness, I'll work out the probability of getting four, five and six numbers:

For four numbers, chances are: \[ \text{35 x } \frac{^{38}C_3}{^{45}C_7} = \frac{4921}{756327} \approx 0.0065 \]For five numbers, chances are: \[ \text{21 x } \frac{^{38}C_2}{^{45}C_7} = \frac{4921}{15126540} \approx 0.0003 \]For six numbers, chances are:\[ \text{7 x } \frac{^{38}C_1}{^{45}C_7} = \frac{133}{22689810} \text{  or a very small chance!} \]Working on this post, I noticed that Blogger's rendering of LaTeX code has changed. Before, use of the $ sign at the beginning and end of a mathematical expression meant that MathJax was used to create the inline expression:
MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers ... MathJax uses web-based fonts (in those browsers that support it) to produce high-quality typesetting that scales and prints at full resolution (unlike mathematics included as images) source
Now however, use of the dollar sign creates an inline image of the mathematical expression and it is only by use of the curved brackets and backslash that MathJax is invoked. The double dollar sign to create display expressions remains unchanged however, and there is no need yet to use backslash and open and closed square brackets. As before, in Android, nothing seems to work.

Sunday, 21 May 2017

Odd Primitive Abundant Numbers

Today I turned 24885 days old. As usual I turned to WolframAlpha to find the prime number factorisation. It is \(3^2 \times 5 \times 7 \times 79\). I then turned to the Online Encyclopaedia of Integer Sequences (OEIS) to see what was special about the number. First mentioned was OEIS A006038: odd primitive abundant numbers. I was already familiar with abundant numbers. These are numbers in which the sum of the proper divisors exceeds the number itself. The first abundant number is 12 and the sum of its proper divisors (1, 2, 4 and 6) is 13. On the other hand, a number like 15 is called deficient because the sum of its proper divisors (1, 3 and 5) is only 9. A number like 6 is called perfect because the sum of its proper divisors (1, 2 and 3) is 6 and equals the number itself.

The divisors of 24885 turn out to be: 1 | 3 | 5 | 7 | 9 | 15 | 21 | 35 | 45 | 63 | 79 | 105 | 237 | 315 | 395 | 553 | 711 | 1185 | 1659 | 2765 | 3555 | 4977 | 8295 and total 25035. It is clearly an abundant number but what is a primitive abundant number? Well, Wikipedia supplies the following definition: in mathematics a primitive abundant number is an abundant number whose proper divisors are all deficient numbers. 20 is given an example of such a number because its divisors (1, 2, 4, 5 and 10) are all deficient numbers (the sums of the factors being respectively 0, 1, 3, 1 and 8). The sequence of primitive abundant numbers begins as follows (OEIS A091191):
12, 18, 20, 30, 42, 56, 66, 70, 78, 88, 102, 104, 114, 138, 174, 186, 196, 222, 246, 258, 272, 282, 304, 308, 318, 354, 364, 366, 368, 402, 426, 438, 464, 474, 476, 498, 532, 534, 550, 572, 582, 606, 618, 642, 644, 650, 654, 678, 748, 762, 786, 812, 822
It will be noted that any odd numbers are conspicuously absent from this initial list. As it turns out, the first odd primitive abundant number is 945. The sequence of odd primitive abundant numbers begins as follows (OEIS A006038):
945, 1575, 2205, 3465, 4095, 5355, 5775, 5985, 6435, 6825, 7245, 7425, 8085, 8415, 8925, 9135, 9555, 9765, 11655, 12705, 12915, 13545, 14805, 15015, 16695, 18585, 19215, 19635, 21105, 21945, 22365, 22995, 23205, 24885, 25935, 26145, 26565, 28035, 28215
So that's the story. There are:
  • abundant numbers
  • primitive abundant numbers
  • even primitive abundant numbers
  • odd primitive abundant numbers (far less frequent than their even counterparts)
Looking at the list of numbers of odd primitive abundant numbers, it can be seen that it will be about three years before I encounter another one.

Tuesday, 16 May 2017

Varieties of Balanced Primes

Recently I passed the 24877 mark. 24877 is a prime number but it's also a balanced prime of order seven, meaning that it is the average of the seven primes preceding it and seven primes succeeding it. The first example of such a prime is 29 because:
$$\textbf{29} = \frac{\overbrace{5 + 7 + 11 + 13 + 17 + 19 + 23}^\text{seven primes below}}{15} \\ + \frac{\textbf{29} + \overbrace{31 + 37 + 41 + 43 + 47 + 53 + 59}^\text{seven primes above}}{15}$$Balanced primes range from order one upwards with the first balanced prime of order one being 5 where:$$\textbf{5}=\frac{3+\textbf{5}+7}{3}$$A subset of the balanced primes are those primes that are doubly balanced, meaning they are averages of both their immediate and their second neighbours. The first example of such a prime is 18731 with surrounding primes of 18713, 18719 below and 18743, 18749 above. We find that:$$ \begin{align} \textbf{18731} &= \frac{18719+\textbf{18731}+18743}{3} \\
&=\frac{18713+18719+\textbf{18731}+18743+18749}{5} \end{align} $$
Primes can be triply balanced (the first of these is 683783), quadruply balanced (the first of these is 98303927) and so on. In terms of the counting of the days of our lives, it is only the first five of the doubly balanced primes (18731, 25621, 28069, 30059 and 31051) that we are likely to encounter.

A prime can be balanced in more ways than one but the orders may not be continuous. A doubly balanced prime like 18713 is a balanced prime of order 1 and order 2. Here the orders, 1 and 2, are continuous. However, a prime like 263 can be written as (257 + 263 + 269)/3 but also (179 + 181 + 191 + 193 + 197 + 199 + 211 + 223 + 227 + 229 + 233 + 239 + 241 + 251 + 257 + 263 + 269 + 271 + 277 + 281 + 283 + 293 + 307 + 311 + 313 + 317 + 331 + 337 + 347 + 349 + 353)/31. It is a balanced prime of order 1 and order 31, but 1 and 31 are not continuous. Both 263 and 18713 are said to be balanced primes of index 2. The balanced primes of index 1 are those that are balanced in one way only, the first of these being 5.

Unlike the doubly balanced primes (18731, 25621, 28069, 30059, 31051 etc.), the balanced primes of index 2 are relatively frequent. Here is a list of the first of them:

211, 263, 349, 397, 409, 439, 709, 751, 787, 827, 1153, 1187, 1259, 1487, 1523, 1531, 2281, 2287, 2347, 2621, 3037, 3109, 3313, 3329, 3539, 3673, 4357, 4397, 4493, 4951, 4969, 4987, 5189, 5303, 5347, 5857, 6323, 6337, 7583, 7907, 7933, 8429, 8713, 8821

After that, they naturally become less frequent. Here are the first balanced primes of index 3:

53, 607, 977, 1289, 2083, 2351, 4013, 5563, 8803, 10657, 11117, 12583, 14747, 16433, 18731, 22067, 22699, 28477, 32833, 39227, 39749, 41957, 44357, 46229, 46643, 50053, 50123, 51869, 53617, 54469, 56167, 63377, 63527, 66797, 74729, 75217

Even the first few balanced primes of index 4 (157, 353, 8233, 23893, 26183 and 30197) will occur within the lives of most individuals.