Info 2950, Lecture 7 16 Feb 2017 Prob Set 2: due Fri night 24 Feb The registrar has designated the final exam date/time for this course as Sun, 21 May 2017, 2:00-4:30pm
Suppose that q = m / 132 prefer 23 Mar. We re random sampling 45 people, each a Bernoulli trial with probability q of success What statistical variation would we expect for N=45? X Estimate q = 36/45 = 4/5, then variance of a trial is (1/5)(4/5), and p V = Nq(1-q) = 45 * (1/5) (4/5) = 36 / 5, so that = V [X] = 2.68 so result for mean Nq is accurate to roughly 36 +/- 2.65, (or as a percentage q =.8 +/-.06 = 80% +/- 6% )
https://xkcd.com/882/ ( p-hacking )
Example: Suppose a software program has a bug that occurs with probability p =1/1000 a) How many times do we need to run the program in order to have a 50% chance of seeing the bug occur? b) What is the probability of seeing the bug if we run the program 1000 times?
Telegraphic review of exponentials and logarithms: Multiplying m factors of x gives x m, which satisfies x m x n = x m+n, (x n ) m = x nm, x 0 =1 Exponential function: f(x) =y x is frequently used with y =e,wheree=2.71828182845905... is a transcendental number The function with base e also has a special name: exp(x) =e x
One definition of e: Invest $1 at a 100%/year interest rate for a year Compound interest once at end of year: $1 (1 + 1) = $2 If compounded twice, 50% after a half year, 50% at the end of the year: $1 (1 + 1/2)(1 + 1/2) = $2.25 Break year into N pieces, compound interest N times: (1 + 1/N ) N In the large N limit (compounded continuously), the result converges to lim (1 + 1/N N!1 )N =e.
Interest rate of 5% per year compounded continuously: lim N!1 (1 +.05/N ) N =lim M!1 (1 + 1/M ).05M =e.05 1.051271096. For general interest rate x, letn = Mx: lim N!1 (1 + x/n ) N =lim M!1 (1 + 1/M ) Mx =e x. e x can also be written as an infinite sum. Expand product, keep only terms that survive large N limit: e x = lim 1+ x N = lim 1+N x N!1 N N!1 N + N(N 1) 2! x N 2 + + N m x N m + =1+x + x2 2! + x3 3! + + xm m! + = 1 X n=0 x n n!
The logarithm function is the inverse of the exponential function: if y x = X then x = log y X For example: 10 3 = 1000 so log 10 1000 = 3 2 10 = 1024 so log 2 1024 = 10 [Note: the rough relation 10 3 2 10 implies that 10 3/10 2 and 2 10/3 10, giving estimates log 10 2 3/10 and log 2 10 10/3 (actual values: 0.30103... and 3.32192...)]
Useful properties of the logarithm function follow directly from corresponding properties x m x n = x m+n, (x n ) m = x nm, x 0 =1of the exponential function: log XZ = log X + log Z, log X s = s log X, log 1 = 0 (For example if X = y x and Z = y z, then log y XZ = log y y x y z = log y y x+z = x + z = log y X + log y Z and log X s = log y y xs = xs = s log y X
Logarithms to di erent bases y, z are simply related by a numerical factor log z y: log y x = log z x log z y (following from log z x = log z y log y x = log y x log z y). The special notation ln = log e is used for logarithms to the base e: for example: ln 2 = log e 2.693. For the leading behavior, recall e t 1 t for small t, soln(1 t) t
The series expansion for the function ln(1 + t) =a 1 t + a 2 t 2 + a 3 t 3 + can be determined by setting e x =1+t (defined so that t is small when x is small) and substituting in e x = P 1 n=0 xn n! : 1+t =1+(a 1 t+a 2 t 2 +a 3 t 3 + )+ 1 2 (a 1t+a 2 t 2 +a 3 t 3 + ) 2 + 1 3! (a 1t+a 2 t 2 +a 3 t 3 + ) 3 +. Comparing the coe cients of powers of t gives: a 1 = 1, a 2 + a 2 1/2 = 0, a 3 +2a 1 a 2 /2+a 3 1/6 = 0,... and thus a 2 = 1/2, a 3 =1/2 1/6 =1/3, i.e., ln(1 + t) =t t 2 /2+t 3 /3 Letting t! t, the full result can be written in the form ln(1 t) = t t 2 2 t 3 3 = 1X n=1 t n n
Example: Suppose a software program has a bug that occurs with probability p =1/1000 a) How many times do we need to run the program in order to have a 50% chance of seeing the bug occur? b) What is the probability of seeing the bug if we run the program 1000 times?
Example: Suppose a software program has a bug that occurs with probability p =1/1000. a) probability of not seeing the problem occur in a single run is P 1 =1 p assuming successive runs independent, probability of seeing no problem after N runs is P N =(1 p) N For (1 p) N =1/2, we find N ln(1 p) =ln(1/2) Plug into calculator, or use ln(1 p) p for small p: Np ln 2, so N (1/p) ln 2 = 1000 ln 2 693 so after N = 693 trials the probability of no problem falls to roughly 50%.
Example: Suppose a software program has a bug that occurs with probability p =1/1000 b) probability of not seeing bug in 1000 runs is P 1000 =(1 1 1000 )1000 1000 is large so this is approximated by P 1000 e 1.368 [Equivalently, using log(1 t) t, we can estimate ln P 1000 = 1000 ln(1 1 1000 ) 1000( 1 1000 )= 1, so again P 1000 e 1 ] The probability of seeing the bug is therefore 1 P 1000.632, i.e., has climbed to roughly 63.2% after 1000 trials. [Note that this also the probability that someone in a group of 365 other people has a birthday coincident with yours: (1 1 365 )365 e 1 is no coincidence, so also 1 1/e.632]
plt.figure(figsize(8,6)) N=arange(5001.) (5000,.993) plt.plot(1-exp(-n/1000),'r') points = array([693,1000,5000]) plt.plot(points,1-exp(-points/1000.),'o') plt.xticks(range(0,5001,500)) plt.yticks(arange(.1,1.1,.1)) (1000,.632) plt.grid('on') plt.savefig('eprob.pdf') (693,.5) probability of seeing a problem, given by 1 (999/1000) N 1 e N/1000.
This problem of the probability of seeing some event in N trials is directly analogous to the problem of nuclear decay, where p is instead the probability per unit time of decay of some nuclear species. (In the original problem, p was a probability per trial, so a trial becomes an infinitesimal time step in the nuclear problem.) The half-life, i.e., the time for half of some sample to be likely to decay, is given by the equivalent formula t 1/2 =(1/p)ln2, and the fraction remaining (not subject to the event ) at time t is given by e pt =e ln 2(t/t 1/2)