[ Originally published in Datafile, Vol 15 No 1, February/March 1996, page 10. ] An ApLet for the 38G Craig A. Finseth member #745 This ApLet illustrates the normal distribution curve. It is based on the "real life" model of driving a car. While driving (especially at higher speeds), it is clear that you are passing some vehicles but being passed by others. This ApLet assumes that the speed distribution of the traffic matches the normal distribution. While this assumption is not correct, it is a close enough approximation that it is a reasonable example for the lesson. The input parameters are the traffic's average speed and the standard deviation of that speed. These values can be entered manually or they can be selected from one of the three built-in models [see source note below]. You can view the current values by selecting the: New Avg. Speed New Deviation views and CANCEL'ing the entry. Once the values have been specified, you can view the curves of the percentage of vehicles travelling at that speed or the cumulative number of vehicles travelling at that or slower than that speed (i.e., that one would pass). You can then use the numeric view to answer such questions as: - How fast should I travel if I wish to pass X% of all vehicles? - If I travel at speed X, on the average, how many vehicles will I pass or be passed by? Overall The ApLet is organized around a custom VIEW, which is set up by the SetPaViews program. Selecting a view causes the associated program to run. Each program typically accepts some user input, then shows an updated PLOT view. The exception is the Start view, which initializes the global variables then shows the NOTE. Global Variables S average speed D standard deviation Listings These have been manually transcribed because it wasn't worth the hassle to deal with the steps necessary to do the electronic transfer. Hopefully, there are no errors (:-). Comments (inside @...@) are not in the programs themselves. Special sequences \v/ square root \Gp pi ^2 square \|> store SYMB F1(X)=1-UTPN(S,D^2,X) F2(X)=1/\v/(2*\Gp)*e^(-((X-S)/D)^2/2) NOTE This ApLet illustrates the normal distribution by means of a model taken from driving a car. You specify the traffic's average speed and standard deviation. Then, for any speed, you can view the percentage of cards at that speed and the percentage of cars that one would pass. SetPaViews -- used to initialize the views SETVIEWS "Start"; ".PaStart";8; "Speed Model"; ".PaModel";1; "New Avg. Speed"; ".PaSpeed";1; "New Deviation"; ".PaDev";1; "Plot"; ".PaPass";1: .PaStart 55\|>S: @provide useful defaults@ 10\|>D: CHECK 1: UNCHECK 2: .PaModel 1\|>A: CHOOSE A: "Model"; "Non-Freeway 55"; "Freeway 55"; "Freeway 65"; "User-Specified": CASE IF A==0 THEN STOP END IF A==1 THEN 62.5\|>S: 9.35\|>D END IF A==2 THEN 62.5\|>S: 9.35\|>D END IF A==3 THEN 72.5\|>S: 9.35\|>D END IF A==4 THEN RUN ".PaSpeed": RUN ".PaDev": END END: UNCHECK 3: @force plot screen to be recalculated@ .PaSpeed INPUT S; "Average Speed"; "Speed"; "Enter the average speed"; S: MAX(5,MIN(S,100))\|>S: @force reasonable range@ UNCHECK 3: @force plot screen to be recalculated@ .PaDev INPUT D; "Standard Deviation"; "Std.Dev."; "Enter the standard deviation"; D: MAX(.1,MIN(D,100))\|>D: @force reasonable range@ UNCHECK 3: @force plot screen to be recalculated@ .PaPass 1\|>A: CHOOSE A: "Plot"; "Passing"; "Speed"; "Both": CASE IF A==0 THEN STOP END IF A==1 THEN CHECK 1: UNCHECK 2: END IF A==2 THEN UNCHECK 1: CHECK 2: END IF A==3 THEN CHECK 1: CHECK 2: END END: Craig A. Finseth 1343 Lafond St Paul MN 55104 USA +1 612 644 4027 fin@winternet.com http://www.winternet.com/~fin The ApLet is available electronically from my WWW home page.
Areas
General
Craig's Articles
Last modified Saturday, 2012-02-25T17:29:02-06:00.