Chapter 5 - STATISTICS FOR BUSINESS & ECONOMICS by Paul Newbold
*****************************************************************************
* CHAPTER 5 - STATISTICS FOR BUSINESS & ECONOMICS, 4th Ed., by Paul Newbold *
*****************************************************************************
*
* Example 5.1, page 185
*
GEN1 FX0=0.50
GEN1 FRACTURE=(FX0*1.5)-(FX0*0.5)
PRINT FRACTURE
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.2, page 188
*
* Based on the formula in the box on page 188, the values for A, B, MEANT
* and STD are defined.
*
GEN1 A=290
GEN1 B=-5
GEN1 MEANT=24
GEN1 SIGMA=4
*
* Expected Heating Bill (HEATBILL).
*
GEN1 HEATBILL=A+(B*MEANT)
*
* The variance for the Heating Bill (VARBILL) is calculated.  The standard
* deviation (STDBILL) is the square root of VARBILL.
*
GEN1 VARBILL=(B**2)*(SIGMA**2)
GEN1 STDBILL=ABS(B)*SIGMA
PRINT HEATBILL VARBILL STDBILL
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.3, page 191
*
* The variable X1=materials cost and X2=labor costs.
*
GEN1 LABOR=1500
GEN1 MDAYS=80
GEN1 SIGMAL=12
GEN1 MEAN1=100000
GEN1 SIGMA1=10000
GEN1 MEAN2=LABOR*MDAYS
GEN1 SIGMA2=LABOR*SIGMAL
*
* Total Project Cost(TCOST), Variance (VAR) and Standard Deviation (STD) is:
*
GEN1 TCOST=MEAN1+MEAN2
GEN1 VAR=(SIGMA1**2)+(SIGMA2**2)
GEN1 STD=SQRT(VAR)
PRINT TCOST VAR STD
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.4, page 192
*
* Read this example carefully.  Be sure you understand the methodology.
*
*----------------------------------------------------------------------------
* Example 5.5, page 200
*
* The probability that Z is less than 0.75 and greater -0.50 is calculated
* using the GEN1 command.  From Table 3 of the Appendix, Fz(0.50)=0.6915
* and Fz(0.75)=-.7734.
*
GEN1 FNEG50=0.6915
GEN1 F75=0.7734
GEN1 PNEG5075=F75-(1-FNEG50)
PRINT PNEG5075
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.6, page 201
*
* The probability that X is larger than 18 is calculated using the GEN1
* command.
*
GEN1 X=18
GEN1 MEAN=15
GEN1 SIGMA2=16
GEN1 SIGMA=SQRT(SIGMA2)
GEN1 FZ=(X-MEAN)/SIGMA
PRINT FZ
*
* From Table 3 of the Appendix, Fz(0.75)=0.7734.
*
GEN1 F75=0.7734
GEN1 PX=1-F75
PRINT PX
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.7, page 201
*
* The probability that X is less than 6 and greater than 4 is calculated
* using the GEN1 command.
*
GEN1 MEAN=3
GEN1 SIGMA=2
GEN1 X1=4
GEN1 X2=6
GEN1 P4=(X1-MEAN)/SIGMA
GEN1 P6=(X2-MEAN)/SIGMA
PRINT P4 P6
*
* From Table 3 of the Appendix, Fz(1.5)=0.9332 and Fz(0.5)=0.6915.
*
GEN1 F15=0.9332
GEN1 F5=0.6915
GEN1 PX=F15-F5
PRINT PX
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.8, page 202
*
* The probability that the lightbulb's lifetime will between 900 and 1300
* hours is calculated using the GEN1 command.
*
GEN1 MEAN=1200
GEN1 SIGMA=250
GEN1 X1=900
GEN1 X2=1300
GEN1 P900=(X1-MEAN)/SIGMA
GEN1 P1300=(X2-MEAN)/SIGMA
PRINT P900 P1300
*
* From Table 3 of the Appendix, Fz(0.4)=0.6554 and Fz(-1.2)=0.8849.
*
GEN1 F4=0.6554
GEN1 FNEG12=0.8849
GEN1 PX=F4-(1-FNEG12)
PRINT PX
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.9, page 202
*
* The probability that a portion of the students obtained test scores between
* 85 and 95 is calculated using the GEN1 command.
*
GEN1 MEAN=60
GEN1 SIGMA=15
GEN1 SCORE1=85
GEN1 SCORE2=95
GEN1 P85=(SCORE1-MEAN)/SIGMA
GEN1 P95=(SCORE2-MEAN)/SIGMA
PRINT P85 P95
*
* From Table 3 of the Appendix, Fz(2.33)=0.9901 and Fz(1.67)=0.9525.
*
GEN1 F233=0.9901
GEN1 F167=0.9525
GEN1 PX=F233-F167
PRINT PX
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.10, page 203
*
* The cutoff point for the top 10% of all students from Example 5.9 is
* calculated using the GEN1 command.  
*
GEN1 P=0.10
GEN1 MEAN=60
GEN1 SIGMA=15
GEN1 Z=1.28
GEN1 B=(Z*SIGMA)+MEAN
PRINT B
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.11, page 212
*
* The probability that between 45 to 50 homes visits will result if he
* contacts 100 people by telephone is calculated using the GEN1 command.
* Approximate the binomial probability without using the continuity
* correction is done first.
*
GEN1 A=45
GEN1 B=50
GEN1 N=100
GEN1 P=0.40
GEN1 LOWERB=(A-N*P)/(SQRT(N*P*(1-P)))
GEN1 UPPERB=(B-N*P)/(SQRT(N*P*(1-P)))
PRINT LOWERB UPPERB
*
* From Table 3 of the Appendix, Fz(2.04)=0.9793 and Fz(1.02)=0.8461.
*
GEN1 F204=0.9793
GEN1 F102=0.8461
GEN1 PX=F204-F102
PRINT PX
*
* Now approximate the binomial probability using the continuity correction.
* From Table 3 of the Appendix, Fz(2.14)=0.9838 and Fz(0.92)=0.8212.
*
GEN1 F214=0.9839
GEN1 F92=0.8212
GEN1 PX=F214-F92
PRINT PX
*
* A shorter method in estimating the binomial probability is to use the
* DISTRIB command in SHAZAM.  The general format of the DISTRIB command is:
*
*     DISTRIB vars / options
*
* where:  var     = a list of variables
*         options = a list of the options that are required on the
*                   specified type of distribution
*
* First the sample size of 100 contacts must be generated with the SAMPLE
* and GENR commands.  The TIME(0) function on the GENR command creates a
* time index that will begin at 1.
*
SAMPLE 1 100
GENR X=TIME(0)
*
* The TYPE=BINOMIAL option specifies that the Binomial Distribution is to be
* estimated.  When a Binomial Distribution is estimated the N= and P= options
* must be specified.  N= the sample size and P= the parameter value of the
* distribution.  The PDF= option will be used to save the Probability
* Density Functions for each observation in the variable PDF which will be
* used in calculating the probability that between 45 and 50 visits will
* result for the salesman.
*
DISTRIB X / TYPE=BINOMIAL P=0.4 N=100 PDF=PDF LIST
*
* The GEN1 command is used to extract the Probability Density Functions for
* observations 45 (PDF:45), 46 (PDF:46), 47 (PDF:47), 48 (PDF:48), 49 (PDF:49),
* and 50 (PDF:50) from the vector PDF to calculate the Binomial Probability
* with continuity correction.
*
GEN1 VALUE=PDF:45+PDF:46+PDF:47+PDF:48+PDF:49+PDF:50
PRINT VALUE
*
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.12, page 214
*
* The probability that the number of calls received in a given day is between
* 20 to 30.  First approximate the Poisson distribution using the normal
* distribution without continuity correction.  From Table 3 of the Appendix,
* Fz(1)=0.8413.
*
GEN1 FNEG1=0.8413
GEN1 F1=0.8413
GEN1 PX=F1-(1-FNEG1)
PRINT PX
*
* Now estimate the Poisson distribution with the continuity correction.
* From Table 3 of the Appendix, Fz(1.1)=0,8643.
*
GEN1 F11=0.8643
GEN1 FNEG11=0.8643
GEN1 PX=F11-(1-FNEG11)
PRINT PX
*
* The DISTRIB command with the TYPE=POISSON option can be used in this
* example.  This method of estimation is easier.  When the TYPE=POISSON
* option is used the MEAN= option must be specified.  The Probability Density
* Functions are saved in the vector called PDF.  
*
SAMPLE 1 30
GENR X=TIME(0)
DISTRIB X / TYPE=POISSON MEAN=25 PDF=PDF LIST
*
* The GEN1 command is used to calculate the Poisson probability with
* continuity correction.
*
GEN1 VALUE=PDF:20+PDF:21+PDF:22+PDF:23+PDF:24+PDF:25+PDF:26+PDF:27+PDF:28&
+PDF:29+PDF:30
PRINT VALUE
*
DELETE / ALL
*
*----------------------------------------------------------------------------
* Example 5.13, page 216
*
* The probability that the customer service will take longer than 10 minutes.
*
GEN1 PX=EXP(-2)
PRINT PX
*
* The probability that time between successive strikes is less than 2 years.
* 
GEN1 F2=1-EXP(-0.8)
PRINT F2
DELETE / ALL
*
*----------------------------------------------------------------------------
STOP