macro # # Macro: NCRVTAIL.MAC for Release 13 # Written by: Cathy Akritas, Minitab Inc., May 2005 # # This macro draws a normal curve with shaded tails, shading the specified # proportion of area in the tails. The default behavior is to draw a standard # normal curve and shade half of the specified area in the upper tail and half # in the lower tail. Optionally, you can change the curve from the standard # normal curve to a normal curve with a specified mean and standard deviation or # place the entire shaded area in either the upper or lower tail. # # Suppose you want to create a standard normal curve with shaded area = .05, # where .025 is in the lower tail and .025 area is in the upper tail. # Choose Edit > Commamd Line Editor and type the command # # %NCRVTAIL .05 # # Click on Submit commands. # # If you want to create a normal curve using mean 25 and standard deviation 2.5 # and the amount of shaded area is .1. Go to Edit > Command Line Editor and # type the following # # %NCRVTAIL .1; # params 25 2.5. # # Click on Submit commands. # # If you want to put all the shaded area in the upper tail, go to Edit > Command # Line Editor and type the following # # %NCRVTAIL .1; # params 25 2.5; # upper. # # Click on Submit commands. # # If you want to put all the shaded area in the lower tail, go to Edit > Command # Line Editor and type the following # # %NCRVTAIL .1; # params 25 2.5; # lower. # ############################################################################### # # Neither Minitab Inc. nor the author of this MACRO makes any claim or offers # any warranty whatsoever with regard to the accuracy of this MACRO or its # suitability for use, and Minitab Inc. and the author of this MACRO each # disclaims any liability with respect thereto. # ############################################################################### NCRVTAIL a; params mu sigma; lower; upper. mcolumn x fx group tmp1 xline1 xline2 yline1 yline2 tmp2 ticks mconstant mu sigma a low hi za ahi zhi fn1 fn2 fn3 ttl xlab lotext hitext mconstant x1 y1 x2 x3 y3 reftext1 reftext2 incr k default mu = 0 sigma = 1 mreset noecho brief 0 if sigma le 0 brief 2 note note *** Error *** Sigma must greater than 0 note exit endif if a gt 1 let a = a/100 endif if a ge 1 brief 2 note note *** Error *** Alpha must be greater than 0 and less than 1 note exit endif let low = mu - 4.5*sigma let hi = mu + 4.5*sigma let k = abso(floor(logt(sigma))) +1 if k = 1 or k = 2 let k = 3 endif let incr = (hi-low)/(10**(k/1.11111111)) set x low:hi/incr end pdf x fx; normal mu sigma. if lower = 1 or upper = 1 let ahi = 1 - a else let a = a/2 let ahi = 1-a endif invcdf a Za; norm mu sigma. invcdf ahi zhi; norm mu sigma. stack a ahi tmp1 text tmp1 tmp1; maxw 20. unstack tmp1 a ahi stack Za za xline1 stack zhi zhi xline2 let y1 = .2/sigma if lower = 1 let group = (x gt za) let lotext = a let hitext = " " stack 0 0 yline2 stack 0 y1 yline1 let tmp2 = za text tmp2 tmp2; maxwidth 20. let reftext1 = tmp2(1) let reftext2 = " " elseif upper = 1 let group = (x lt zhi) let lotext = " " let hitext = a stack 0 y1 yline2 stack 0 0 yline1 let tmp2 = zhi text tmp2 tmp2; maxw 20. let reftext1 = " " let reftext2 = tmp2(1) else let group = (x gt za) and (x le zhi) let lotext = a let hitext = a stack 0 y1 yline1 stack 0 y1 yline2 stack za zhi tmp2 text tmp2 tmp2; maxwidth 20. let reftext1 = tmp2(1) let reftext2 = tmp2(2) endif let x1 = low + sigma let x2 = hi - sigma let y1 = .025/sigma let y3 = .215/sigma let ticks(1) = mu - 4*sigma let ticks(2) = mu - 3*sigma let ticks(3) = mu - 2*sigma let ticks(4) = mu - 1*sigma let ticks(5) = mu let ticks(6) = mu + 1*sigma let ticks(7) = mu + 2*sigma let ticks(8) = mu + 3*sigma let ticks(9) = mu + 4*sigma if params = 1 kkset ttl "Area under Normal Curve" kkset xlab "Data" stack mu sigma tmp1 text tmp1 tmp1; maxwidth 20. unstack tmp1 mu sigma kkset fn2 "m = " kkcat fn2 mu fn1 kkset fn2 ", " kkcat fn1 fn2 fn3 kkset fn2 "s = " kkcat fn3 fn2 fn1 kkcat fn1 sigma fn2 else kkset xlab "Z" kkset ttl "Area under Standard Normal Curve" kkset fn2 "m = 0, s = 1" endif plot fx*x; wtitle "Area under Normal Curve"; text za y3 reftext1; placement 0 0; text zhi y3 reftext2; placement 0 0; line xline1 yline1; Type 2; Color 16; Size 1.15; line xline2 yline2; Type 2; Color 16; Size 1.15; ### scale 2; mini 2 0; ### ldisplay 1 0 0 0; ### scale 1; mini 1 low; maxi 1 hi; ticks 1 ticks; area group; type 2 1; color 1 0; nolegend; axis 2; label " "; axis 1; label xlab; title ttl; title fn2; tfont 4; text x1 y1 lotext; text x2 y1 hitext; placement -1 0. endmacro