normalDistribution

I have never written anything on Statistics (coz I hate statistics) on my blog so far and I believe I am going to start writing something on it from now on. I picked Normal Distribution because it is important. By Central limit theorem, in simple terms if you have many independent random variables that are generated by all kinds of crazy distribution, the sum of those random variables will tends toward the Normal distribution.

Normal Distribution

f(x) = \displaystyle\frac{1}{\sqrt{2\pi}\sigma} e^{-\frac12(\frac{x-\mu}{\sigma})^2}

where x, \mu \in \mathbb{R}, \sigma\in\mathbb{R}^+.

Then the MGF (Moment Generating Function) would be the following:

\displaystyle M_X(t) = E(e^{tX}) = \int_{-\infty}^{\infty} e^{tx}\frac{1}{\sqrt{2\pi}\sigma}e^{-\frac12(\frac{x-\mu}{\sigma})^2} \text{ d}x

\displaystyle = \int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}\sigma} e^{tx-\frac12(\frac{x-\mu}{\sigma})^2} \text{ d}x

\displaystyle = \int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}\sigma} \exp\left(\frac{2\sigma^2tx-(x^2-2x\mu+\mu^2)}{2\sigma^2}\right)\text{ d}x

\displaystyle = \int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}\sigma}\exp\left(\frac{-x^2+(2\sigma^2t+2\mu)x-\mu^2}{2\sigma^2}\right) \text{ d}x

Now using completing the square,

-x^2+2(\sigma^2t+\mu)x-\mu^2

= -(x^2-2(\sigma^2t+\mu)x+(\sigma^2t+\mu)^2-(\sigma^2t+u)^2)-\mu^2

= -(x-(\sigma^2t+\mu))^2+(\sigma^2t+\mu)^2-\mu^2

= -(x-(\sigma^2t+\mu))^2 + \sigma^4 t^2 + 2\sigma^2 t\mu

hence,

\displaystyle M_X(t) = \int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}\sigma} \exp\left(\frac{-(x-(\sigma^2t+\mu))^2+\sigma^4t^2+2\sigma^2t\mu}{2\sigma^2}\right) \text{ d}x

\displaystyle = \exp\left(\frac{\sigma^2t^2+2t\mu}{2}\right) \int_{-\infty}^\infty \frac{1}{\sqrt{2\pi}\sigma} \exp\left(-\frac12 \left(\frac{x-\sigma^2t-\mu}{\sigma}\right)^2\right) \text{ d}x

Since the integral is the cumulative distribution function of the normal distribution which shift to the right by \sigma^2t units, the integral does sum to one. Therefore we left with

\displaystyle M_X(t) = \exp\left(\frac{\sigma^2t^2}{2}+t\mu\right)

Expected Value

\displaystyle E(X) = M_X'(t)\bigg|_{t=0} = \exp\left(\frac{\sigma^2t^2}{2}+t\mu\right) \cdot (\sigma^2t+\mu)\bigg|_{t=0} = \mu

Variance

\displaystyle E(X^2) = M_X''(t)\bigg|_{t=0} =\exp\left(\frac{\sigma^2t^2}{2}+t\mu\right)(\sigma^2t+\mu)^2 + \exp\left(\frac{\sigma^2t^2}{2}+t\mu\right)\sigma^2\bigg|_{t=0}

= \mu^2 + \sigma^2

Hence,

Var(X) = E(X^2)-E^2(X) = \mu^2 + \sigma^2 - \mu^2 =\sigma^2

Advertisements

Some Interesting Prime Numbers

Posted: April 14, 2018 in Mathematics

Prime numbers are the building blocks of all natural numbers. The Fundamental Theorem of Arithmetic states that every natural number greater than one is a prime itself or can be uniquely expressed as a product of primes. A prime number is a number that has one and itself as its factors, otherwise the number is composite. Although 1 has 1 and itself as its only factors, 1 is not considered as a prime. Due to the fact that defining 1 as a prime will destroy the uniqueness of the prime factorization of a number. Anyhow, there are a few prime numbers that I personally think they are interesting.

2 is the only even prime number

Any even number that is greater than 2 can be written as the product of 2 and a natural number greater than one so all even numbers greater than 2 are composite.

91 is NOT a prime number

I think almost all students in elementary school or even some in highschool thought 91 is a prime number. I am not kidding, if you are a teacher or a math tutor, you know what I mean. Almost 9 out of 10 students I encountered with always think 91 is a prime number. It could be that 91 isn’t in the times table? and it is odd and doesn’t end with a 5? and maybe it is obviously not divisible by 3 that makes people think 91 is highly unlikely a composite number? Or maybe people are too lazy to try to divide 91 by 7 and see for themselves.

1979 is the year I was born and it is a prime number

Yeah I am kind of proud to be born on the year that is a prime πŸ™‚

2017 is the year which bitcoin increased 20 fold

It’s not because of bitcoin price has been increased from $1000 to $20,000 in the year 2017. The reason I think 2017 is an interesting prime number is that if you add up all the odd prime numbers from 3 all the way up to 2017, you will get a prime number as the result. 3 + 5 + 7 + 11 + 13 + … + 2017 = 283079 which is a prime number. You can check it with wolfram alpha. There are also some fun facts about 2017 I found on the internet.

  • 20170123456789 is prime
  • 2017Ο€ (round to nearest integer) = 6337 is primeΒ 
  • 2017e (round to nearest integer) = 5483 is prime
  • The sum of the cube of gap of primes up to 2017 is a prime number.
    (3-2)^3+(5-3)^3+(7-5)^3+\cdots+(2017-2011)^3
  • These three prime numbers are consecutive
    2011 = 2017+2-0-1-7
    2017 = 2017 + 2 \times 0 \times 1 \times 7
    2027 = 2017+2+0+1+7

prime numbers that you can find in Pi

This is first 50 digits of Pi.

\pi \approx 3.1415926535897932384626433832795028841971693993751 \ldots

Couple years ago I was reading a book on recreational math and the author quoted that the first 12 digits of Pi (after rounding off) is a prime number. 314159265359 is a prime number. Of course you can always check it with wolfram alpha. So I found 3, 31, 314159, andΒ 31415926535897932384626433832795028841 are also primes as well. There maybe more. I may wrote a script on maple to find more later when I have the time.

a prime that is unlucky with the devil

1000000000000066600000000000001 is a prime number. 666 is the number of a beast in the bible (I didn’t read the whole bible, that’s just what everyone is saying). The number 666 is considered as a devil which sits right inside in the middle of this prime number. And there are “13” zeros on the left and on the right of the number 666. Why 13 is unlucky? I don’t have a clue just go along with the majority.

12345678910987654321 is a prime number

This is no doubt one of the nice prime numbers even a 3 year old can remember.

a prime number that ends with “19” and “67”

1234567891011121314151617181967 is a prime number. This is a prime number that is easy to remember if you are a HKer and speak Cantonese because it is “19” and “67”. This number is very nice all you need to do is to write down the number 1, 2, 3, all the way up to 19 and then ends it with 67. πŸ™‚

the largest known prime as of March 2018

I can’t end this article without writing down the largest known prime to human. As of March 2018 according to Wikipedia, the largest known prime is

2^{77232917} - 1

which is found by the GIMPS (Greatest Internet Mersenne Prime Search) in 2017. I am not gonna bother typing the number out because it is 23,249,425 digits long!

Ans: 10P7 πŸ™‚

photo_2018-03-01_12-59-13.jpg

Q24.

Denote G_i, R_i, B_i, Y_i as the i-th bucket that contains the puck.

If all 4 pucks are distributed into the same Green bucket, then we don’t need to worry about the Red, Blue, and Yellow buckets since they won’t have 4 pucks in them. So,

\displaystyle P(G_a, G_a, G_a, G_a) = 3 \left(\frac13\right)^4 = \frac{1}{27}

Now, 3 pucks are distributed into the same Green bucket, then we only need to exclude the case where 3 pucks are put into the same Red bucket. There are 4 ways to permute aaab and 3 numbers to pick for a and b which is 6 ways, so

\displaystyle P(G_a, G_a, G_a, G_b) \cdot (1 - P(R_a, R_a, R_a)) = 4 \cdot 6 \cdot \left(\frac13\right)^4 \cdot \left(1-3 \left(\frac13\right)^3\right) = \frac{64}{243}

If 2 pucks are distributed into the same Green bucket, then we only need to consider the case where all 3 pucks are distributed evenly into three different Red buckets and all 2 pucks are distributed evenly into two different Blue buckets. The most difficult part of the problem is in this case here. We need to find the number of ways to permute n repeated objects, aabc, which is \dfrac{4!}{2!1!1!}, and since the permutation of b and c has already counted, we need to only consider how many numbers go into the choice of a which is 3.

\displaystyle P(G_a, G_a, G_b, G_c) \cdot P(R_a, R_b, R_c) \cdot P(B_a, B_b) \\ = \frac{4!}{2!1!1!}\cdot 3 \cdot \left(\frac13\right)^4 \cdot 3!\left(\frac13\right)^3 \cdot (3P2) \left(\frac13\right)^2 \\ = \frac{4}{9}\cdot\frac{2}{9}\cdot\frac{2}{3} = \frac{16}{243}

Final step, add the three results and we get

\displaystyle \frac{1}{27} + \frac{64}{243} + \frac{16}{243} = \frac{89}{243}


Q25.

For 1 \leq k \leq 2018 and P, Q, R \in \{1,2,\ldots,9\}

P_{2k} - Q_k = (R_k)^2

When k = 1,

11P - Q = R^2. The 8 quadruples are easy to find, they are

(1,7,2,1), (1,2,3,1), (2,6,4,1), (3,8,5,1), (4,8,6,1), (5,6,7,1), (6,2,8,1), (8,7,9,1)

When k = 2,

1111P - 11Q = 11^2R^2 \Rightarrow 101P - Q = 11R^2

When k = 3,

111111P - 111Q = 111^2R^2 \Rightarrow 1001P - Q = 111R^2

\therefore (10^k+1)P-Q=\dfrac{10^k-1}{10-1}\cdot R^2 \Rightarrow (10^k+1)P-Q=\dfrac{10^k-1}{9} \cdot R^2

or

P-Q \equiv 11R^2 \pmod{100} \text{ for } k \geq 2

\underline{\quad R \qquad R^2 \qquad 11R^2 \qquad 11R^2 \mod{100} \quad} \\ \text{ } \quad 1 \qquad 1 \quad \qquad 11 \qquad\qquad\qquad 11 \\ \text{ } \quad 2 \qquad 4 \quad \qquad 44 \qquad\qquad\qquad 44 \\ \text{ } \quad 3 \qquad 9 \quad \qquad 99 \qquad\qquad\qquad 99 \equiv -1 \\ \text{ } \quad 4 \qquad 16 \quad \quad 176 \qquad\qquad\qquad 76 \\ \text{ } \quad 5 \qquad 25 \quad \quad 275 \qquad\qquad\qquad 75 \\ \text{ } \quad 6 \qquad 36 \quad \quad 396 \qquad\qquad\qquad 96 \equiv -4 \\ \text{ } \quad 7 \qquad 49 \quad \quad 539 \qquad\qquad\qquad 39 \\ \text{ } \quad 8 \qquad 64 \quad \quad 704 \qquad\qquad\qquad 4 \\ \text{ } \quad 9 \qquad 81 \quad \quad 891 \qquad\qquad\qquad 91

Therefore, R can only be 3, 6, or 8.

When R = 3,

(10^k + 1)P - Q = 10^k - 1

10^k P + P - Q = 10^k - 1

\text{Since } P - Q \equiv -1 \mod{100}

10^k P - 1 = 10^k - 1

\Rightarrow P = 1, Q = 2 \quad \therefore (1,2,3,k) \text{ for } 1 < k \leq 2018

Therefore 2017 quadruples.

When R = 6,

(10^k + 1)P - Q = \dfrac{10^k-1}{9} \cdot 36

10^k P - 4 = 4\cdot 10^k - 4

\Rightarrow P = 4, Q = 8 \quad \therefore (4,8,6,k) \text{ for } 1 < k \leq 2018

Therefore 2017 quadruples.

When R = 8,

(10^k + 1)P - Q =\dfrac{10k-1}{9} \cdot 64

9(10^k P + 4) = 64 \cdot 10^k - 64

9 \cdot 10^k P + 36 = 64 \cdot 10^k - 64

100 = (64 - 9P) 10^k

Now, obviously k > 2 has no solution.

If k = 2,

1 = 64 -9P

\Rightarrow P = 7, Q = 3

\therefore (7,3,8,2) is a solution.

In conclusion, N = 8 + 2017 + 2017 + 1 = 4043.

Therefore the sum of digits of N is 11.

What is \pi? \pi is a constant. It is a ratio of the circumference to the diameter of a circle. It’s value is approximately 3.14 or 3.14159 if one cares about accuracy, however 3.14159 is only correct to 6 significant figures. If you pull out your everyday scientific calculator and press the \pi button, it will show 3.141592654 on the display. Although this value is good to 10 significant figures, it still contains an error. I know it has error because I have \pi memorized to 3.14159265358979323846… You may wonder why I memorize \pi to 21 digits? It could be the password to one of my dozen email addresses. You can try hacking my email with it πŸ™‚

No matter how many digits of \pi you write down on a piece of paper, it is still just an approximation. The tail of \pi never terminates. It is an irrational number. Most mathematicians don’t really like approximation, so you rarely see one write 3.14 as \pi. It’s just not correct and not cool to write \pi = 3.14 (other than PIE=314). So today I am gonna show you a cool way to write \pi.

\pi = \left(\left(-.5\right)!\right)^2 \quad \text{ or } \quad \pi = \Gamma^2(\frac12)

The symbol “!” means factorial. By definition,

n! = n(n-1)(n-2)\cdots 2 \cdot 1 for all positive integers n. So

1! =1,

2! = 2\cdot 1 = 2,

3! =3\cdot2\cdot1 = 6

and so on.

What about (-0.5)!? The above definition didn’t include non-positive integer factorial. So we need to find a way to extend the factorials to a larger set of number that includes decimal numbers. One way to do it is by using Gamma function.

\displaystyle \Gamma(s) = \int_0^\infty t^{s-1} e^{-t} \text{ d}t

First of all, we need to verify that this Gamma function indeed satisfies

f(1)=1 \text{ and } f(n+1) = nf(n)

\displaystyle \Gamma(1) = \int_0^\infty e^{-t} \text{ d}t = -e^{-t}\bigg|_0^\infty = 1

and by using integration by parts, we get

\displaystyle \Gamma(s+1) = \int_0^\infty t^s e^{-t} \text{ d}t = -t^s e^{-t}\bigg|_0^\infty + s\int_0^\infty t^{s-1} e^{-t} \text{ d}t = s\Gamma(s)

And therefore the Gamma function does indeed extend the factorials to the real numbers, and in fact also the complex numbers as well.

\Gamma(1) = 1

\Gamma(2) = 1\cdot\Gamma(1) = 1

\Gamma(3) = 2\cdot\Gamma(2) = 2\cdot 1

\Gamma(4) = 3\cdot\Gamma(3) = 3\cdot 2 \cdot 1

Hence, we see that

n! = \Gamma(n+1)

Now, let’s compute \Gamma\left(\frac12\right).

By using substitution of w=\sqrt{t}, we get

\displaystyle\Gamma\left(\frac12\right) = \int_0^\infty \frac{e^{-t}}{\sqrt{t}} \text{ d}t = 2\int_0^\infty e^{-w^2} \text{ d}w

Now let \displaystyle I=\int_0^\infty e^{-w^2} \text{ d}w,

\displaystyle I^2 = \int_0^\infty e^{-x^2}\text{ d}x \int_0^\infty e^{-y^2}\text{ d}y =\int_0^\infty \int_0^\infty e^{-(x^2+y^2)} \text{ d}x\text{ d}y

then by using polar coordinates,

\displaystyle I^2=\int_0^{\pi/2} \int_0^\infty e^{-r^2} r\text{ d}r\text{ d}\theta = \frac{\pi}{2} \int_0^\infty re^{-r^2} \text{ d}r

By substituting u =r^2 we get

\displaystyle I^2 = \frac{\pi}{4} \int_0^\infty e^{-u} \text{ d}u = \frac{\pi}{4}(-e^{-u})\bigg|_0^\infty = \frac{\pi}{4}

\therefore I = \dfrac{\sqrt\pi}{2}

Therefore,

\displaystyle \Gamma\left(\frac12\right) = \sqrt\pi

or

\pi = \Gamma^2\left(\dfrac12\right)

or

\pi = \left(\left(-\dfrac12\right)!\right)^2

if you accept the factorial notation πŸ™‚

 

 

Usually in school, you learn how to construct a parallelogram with compass and straightedge. But today, I am gonna show you how to construct a parallelogram with only one ruler. Of course, you need a piece of paper, a pencil, a hand, and your brain as well, etc …

Actually the method is very simple, even an eight year old can do it I promise. So here it is:

  1. Draw a quadrilateral (4-sided shape), any quadrilateral will do even the non-convex one.
  2. Find the midpoint of all four sides with your ruler.
  3. Connect those four midpoints together and you are done.

Here are some examples.

DrawingParallelogram

The proof is very simple.

Let the four points A(a_1, a_2),Β B(b_1, b_2),Β C(c_1, c_2),Β D(d_1, d_2) be the vertices of a quadrilateral.

DrawingParallelogramProof

Then the four midpoints are

\displaystyle P\left(\frac{a_1+b_1}{2}, \frac{a_2+b_2}{2}\right), Q\left(\frac{b_1+c_1}{2}, \frac{b_2+c_2}{2}\right), R\left(\frac{c_1+d_1}{2}, \frac{c_2+d_2}{2}\right), S\left(\frac{d_1+a_1}{2}, \frac{d_2+a_2}{2}\right)

Find the slopes of the sides and show that the opposite sides are parallel:

m_{PQ} = \dfrac{c_2-a_2}{c_1-a_1} = m_{RS} \Rightarrow PQ \;//\; RS

m_{QR} = \dfrac{d_2-b_2}{d_1-b_1} = m_{SP} \Rightarrow QR \;//\; SP

Therefore PQRS is a parallelogram.

Sum of Zeroth Powers

1^0 + 6^0 + 7^0 + 23^0 + 24^0 + 30^0 + 38^0 + 47^0 + 54^0 + 55^0 = 10

2^0 + 3^0 + 10^0 + 19^0 + 27^0 + 33^0 + 34^0 + 50^0 + 51^0 + 56^0 = 10

Sum of First Powers

1^1 + 6^1 + 7^1 + 23^1 + 24^1 + 30^1 + 38^1 + 47^1 + 54^1 + 55^1 = 285

2^1 + 3^1 + 10^1 + 19^1 + 27^1 + 33^1 + 34^1 + 50^1 + 51^1 + 56^1 = 285

Sum of Second Powers

1^2 + 6^2 + 7^2 + 23^2 + 24^2 + 30^2 + 38^2 + 47^2 + 54^2 + 55^2 = 11685

2^2 + 3^2 + 10^2 + 19^2 + 27^2 + 33^2 + 34^2 + 50^2 + 51^2 + 56^2 = 11685

Sum of Third Powers

1^3 + 6^3 + 7^3 + 23^3 + 24^3 + 30^3 + 38^3 + 47^3 + 54^3 + 55^3 = 536085

2^3 + 3^3 + 10^3 + 19^3 + 27^3 + 33^3 + 34^3 + 50^3 + 51^3 + 56^3 = 536085

Sum of Fourth Powers

1^4 + 6^4 + 7^4 + 23^4 + 24^4 + 30^4 + 38^4 + 47^4 + 54^4 + 55^4 = 26043813

2^4 + 3^4 + 10^4 + 19^4 + 27^4 + 33^4 + 34^4 + 50^4 + 51^4 + 56^4 = 26043813

Sum of Fifth Powers

1^5 + 6^5 + 7^5 + 23^5 + 24^5 + 30^5 + 38^5 + 47^5 + 54^5 + 55^5 = 1309753125

2^5 + 3^5 + 10^5 + 19^5 + 27^5 + 33^5 + 34^5 + 50^5 + 51^5 + 56^5 = 1309753125

Sum of Sixth Powers

1^6 + 6^6 + 7^6 + 23^6 + 24^6 + 30^6 + 38^6 + 47^6 + 54^6 + 55^6 = 67334006805

2^6 + 3^6 + 10^6 + 19^6 + 27^6 + 33^6 + 34^6 + 50^6 + 51^6 + 56^6 = 67334006805

Sum of Seventh Powers

1^7 + 6^7 + 7^7 + 23^7 + 24^7 + 30^7 + 38^7 + 47^7 + 54^7 + 55^7 = 3512261547765

2^7 + 3^7 + 10^7 + 19^7 + 27^7 + 33^7 + 34^7 + 50^7 + 51^7 + 56^7 = 3512261547765

Sum of Eighth Powers

1^8 + 6^8 + 7^8 + 23^8 + 24^8 + 30^8 + 38^8 + 47^8 + 54^8 + 55^8 = 185039471773893

2^8 + 3^8 + 10^8 + 19^8 + 27^8 + 33^8 + 34^8 + 50^8 + 51^8 + 56^8 = 185039471773893