Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Selected Statistics Examples from Lectures Matlab: Histograms >> y = [1 3 5 8 2 4 6 7 8 3 2 9 4 3 6 7 4 1 535896246156987534529 659416785429679253196 843679134752985745436 793169567321578531975 3 4 7 9 1]’; >> mean(y) ans = 5.1589 16 14 12 10 8 6 4 2 0 1 2 3 4 5 6 7 8 >> var(y) ans = 6.1726 >> std(y) ans = 2.4845 >> hist(y,9) histogram plot with 9 bins >> n = hist(y,9) store result in vector n >> x = [2 4 6 8]’ >> n = hist(y,x) create histogram with bin centers specified by vector x 35 30 25 20 15 10 5 0 2 4 6 8 9 Probability Examples Probability that at least one coin will turn heads up from five tossed coins » » » » Number of outcomes: 25 = 32 Probability of each outcome: 1/32 complement set Probability of no heads: P(AC) = 1/32 Probability at least one head: P(A) = 1-P(AC) = 31/32 Probability of getting an odd number or a number less than 4 from a single dice toss » » » » Probability of odd number: P(A) = 3/6 Probability of number less than 4: P(B) = 3/6 Probability of both: P( A B) 2 / 6 Probability of either: P( A B) P( A) P( B) P( A B) 3 / 6 3 / 6 2 / 6 2 / 3 Permutation Examples Process for manufacturing polymer thin films » Compute the probability that the first 6 films will be too thin and the next 4 films will be too thick if the thickness is a random variable with the mean equal to the desired thickness » n1 = 6, n2 = 4 » Probability 1 6!4! P 0.005 0.5% n! n1!n2 ! 10! Encryption cipher » Letters arranged in five-letter words: n = 26, k = 5 » Total number of different words: nk = 265 = 11,881,376 » Total number of different words containing each letter no n! 26! more than once: 7,893,600 (n k )! (26 5)! Combination Examples Effect of repetitions » Three letters a, b, c taken two at a time (n = 3, k = 2) » Combinations without repetition n 3 3! 3 ab ac bc k 2 2!(3 2)! » Combinations with repetitions ab ac bc n k 1 4 4! 6 aa bb cc k 2 2!(4 2)! 500 thin films taken 5 at a time » Combinations without repetitions n 500 500! 255,244,686,600 k 5 5!(500 5)! Matlab: Permutations and Combinations >> perms([2 4 6]) all possible permutations of 2, 4, 6 6 4 2 6 2 4 4 6 2 4 2 6 2 4 6 2 6 4 >> randperm(6) returns one possible permutation of 1-6 5 1 2 3 4 6 >> nchoosek(5,4) number of combinations of 5 things taken 4 at a time without repetitions ans = 5 >> nchoosek(2:2:10,4) all possible combinations of 2, 4, 6, 8, 10 taken 4 at a time without repetitions 2 4 6 8 2 4 6 10 2 4 8 10 2 6 8 10 4 6 8 10 Continuous Distribution Example Probability density function 0.75(1 x 2 ) 1 x 1 f ( x) 0 otherwise 1 f (v)dv 0.75(1 v 2 )dv 1 1 Cumulative distribution function x x 1 F ( x) f (v)dv 0.75(1 v 2 )dv 0.5 0.75 x 0.25 x 3 x 1 0 F ( x) 0.5 0.75 x 0.25 x 3 1 1 x 1 x 1 Probability of events P(0.5 x 0.5) F (0.5) F (0.5) 0.5 0.5 0.75(1 v 2 )dv 68.75% P( X x) F ( x) 0.95 0.5 0.75 x 0.25 x 3 x 0.73 Matlab: Normal Distribution Normal distribution: normpdf(x,mu,sigma) » normpdf(8,10,2) ans = 0.1210 » normpdf(9,10,2) ans = 0.1760 » normpdf(8,10,4) ans = 0.0880 Normal cumulative distribution: normcdf(x,mu,sigma) » normcdf(8,10,2) ans = 0.1587 » normcdf(12,10,2) ans = 0.8413 Inverse normal cumulative distribution: norminv(p,mu,sigma) » norminv([0.025 0.975],10,2) ans = 6.0801 13.9199 Random number from normal distribution: normrnd(mu,sigma,v) » normrnd(10,2,[1 5]) ans = 9.1349 10.2507 10.5754 7.7071 6.6688 Matlab: Normal Distribution Example The temperature of a bioreactor follows a normal distribution with an average temperature of 30oC and a standard deviation of 1oC. What percentage of the reactor operating time will the temperature be within +/-0.5oC of the average? Calculate probability at 29.5oC and 30.5oC, then calculate the difference: 0.4 » p=normcdf([29.5 30.5],30,1) p = [0.3085 0.6915] » p(2) – p(1) 0.3829 0.3 0.2 0.1 0 25 26 27 28 29 30 31 Temperature The reactor temperature will be within +/- 0.5oC of the average ~38% of the operating time 32 33 34 35 Discrete Distribution Example Matlab function: unicdf(x,n), >> x = (0:6); >> y = unidcdf(x,6); >> stairs(x,y) Poisson Distribution Example Probability of a defective thin polymer film p = 0.01 What is the probability of more than 2 defects in a lot of 100 samples? Binomial distribution: m = np = (100)(0.01) = 1 Since p <<1, can use Poisson distribution to approximate the solution. 2 2 P( X 2) F (2) f ( x j ) m xj e m e 1 10 0! x j! P( X 2) 1 P( X 2) 8.03% j 0 j 0 11 1! 12 2! 0.9197 Matlab: Maximum Likelihood In a chemical vapor deposition process to make a solar cell, there is an 87% probability that a sufficient amount of silicon will be deposited in each cell. Estimate the maximum likelihood of success in 5000 cells. s = binornd(n,p) – randomly generate the number of positive outcomes given n trials each with probability p of success » s = binornd(5000,0.87) s=4338 phat = binofit(s,n) – returns the maximum likelihood estimate given s successful outcomes in n trials » phat = binofit(s,5000) phat = 0.8676 Mean Confidence Interval Example Measurements of polymer molecular weight (scaled by 10-5) 1.25 1.36 1.22 1.19 1.33 1.12 1.27 1.27 1.31 1.26 Confidence interval 0.95 m 10 1 9 F (c) 0.975 c 2.26 x 1.26 s 2 0.0049 (2.26) 0.0049 k 0.050 CONF0.95 1.21 m 1.31 10 Variance Confidence Interval Example Measurements of polymer molecular weight (scaled by 10-5) 1.25 1.36 1.22 1.19 1.33 1.12 1.27 1.27 1.31 1.26 Confidence interval 0.95 m 9 F (c1 ) 0.025 c1 2.70 F (c2 ) 0.975 c2 19.02 (9)(0.0049) (9)(0.0049) s 0.0049 k1 0.0163 k 2 0.0023 2.70 19.02 2 CONF0.95 0.002 2 0.016 Matlab: Confidence Intervals >> [muhat,sigmahat,muci,sigmaci] = normfit(data,alpha) data: vector or matrix of data alpha: confidence level = 1-alpha muhat: estimated mean sigmahat: estimated standard deviation muci: confidence interval on the mean sigmaci: confidence interval on the standard deviation >> [muhat,sigmahat,muci,sigmaci] = normfit([1.25 1.36 1.22 1.19 1.33 1.12 1.27 1.27 1.31 1.26],0.05) muhat = 1.2580 sigmahat = 0.0697 muci = 1.2081 1.3079 sigmaci = 0.0480 0.1273 Mean Hypothesis Test Example Measurements of polymer molecular weight x 1.258 s 2 0.0049 Hypothesis: m0 = 1.3 instead of the alternative m1 < m0 Significance level: a = 0.10 Degrees of freedom: m = 9 Critical value P(T c~) m0 1 a 0.90 c~ 1.38 P(T c) m0 a 0.10 c c~ 1.38 Sample t 1.258 1.3 t 1.897 c 1.38 0.0049 10 Reject hypothesis Polymerization Reactor Control Monomers Catalysts Hydrogen Solvent Polymer On-line measurements Lab measurements Monomer Content Viscosity Lab measurements » Viscosity and monomer content of polymer every four hours » Three monomer content measurements: 23%, 18%, 22% Mean content control » Expected mean and known variance: m0 = 20%, 2 = 1 » Control limits: LCL m0 2.58 2 1 2 20 2.58 18.5% UCL m0 2.58 21.5% n 3 n » Sample mean: 21% process is in control Goodness of Fit Example Maximum likelihood estimates 1 n mˆ x j x 364.7 n j 1 1 n 2 ˆ ( x j x ) 2 712.9 n j 1 Goodness of Fit Example cont. Matlab: Goodness of Fit Example Find maximum likelihood estimates for µ and σ of a normal distribution with function mle >> data=[320 … 360]; >> phat = mle(data) phat = 364.7 26.7 Analyze dataset for goodness of fit using function chi2gof – usage: [h,p,stats]=chi2gof(x,’edges’,edges) for data in vector x divided into intervals with the specified edges » » » » If h = 1, reject hypothesis at 5% significance If h = 0, accept hypothesis at 5% significance p: probability of observing given statistic stats: includes chi-square statistic and degrees of freedom >> [h,p,stats]=chi2gof(data,’edges’,[-inf,325:10:405,inf]); >> h = 0 >> p = 0.8990 >> chi2stat = 2.8440 >> df = 7