Review of PROBABILITY DISTRIBUTIONS

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 1

Probability that a (continuous) random variable X is in (x,x+dx). PDF P(x < X < x + dx) 0.8 0.6 Probability density function (PDF). gamma distrib. P x < X < x + dx 0.4 f x = lim ( ) ( ) dx→+0 dx 0.2 X P x < X < x + dx ≈ f x dx 0 ( ) ( ) 0 2 4 6 Cumulative distribution function (CDF) CDF = Life time distribution. 1 x 0.8 F x = P X ≤ x = f s ds ( ) ( ) ∫ −∞ ( ) 0.6 Survival function 0.4 = Complementary CDF. 0.2 ∞ F x = P X > x = f s ds =1− F x 0 ( ) ( ) ∫ x ( ) ( ) 0 2 4 6

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 2 The fundamental theorem of calculus

The relation between probability distribution and probability density function.

x F x = f s ds ( ) ∫ −∞ ( )

d d " x % F x = f s ds = f x dx ( ) dx #$ ∫ −∞ ( ) &' ( )

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 3 Probability distribution: Example

Exponential distribution

−λx Probability density function (PDF). f (x) = λe

Cumulative distribution function (CDF). F (x) = P(X ≤ x) =1− e−λx Survival function. F (x) = P(X > x) =1− F (x) = e−λx 1.0

0.8

0.6

0.4

0.2

1 2 3 4 5

! # −1 ! # −2 Expectation E"X $ = λ var"X $ = λ

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 4 Samples from a distribution

PDF 0.8

0.6 gamma distrib. 0.4 f x X ( ) 0.2 If a random variable X follows a cdf FX, X then the r.v. U given by 0 0 2 4 6 X U = F X = f s ds X ( ) ∫ −∞ X ( ) CDF 1 follows an uniform distribution in [0,1]. U 0.8 FX x 0.6 ( )

0.4

0.2

0 0 2 X 4 6

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 5 Homework 1-1

Problem Confirm that U F X follows an uniform distribution in [0,1]. = X ( ) x when X is a random variable from F x = f s ds X ( ) ∫ 0 X ( )

Hint f x Suppose a random variable (r.v.) X given by a pdf X ( ) Consider a r.v. Y that is transformed from X using a monotonic function g. Y = g (X ) dx −1 The distribution of Y is given as f y = f x = f x g! x Y ( ) X ( ) dy X ( ) ( ) x Consider a particular relation given by CDF, g x = F x = f s ds ( ) X ( ) ∫ −∞ X ( )

−1 −1 f y f x g x f x f x 1 Then we obtain Y ( ) = X ( ) !( ) = X ( ) X ( ) =

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 6 Samples from a distribution

Inverse function method CDF 1 Let U be an uniform r.v.. 0.8 X 0.6 X that satisfiesU = f s ds follows the density f x . 0.4 ∫ −∞ X ( ) X ( ) 0.2 −1 The r.v. X = F U follows the CDF given by F. 0 ( ) 0 2 4 6

f x e−λx : X ( ) = λ

X U = F X = λe−λs ds =1− e−λX X ( ) ∫ −∞ A r.v. that follows an exponential distribution with rate λ is generated using an uniform r.v. X as X F −1 U −1 log U = X ( ) = −λ ( )

Memo: The distribution that can be inverted analytically is limited, e.g., Exp., Weibull, Pareto, etc. For other distributions, one can numerically compute CDF to obtain X.

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 7 Introduction to

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 8 Memoryless process

A point process is memoryless if intervals X satisfy P(X > s + t | X > t) = P(X > s)

Question. s Event Suppose that you bought a refrigerator t years ago. It still works well. How long will it continue to work from now? 0 t t + s X

Answer. We wish to know the probability that the refrigerator survives another s years given that it survived t years. This is given as P(X > s + t | X > t). From the memoryless property, it is equivalent to P(X > s). Thus, the fact that the refrigerator survived t years did not provide any information to predict a failure of the refrigerator in future.

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 9 Exponential distribution

Q. What distribution possesses the memoryless property?

Ans. The exponential distribution: f (x) = λe−λx

The survival function can be written in a conditional form as P(X > s + t) = P(X > s + t | X > t) P(X > t) Using the memoryless property, we obtain P(X > s + t) = P(X > s) P(X > t) The exponential distribution satisfies the memoryless property. If P ( X > x ) = e − λ x , then P(X > s) P(X > t) = e−λse−λt = e−λ(s+t) = P X > s + t d ( ) Density is given as f x = − P X > x = λe−λx ( ) dx ( ) Poisson point process

If intervals of events are samples from the exponential distribution, and the intervals are independent each other, then the process is memoryless.

This process is called a (homogeneous) Poisson point process.

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 11 Simulating a Poisson process

Question. How can we simulate a Poisson point process?

Ans. Use the inverse function method to generate an inter-spike interval (ISIs) that follows an exponential distribution.

1.0

0.8

0.6

0.4 −1 ISI X = −λ logU 0.2

1 2 3 4 5

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 12 The Let’s consider a distribution of the number of spikes that occurred in T[s].

NT : the number of spikes that happens in T [s]

1 2 3 NT -th spike

T

A count distribution of a Poisson point process is given by a Poisson

distribution. Ê Ê 0.35

0.30

n 0.25 λT ( ) −λT 0.20 Ê P N n e ‡ ‡ ( T = ) = 0.15 n! ‡ ‡ Ï Ï Ï Ï ‡ 0.10 Ï Ï ‡ Ï Ê Ï ‡ 0.05 Ï ‡ Ï ‡ Ï Ï ‡ Ï Ê ‡ Ï Ï‡ Ï Ï Ï Ê Ê Ê Ê Ê Ê Ê Ê‡ ʇ ʇ ʇ ʇ ʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ Ïʇ 5 10 15 20 25 30

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 13 Homework 1-2

Problem Derive the Poisson distribution for the first few spike counts, NT = 0,1,2.

Hint If there is no spike in T, then the first spike occurred after T. This is given by survival function of an N 0 X1 T = exponential distribution. P N 0 P X T F T ( T = ) = ( 1 > ) = ( ) T

X2 Let the first spike occurred at s_1, the first ISI follows an exponential density, the second ISI NT =1 should be greater than T-s_1.

T s1 T P N =1 = f s F T − s ds ( T ) ∫ 0 ( 1) ( 1) 1

NT = 2 X3 Similarly if you have two spikes in T,

T T P N = 2 = f s f s − s F T − s ds ds ( T ) ∫ 0 ∫ s ( 1) ( 2 1) ( 2 ) 1 2 s1 s2 T 1

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 14 The distribution Let’s consider a distribution of a waiting time τ until spikes occurred n times.

1 2 3 n-th spike

τ

Waiting time of multiple spikes from a Poisson process is given by an Erlang distribution.

0.4

0.3 n n−1 λ τ −λτ P(τ < X < τ + dτ ) = e dτ 0.2 (n −1)! 0.1

2 4 6 8 10 12 14

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 15 Spike count and ISI The relation between a Poisson and Erlang distribution.

1 2 3 n-1 n

Nτ spikes τ Sn

If S n > τ , the number of spikes in is at most n-1. P N < n = P S > τ ( τ ) ( n )

Rhs is a survival function of an Erlang distribution.

n−1 k ∞ n n−1 −λt (λτ ) −λτ P(Sn > τ ) = λ t e dt = e ∫τ ∑ k! k=0 n (λτ ) −λτ P(Nτ = n) = P(Nτ < n +1) − P(Nτ < n) = e n!

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 16 Instantaneous spike rate

Alternative definition of a Poisson point process

Divide T into small N bins of a small width Δ (T=NΔ). Spike

t t + Δ Δ Instantaneous spike rate P(a spike in [t,t + Δ)) = λΔ + o(Δ) P(>1 spikes in [t,t + Δ)) = o(Δ) P(no spikes in [t,t + Δ)) =1− λΔ + o(Δ) o(Δ) o(Δ) is a function that approaches to zero faster than Δ : lim = 0 Δ→+0 Δ

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 17 Relation to the Poisson distribution

The probability of a spike/no spike is an approximation of the Poisson distribution for a small time bin. The spike count in a small bin is approximated as n n λΔ λΔ # 1 2 & P N = n = ( ) e−λΔ = ( ) 1− λΔ + λΔ + ( Δ ) % ( ) ( n! n! $ 2 ' In particular, # 1 2 & P N = 0 =1 1− λΔ + λΔ + =1− λΔ + o Δ ( Δ ) % ( ) ( ( ) $ 2 ' # 1 2 & P N =1 = λΔ 1− λΔ + λΔ + = λΔ + o Δ ( Δ ) % ( ) ( ( ) $ 2 ' 2 # 1 2 & P N = 2 = λΔ 1− λΔ + λΔ + = o Δ ( Δ ) ( ) % ( ) ( ( ) $ 2 '

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 18 Exponential / Poisson distribution revisited

The exponential distribution from an instantaneous spike rate.

The probability that no spikes happened in N-1 bins and a spike happened in the last bin (). (x=NΔ)

N−1 P(x < X < x + Δ) = (1− λΔ) λΔ + o(Δ)

P(x < X < x + Δ) −λx ISI distribution: f (x) = lim = λe Δ→0 Δ

The Poisson distribution from an instantaneous spike rate.

The probability that n spikes happened in N bins (T=NΔ).

! $ n N N−n n (λT) −λT P(NT = n) = # &(1− λΔ) (λΔ) → e as Δ → 0 " n % n!

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 19 Exponential distribution revisited

We can derive the exponential distribution from an instantaneous spike rate, λ [spike/sec]

Divide T into small N bins of a width Δ. N bins Probability a spike in a bin: λΔ Δ Spike >2 spikes in a bin: o(Δ) no spikes in a bin: 1− λΔ + o(Δ) T = NΔ

The probability that no spikes happened in N-1 bins and a spike happened in the last bin.

N−1 P(x < T < x + Δ) = (1− λΔ) λΔ + o(Δ)

P(x < T < x + Δ) −λx ISI distribution: f (x) = lim = λe Δ→0 Δ

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 20 Poisson distribution revisted

We can derive the Poisson distribution from an instantaneous spike rate, λ [spike/sec]

Divide T into small N bins of a width Δ. N bins Probability a spike in a bin: λΔ Δ Spike >2 spikes in a bin: o(Δ) no spikes in a bin: 1− λΔ + o(Δ) T = NΔ

The probability that n spikes happened in T [s].

! $ n N N−n n (λT) −λT P(NT = n) = # &(1− λΔ) (λΔ) → e as Δ → 0 " n % n!

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 21 Homework 1-3

Problem The probability that no spikes happened in N-1 bins and a spike happened in the last bin is given as

N−1 λΔ N P(x < X < x + Δ) = (1− λΔ) λΔ + o(Δ) = (1− λΔ) + o(Δ) 1− λΔ Show that the ISI distribution becomes an exponential distribution.

Hint Approximate the terms by the Taylor expansions. 1 2 1 3 1 2 3 log(1− x) = −x − x − x  =1+ x + x + x  2 3 1− x N (1− λΔ) = exp$#N log(1− λΔ)&% λΔ 2 = λΔ 1+ λΔ +(λΔ) + # ' 1 2 *% 1− λΔ { } = exp-N (−λΔ − (λΔ) −+. $ ) 2 ,& = λΔ + o(Δ) / 1 2 = e−λx 11− λ 2 xΔ +4 0 2 3 Hence we obtain P(x < X < x + Δ) −λx P x < X < x + Δ = λΔexp −λx + o Δ , and f (x) = lim = λe ( ) [ ] ( ) Δ→0 Δ

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 22 Homework 1-4

Problem Probability that n spikes occur in N bins (T [s]) is given as

! N $ n N−n P(NT = n) = # &(λΔ) (1− λΔ) " n % Show that the probability becomes the Poisson distribution for large N and small Δ with a relation given by a constant T=NΔ.

Hint Using an approximation given by the Taylor expansions (See previous slides). n N! # λΔ & N N! n P(NT = n) = % ( (1− λΔ) ≈ (λΔ) exp[−λΔN] (N − n)!n!$1− λΔ ' (N − n)!n! Use the relation, T=NΔ, to obtain

N! 1 n P(NT = n) = n (λT) exp[−λT ] (N − n)!N n! Use the Stirling’s formula ln N! ~ N ln N − N N! " n % " n %N and prove that ln = $1− 'ln$1− ' − n =1⋅ lne−n − n → 0 (N − n)!N n # N & # N &

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 23 Likelihood function

t t t Likelihood function 1 2 n

0 T

n p(t1,t2,…,tn ∩ NT = n) = λ exp[−λT ]

Proof n p(t1,t2,…,tn ∩ NT = n)Δ n

= f (t1)Δ∏ f (ti − ti−1)Δ ⋅ P(tn+1 > T | tn ) i=2 n & ( & ( = λ exp(−λt1)Δ∏λ exp'−λ (ti − ti−1))Δ ⋅ exp'−λ (T − tn )) i=2 = λ nΔexp[−λT ] Here the ISI distribution is f (x) = λ exp[−λx]

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 24 INHOMOGENEOUS POISSON PROCESS

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 25 Inhomogeneous Poisson process

Instantaneous rate λ (t)

Point process

t t +Δ

P(a spike in [t,t + Δ)) = λ (t)Δ + o(Δ) Time-dependent rate

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 26 Inhomogeneous Poisson process

Instantaneous rate λ (t)

Point process

ti−1 ti

t # & f (t | ti−1) = λ (t)exp − λ (u)du for t > ti−1 $% ∫ ti−1 '(

Note that the above formula extends the exponential ISI of homogeneous Poisson process.

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 27 Homework 1-5

Problem Derive the ISI density of the inhomogeneous Poisson process.

Hint Let the last spike occurred at time 0. The probability of a spike occurrence in [t, t+Δ) is given as N−1 P( t < X < t + Δ) = ∏$#1− λ (kΔ)Δ&%⋅$#λ (NΔ)Δ&%+ o(Δ) k=1 λ (NΔ)Δ N = ⋅∏$#1− λ (kΔ)Δ&%+ o(Δ) 1− λ (NΔ)Δ k=1 Using the following approximation, N # N % # N % ∏$#1− λ (kΔ)Δ&% = exp)∑log{1− λ (kΔ)Δ}* = exp)∑{−λ (kΔ)Δ + o(Δ)}* k=1 $ k=1 & $ k=1 & λ (NΔ)Δ = λ (NΔ)Δ + o(Δ) 1− λ (NΔ)Δ P(t < X < t + Δ) % t ( The ISI density is given as f (t) = lim = λ (t)exp − λ (u)du Δ→0 Δ &' ∫ 0 )*

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 28 Likelihood function

t Likelihood function λ ( )

0 T t t1 t2 n n T p t ,t ,…,t ∩ N = n = λ t exp%− λ u du( ( 1 2 n T ) ∏ ( i ) &' ∫ 0 ( ) )* i=1

n Proof n p(t1,t2,…,tn ∩ NT = n)Δ = f (t1)Δ∏ f (ti | ti−1)Δ ⋅ P(tn+1 > T | tn ) i=2 n T = λ t Δexp'− λ u du* ∏ ( i ) () ∫ 0 ( ) +, i=1

# ti & Here the ISI distribution is given as f (ti | ti−1) = λ (ti )exp − λ (u)du $% ∫ ti−1 '(

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 29 What we learned

• Memoryless property of a process. 1

• Exponential distribution = Poisson process. 2

• Poisson count distribution, Waiting time distribution (Erlang). 3

• Definition of a Poisson process using instantaneous firing rate. 4

• Exponential and a Poisson count distribution revisited. 5

• Inhomogeneous Poisson process: ISI distribution and likelihood 6

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 30 Tomorrow, we will learn

• Renewal process: Conditional intensity function and ISI density. 1

• non-Poisson process (Point process written by the conditional intensity 2 function)

• Time-rescaling theorem 3

• How to simulate a point process via the time-rescaling theorem. 4

• How to assess a point process model via the time-rescaling theorem. 5 (Q-Q plot and K-S test)

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 31 Follow-up from the lecture feedback

Stimulus signal x(t) Tomorrow’s topic.

Instantaneous spike-rate λ (t) Today’s topic.

Point process

t t +Δ P(a spike in [t,t + Δ)) = λ (t)Δ + o(Δ)

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 32 Likelihood function

−λx Density function f (x) = λe An observed sample X

−λX Likelihood function L(λ) = f (X) = λe

Multiple observation X1, X2,, Xn n Likelihood function L(λ) = ∏ p(Xi | λ) i=1

Maximum likelihood estimation (MLE) n λMLE = argmax∏ p(Xi | λ) λ i=1

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 33 Likelihood of a Poisson process

Likelihood function of a homogeneous Poisson process Inter-spike Intervals (ISIs)

p(t1,t2,…,tn ∩ NT = n | λ) = p(t1,t2 − t1,…,tn − tn−1 ∩ NT = n) n

= ∏ f (ti − ti−1;λ)⋅ F (T − tn;λ) −λ(ti −ti−1) i=1 f (ti − ti−1) = λe = λ n exp[−λT ]

Likelihood function of a inhomogeneous Poisson process

p(t1,t2,…,tn ∩ NT = n | λ0:T ) = p(t1,t2 − t1,…,tn − tn−1 ∩ NT = n) n = f t − t ;λ ⋅ F T − t ;λ ∏ ( i i−1 ti:ti−1 ) ( i tn:T ) # ti & i=1 f (ti − ti−1) = λ (ti )exp − λ (u)du $% ∫ ti−1 '( n T = λ t exp&− λ u du) ∏ ( i ) '( ∫ 0 ( ) *+ i=1

Hideaki Shimazaki, Ph.D. http://goo.gl/viSNG Poisson process 34