The Lazy Apprentice

 Follow @ProbabilityPuz Q: A shopkeeper hires an apprentice for his store which gets one customer per minute on average uniformly randomly. The apprentice is expected to leave the shop open until at least 6 minutes have passed when no customer arrives. The shop keeper suspects that the apprentice is lazy and wants to close the shop at a shorter notice. The apprentice claims (and the shopkeeper verifies), that the shop is open for about 2.5hrs on average. How could the shopkeeper back his claim?

Statistics: A good book to learn statistics A: Per the contract, at least 6 minutes should pass without a single customer showing up before the apprentice can close the shop. To solve this lets tackle a different problem first. Assume you have a biased coin with a probability $$p$$ of landing heads. What is the expected number of tosses before you get $$n$$ heads in a row. The expected number of tosses to get to the first head is simple enough to calculate, its $$\frac{1}{p}$$. How about two heads? We can formulate this recursively. We need to get to a head first. Following this, you need to toss the coin one more time for sure. With a probability $$p$$ you get the second heads or with a probability $$1 - p$$ you have to start over again. The number of tosses to two heads is thus $$\frac{1}{p} + 1 + \frac{1}{p}\times(1-p)$$.

Extending this out to get $$n$$ tosses, if you assume that $$y(n)$$ is the expected number of tosses to get to $$n$$ heads in a row then the following state transition diagram shows how the transitions happen.

From the state $$y_{n-1}$$, with probability $$1- p$$ you start over again. Stated recursively
$$y_{n} = y_{n-1} + 1 + (1-p)y_{n}\\ py_{n} = y_{n-1} + 1$$
Using the above expression, it is easy to derive the general expression for $$y_{n}$$ as follows, keeping in mind $$y_{0} = 0$$
$$y_{1} = \frac{y_{0}}{p} + \frac{1}{p} = \frac{1}{p}\\ y_{2} = \frac{1}{p}(y_{1} + 1) = \frac{1}{p^{2}} + \frac{1}{p} y_{3} = \frac{1}{p}(y_{2} + 1) = \frac{1}{p^{3}} + \frac{1}{p^{2}} + \frac{1}{p}$$
Being a sum of a geometric series, the $$y_{n}$$ can be evaluated to
$$y_{n} = \frac{1}{1-p}\big(\frac{1}{p^{n}} - 1\big)$$
Now, back to the original question. Assume the apprentice waits $$k$$ minutes before no customer shows up and he chooses to shut the shop. The situation is "similar" to the coin tossing and awaiting for a string of heads. (Note: Strictly speaking, it's similar only in the limiting case when the time interval is very small). In this case each "head" signifies the absence of a customer showing up in a minute. As the customers arrive uniformly at random we can assume they follow a Poisson process. The probability that $$m$$ customers arrive in a one minute window if the rate parameter is $$\lambda$$ (in this case $$\lambda = 1min^{-1}$$) is

$$P(m,\lambda) = \frac{(\lambda)^{m}e^{-\lambda}}{m!}$$

When $$m =0$$ we get $$p = e^{-\lambda}$$. Plugging this value back to our equation for $$y_{n}$$ we get
$$y_{n} = \frac{1}{1 - e^{-\lambda}}\big(e^{k\lambda} - 1\big)$$
for small $$\lambda$$ the denominator of the first part of the equation can be approximated as $$\frac{1}{\lambda}$$ yielding
$$y_{n} = \frac{1}{\lambda}\big(e^{k\lambda} - 1\big)$$

Note, if you plug $$k=6$$ into the above equation you get $$\approx 7$$ hours whereas for $$k=5$$ you get $$\approx 2.5$$ hours. Due to the exponential connection between $$y_{n}$$ and $$k$$ the values for $$y_{n}$$ are super sensitive to changes in $$k$$.

If you are looking to buy some books in probability here are some of the best books to learn the art of Probability

The Best Books to Learn Probability

If you are looking to buy some books in probability here are some of the best books to learn the art of Probability

The Probability Tutoring Book: An Intuitive Course for Engineers and Scientists (and Everyone Else!)
A good book for graduate level classes: has some practice problems in them which is a good thing. But that doesn't make this book any less of buy for the beginner.

An Introduction to Probability Theory and Its Applications, Vol. 1, 3rd Edition
This is a two volume book and the first volume is what will likely interest a beginner because it covers discrete probability. The book tends to treat probability as a theory on its own

Discovering Statistics Using R
This is a good book if you are new to statistics & probability while simultaneously getting started with a programming language. The book supports R and is written in a casual humorous way making it an easy read. Great for beginners. Some of the data on the companion website could be missing.

Fifty Challenging Probl…

The Best Books for Time Series Analysis

If you are looking to learn time series analysis, the following are some of the best books in time series analysis.

Introductory Time Series with R (Use R!)
This is good book to get one started on time series. A nice aspect of this book is that it has examples in R and some of the data is part of standard R packages which makes good introductory material for learning the R language too. That said this is not exactly a graduate level book, and some of the data links in the book may not be valid.

Econometrics
A great book if you are in an economics stream or want to get into it. The nice thing in the book is it tries to bring out a oneness in all the methods used. Econ majors need to be up-to speed on the grounding mathematics for time series analysis to use this book. Outside of those prerequisites, this is one of the best books on econometrics and time series analysis.

Pattern Recognition and Machine Learning (Information Science and Statistics)
This is excelle…

The Best Books for Linear Algebra

The following are some good books to own in the area of Linear Algebra.

Linear Algebra (2nd Edition)
This is the gold standard for linear algebra at an undergraduate level. This book has been around for quite sometime a great book to own.

Linear Algebra: A Modern Introduction
Good book if you want to learn more on the subject of linear algebra however typos in the text could be a problem.

Linear Algebra (Dover Books on Mathematics)
An excellent book to own if you are looking to get into, or want to understand linear algebra. Please keep in mind that you need to have some basic mathematical background before you can use this book.

Linear Algebra Done Right (Undergraduate Texts in Mathematics)
A great book that exposes the method of proof as it used in Linear Algebra. This book is not for the beginner though. You do need some prior knowledge of the basics at least. It would be a good add-on to an existing course you are doing in Linear Algebra.

Linear Algebra, 4th Edition
This is good book …