***************************************************************************** * CHAPTER 5 - STATISTICS FOR BUSINESS AND ECONOMICS, 5th Edition * ***************************************************************************** * Example 5.1, p. 132 * * Read this example carefully. Be sure you understand the methodology. * *---------------------------------------------------------------------------- * Example 5.2, p. 134 * * Read this example carefully. Be sure you understand the methodology. * *---------------------------------------------------------------------------- * Example 5.3, p. 135 * GEN1 P0=0.81 GEN1 P1=0.17 GEN1 P2=0.02 GEN1 MEAN=(0*P0)+(1*P1)+(2*P2) PRINT MEAN * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.4, p. 137 * SAMPLE 1 6 READ SALES PX MEAN 0 0.15 0.15 1 0.30 0.45 2 0.20 0.65 3 0.20 0.85 4 0.10 0.95 5 0.05 1.00 * * Calculate the Expected Value using Equation 5.4 * GENR M=(SALES*PX) * * The SUM(x) function creates a cumulative sum of the variable x. * GEN1 EV=SUM(M,6) PRINT EV * * Calculate the Variance using Equation 5.6 * GENR V=((SALES-EV)**2)*PX GEN1 VAR=SUM(V,6) PRINT VAR * * Replicate Table 5.1 * PRINT SALES PX MEAN V PRINT EV VAR * DELETE / ALL * *---------------------------------------------------------------------------- * Table 5.2 Data, p. 138 * SAMPLE 1 6 READ SALES PX MEAN 0 0.30 0.00 1 0.20 0.20 2 0.10 0.20 3 0.05 0.15 4 0.15 0.60 5 0.20 1.00 * GENR M=SALES*PX * * The SUM(x) function creates a cumulative sum of the variable x. * GEN1 EV=SUM(M,6) PRINT EV * * Calculate the Variance using Equation 5.6 * GENR V=((SALES-EV)**2)*PX GEN1 VAR=SUM(V,6) PRINT VAR * * Replicate Table 5.2 * PRINT SALES PX MEAN V PRINT EV VAR * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.5, p. 141 * SAMPLE 1 5 READ X P 10 0.10 11 0.30 12 0.30 13 0.20 14 0.10 * * Mean for completion time X * GENR E=X*P GEN1 MEANX=SUM(E,5) PRINT MEANX * * Variance for completion time X * GENR V=((X-MEANX)**2)*P GEN1 VARX=SUM(V,5) PRINT VARX * * Mean for Total Cost C is MEANC. Variance for Total Cost C is VARC. * Standard Deviation STD. * GEN1 MEANC=25000+900*MEANX GEN1 VARC=(900**2)*VARX GEN1 STD=SQRT(VARC) PRINT MEANC VARC STD * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.6, p. 145 * GEN1 P0=0.60 GEN1 P1=0.40 GEN1 MEAN=0.40 GEN1 VAR=MEAN*(1-MEAN) PRINT VAR * *---------------------------------------------------------------------------- * Example 5.7, p. 147 * * The DISTRIB command can provide critical values. In this example, the * Probability Density Functions, PDF, are required. The format of the * DISTRIB command is: * * DISTRIB vars / options * * where: vars = list of variables * options = list of options * * Case A - Probability of at Most One Sale. * * In this example the TYPE=BINOMIAL option is used with required options * N= and P=. * GEN1 X=0 DISTRIB X / TYPE=BINOMIAL N=5 P=0.40 GEN1 PDF0=$PDF GEN1 X=1 DISTRIB X / TYPE=BINOMIAL N=5 P=0.40 GEN1 P0=PDF0+$PDF PRINT P0 * * Case B - Between Two and Four Sales. * * For this example, the DO-loop is used to calculate the PDF for between two * and 4 sales (inclusive). The format of the DO-loop is: * * DO dovar=start,stop,inc * commands * ... * ENDO * * where: DO, ENDO = commands are repeatedly executed * dovar = loop variable and must be a #, %, ! or ? symbol DO #=2,4 GEN1 X#=# DISTRIB X# / TYPE=BINOMIAL N=5 P=0.40 GEN1 PDF#=$PDF ENDO GEN1 P24=PDF2+PDF3+PDF4 PRINT P24 * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.8, p. 148 * * The TYPE=BINOMIAL on the DISTRIB command is used for this example. * * Case A - At Most Six Students Will Enroll. * GEN1 X=6 DISTRIB X / TYPE=BINOMIAL N=10 P=0.40 PRINT $CDF * * Case B - More Than Twelve Students Will Actually Enroll. * GEN1 X=12 DISTRIB X / TYPE=BINOMIAL N=20 P=0.40 GEN1 P12=1-$CDF PRINT P12 * * Case C - If 70% Of Those Students Admitted Actually Enrolled. * GEN1 X=3 DISTRIB X / TYPE=BINOMIAL N=15 P=0.30 PRINT $CDF * *---------------------------------------------------------------------------- * Example 5.9, p. 149 * * Case A - Between 37 and 43 (Inclusive) Claims * * For this example, the DO-loop is used to calculate the PDF for each of * the claims between 37 and 43. * DO #=37,43 GEN1 X#=# DISTRIB X# / TYPE=BINOMIAL N=100 P=0.40 * * The GEN1 command is used to save the temporary $PDF from each claim on * the DISTRIB command into the scalar PDF#. * GEN1 PDF#=$PDF PRINT PDF# ENDO * * Once all of the PDFs are calculated, the GEN1 is used to calculate P. * GEN1 P=PDF37+PDF38+PDF39+PDF40+PDF41+PDF42+PDF43 PRINT P * * Case B - At Most 38 Claims * GEN1 X=38 DISTRIB X / TYPE=BINOMIAL N=100 P=0.40 PRINT $CDF * * Case C - More than 42 Claims * GEN1 X=42 DISTRIB X / TYPE=BINOMIAL N=100 P=0.40 GEN1 P42=1-$CDF PRINT P42 * *---------------------------------------------------------------------------- * Example 5.10, p. 150 * * Case A * GEN1 X=16 DISTRIB X / TYPE=BINOMIAL N=20 P=0.80 GEN1 P16=1-$CDF PRINT P16 GEN1 X=15 DISTRIB X / TYPE=BINOMIAL N=20 P=0.80 PRINT $CDF * * Case B * GEN1 X=16 DISTRIB X / TYPE=BINOMIAL N=18 P=0.80 GEN1 X=15 DISTRIB X / TYPE=BINOMIAL N=18 P=0.80 PRINT $CDF * *---------------------------------------------------------------------------- * Example 5.11, p. 154 * * The TYPE=HYPERGEO is used for this example on the DISTRIB command. * * Probability of No Defectives in Sample. * GEN1 X=0 DISTRIB X / TYPE=HYPERGEO BIGN=20 N=6 BIGX=5 GEN1 PDF0=$PDF PRINT PDF0 * * Probability of One Defective in Sample. * GEN1 X=1 DISTRIB X / TYPE=HYPERGEO BIGN=20 N=6 BIGX=5 PRINT $PDF * * Probability that the Shipment of Twenty Items Containing Five Defectives * is defined as P with the GEN1 command. * GEN1 P=PDF0+$PDF PRINT P * *---------------------------------------------------------------------------- * Example 5.12, p. 157 * * Case A - No Failures in a Given Day * GEN1 X=0 DISTRIB X / TYPE=POISSON MEAN=0.03 PRINT $CDF * * Case B - At Least One Component Failure * GEN1 X=0 DISTRIB X / TYPE=POISSON MEAN=0.03 GEN1 CDF0=1-$CDF PRINT CDF0 * * Case C - At Least Two Failures in a Three Day Period * GEN1 X=0 DISTRIB X / TYPE=POISSON MEAN=0.09 GEN1 P0=$PDF GEN1 X=1 DISTRIB X / TYPE=POISSON MEAN=0.09 GEN1 PX2=1-(P0+$PDF) PRINT PX2 * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.13, p. 158 * DO #=0,2 GEN1 X#=# DISTRIB X# / TYPE=POISSON MEAN=2 GEN1 PDF#=$PDF PRINT PDF# ENDO GEN1 P=1-(PDF0+PDF1+PDF2) PRINT P * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.14, p. 159 * DO #=0,2 GEN1 X#=# DISTRIB X# / TYPE=POISSON MEAN=3.5 GEN1 PDF#=$PDF PRINT PDF# ENDO GEN1 P2=PDF0+PDF1+PDF2 GEN1 P3=1-P2 PRINT P2 P3 * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.15, p. 161 * SAMPLE 1 3 READ X1 X2 X3 PY 0.10 0.20 0.10 0.40 0.25 0.25 0.10 0.60 0.35 0.45 0.20 1.00 * * The GEN1 command is used to calculate the probability. To extract the * data from Row 1 of the variable X2, the X2:1 is used. To extract Row 2 * of the variable X2, the X2:3 is used. * GEN1 P12=X2:1/X2:3 PRINT P12 * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.16, p. 163 * SAMPLE 1 4 READ X Y0 Y5 Y10 Y15 / LIST 0 0.0625 0.0625 0.0625 0.0625 5 0.0625 0.0625 0.0625 0.0625 10 0.0625 0.0625 0.0625 0.0625 15 0.0625 0.0625 0.0625 0.0625 * * Case A * STAT Y0 / SUMS=PX0 STAT X / SUMS=SX STAT Y5 / SUMS=SY5 STAT Y10 / SUMS=SY10 STAT Y15 / SUMS=SY15 PRINT PX0 * * Case C * * Mean of X, MX * GENR XC=X/100 GEN1 MX=(XC:1*PX0)+(XC:2*PX0)+(XC:3*PX0)+(XC:4*PX0) PRINT MX * * Variance of X, SIG2X and Standard Deviation, SIG2 * GEN1 SIG2X=PX0*((XC:1-MX)**2+(XC:2-MX)**2+(XC:3-MX)**2+(XC:4-MX)**2) GEN1 SIGX=SQRT(SIG2X) PRINT SIG2X SIGX * *---------------------------------------------------------------------------- * Example 5.17, p. 166 * STAT XC Y0 Y5 Y10 Y15 / PCOV PCOR * DELETE / ALL *---------------------------------------------------------------------------- * Example 5.18, p. 169 * SAMPLE 1 2 READ X PX Y PY / LIST -5 0.40 0 0.60 20 0.60 25 0.40 * * The mean of X, MEANX, is calculated with the GEN1 command. * GENR MX=(X*PX) STAT MX / SUMS=MEANX PRINT MEANX * * Calculate the variance of X, VAR. * GENR V=((X-MEANX)**2)*PX STAT V / SUMS=VAR PRINT VAR * * Strategy A has a Mean Profit, MP and Variance, VX of: * GEN1 MPX=10*MEANX GEN1 VX=100*VAR PRINT MPX VX * * The mean and variance calculations for variable Y is calculated the same * way. * * The mean of Y, MEANY, is calculated with the GEN1 command. * GENR MY=(Y*PY) STAT MY / SUMS=MEANY PRINT MEANY * * Calculate the variance of Y, VARY2. * GENR VARY=((Y-MEANY)**2)*PY STAT VARY / SUMS=VARY2 PRINT VARY2 * * Strategy B has a Mean Profit, MP and Variance, VY of: * GEN1 MPY=10*MEANY GEN1 VX=100*VARY2 PRINT MPY VX * *---------------------------------------------------------------------------- * Example 5.19, p. 171 * SAMPLE 1 4 READ PRICEA PRICE40 PRICE50 PRICE60 PRICE70 / LIST 45 0.240000 0.003333 0.003333 0.003333 50 0.003333 0.240000 0.003333 0.003333 55 0.003333 0.003333 0.240000 0.003333 60 0.003333 0.003333 0.003333 0.240000 * * Calculate the mean value, MEANW, and variance, SIG2W, for the portfolio. * GEN1 MA=53 GEN1 VA=31.3 GEN1 MB=55 GEN1 VB=125 GEN1 COVAB=59.17 GEN1 CORAB=0.947 GEN1 MEANW=5*MA+10*MB GEN1 SIG2W=(5**2)*VA+(10**2)*VB+(2*5*10*COVAB) PRINT MEANW SIG2W * * The covariance of Stock C and D is defined as COVCD with a value of * -59.17 thus, the variance of the portfolio in this case is defined * as SIG2W2. * GEN1 MC=53 GEN1 VC=31.3 GEN1 MD=55 GEN1 VD=125 GEN1 COVCD=-59.17 GEN1 SIG2W2=(5**2)*VC+(10**2)*VD+(2*5*10*COVCD) PRINT SIG2W2 * *---------------------------------------------------------------------------- * Example 5.20, p.172 * * The mean of X, MEANX, is calculated with the GEN1 command. * GENR MX=(X*PX) STAT MX / SUMS=MEANX PRINT MEANX * * Calculate the variance of X, VARX. * GENR V=((X-MEANX)**2)*PX STAT V / SUMS=VARX PRINT VARX * * Strategy A has a Mean Profit, MP and Variance, VX of: * GEN1 MPX=10*MEANX GEN1 VX=100*VARX PRINT MPX VX * * The mean of Y, MEANY, is calculated with the GEN1 command. * GENR MY=(Y*PY) STAT MY / SUMS=MEANY PRINT MEANY * * Calculate the variance of Y, VARY. * GENR VARYY=((Y-MEANY)**2)*PY STAT VARYY / SUMS=VAR3 PRINT VAR3 * * Strategy B has a Mean Profit, MP and Variance, VY of: * GEN1 MPY=10*MEANY GEN1 VX=100*VAR3 PRINT MPY VX GEN1 EB=5*MEANX+5*MEANY GEN1 VB=25*VARX+25*VAR3 PRINT EB VB * *---------------------------------------------------------------------------- STOP