(FILECREATED "28-Jun-86 15:14:29" {QV}<PEDERSEN>LISP>IDL-TDEMO.;3 9423   

      changes to:  (FNS IDLDEMO.CLEANUP IDLDEMO IDLDEMO.WHENSELECTEDFN IDLDEMO.SHADEITEM TDEMO 
			IDL-T-DEMO COMPUTE-TSTATS QUANTILE-PLOT IDLDEMO.SHADEDOUBLEITEM)
		   (VARS IDL-TDEMOCOMS)

      previous date: "25-Jun-86 12:43:35" {QV}<PEDERSEN>LISP>IDL-TDEMO.;1)


(* Copyright (c) 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT IDL-TDEMOCOMS)

(RPAQQ IDL-TDEMOCOMS ((FNS COMPUTE-TSTATS IDL-T-DEMO IDLDEMO.CLEANUP IDLDEMO IDLDEMO.SHADEITEM 
			     IDLDEMO.WHENSELECTEDFN QUANTILE-PLOT)
			(P [SETQ LOTTERY (IDLMATRIX-FROM-LIST (READFILE (QUOTE 
								      {QV}<IDL>DATA>LOTTERY1.DATA]
			   [SETQ LOTTERY2 (IDLMATRIX-FROM-LIST (READFILE (QUOTE 
								      {QV}<IDL>DATA>LOTTERY2.DATA]
			   [SETQ LOTTERY3 (IDLMATRIX-FROM-LIST (READFILE (QUOTE 
								      {QV}<IDL>DATA>LOTTERY3.DATA]
			   (TEDIT (QUOTE {QV}<IDL>DEMO>DEMOSCRIPT.TEDIT)
				  TEDITWINDOW))))
(DEFINEQ

(COMPUTE-TSTATS
  [LAMBDA (MATRIX N)                                         (* jop: "25-Jun-86 12:26")

          (* *)


    (if (NULL N)
	then (SETQ N (IDLARRAY-DIMENSION MATRIX 1)))
    (LET ((M (MEAN MATRIX))
	  (V (SAMPLE-VARIANCE MATRIX)))
         (IDL-QUOTIENT M (IDL-SQRT (IDL-QUOTIENT V N V)
				       V)
			 M])

(IDL-T-DEMO
  [LAMBDA NIL                                                (* jop: "28-Jun-86 14:10")

          (* *)


    (PROG ((TTYWINDOW (WFROMDS (TTYDISPLAYSTREAM)))
	     (IDLDEMO.MENU (create MENU
				     ITEMS ←(QUOTE (("Make a random sample" 
				      "(SETQ SAMPLES (RESHAPE (ASVECTOR* 150 10) (NORMALS 1500))")
						       ("Get its variance" 
							      "(SETQ V (SAMPLE-VARIANCE SAMPLES)")
						       ("Get its mean" "(SETQ M (MEAN SAMPLES)")
						       ("Compute the t-statistics" 
			     "(SETQ TSTATS (IDL-QUOTIENT M (IDL-SQRT (IDL-QUOTIENT V 10 V) V) M)")
						       ("Whats the maximum value?" 
									     "(MAX-REDUCE TSTATS")
						       ("Whats the minimum value?" 
									     "(MIN-REDUCE TSTATS")
						       ("Describe the distribution" 
						  "(HISTOGRAM TSTATS NIL 'T-value 'Normal-Sample")
						       ("Compare quantiles")
						       ("First get Percent points" 
"(PROGN (SETQ TEMP (GENVECTOR 150 1.0)) (SETQ TPOINTS (INV-T-DIST (IDL-QUOTIENT TEMP 151 TEMP) 9 TEMP ))"
										   )
						       ("Sort the Tstats" 
						     "(SETQ OTSTATS (AT* TSTATS (ORDER TSTATS ))")
						       ("Make a quantile plot" 
		"(SETQ SCAT (SCATTERPLOT (ASVECTOR*  TPOINTS OTSTATS) 'Theorectical 'Computed)  ")
						       ("Add a line of slope one" 
								  "(PLOTLINE SCAT 1.0 0.0  NIL 2")
						       ("Do the same to a perturbed data set")
						       ("Perturb SAMPLES" 
		"(PROGN (SETQ PER (IDL-COPY SAMPLES)) (ASSIGN* (NORMALS 150 0.0 5.0) PER 'ALL 0)")
						       ("Programm Tstats" "(DF COMPUTE-TSTATS")
						       ("Compute the t-statistics" 
							 "(SETQ PER-TSTATS (COMPUTE-TSTATS PER )")
						       ("Describe the distribution" 
							"(HISTOGRAM PER-TSTATS NIL 'Per-T-value ")
						       ("Program quantile plot" "(DF QUANTILE-PLOT ")
						       ("Make a quantile plot" 
								   "(QUANTILE-PLOT PER-TSTATS 10")
						       ("Non-zero means" 
     "(PROGN (SETQ NON-ZERO (IDL-COPY SAMPLES)) (SETQ NON-ZERO (IDL-PLUS NON-ZERO 3.0 NON-ZERO))")
						       ("As before" 
     "(PROGN (SETQ NON-ZERO-TSTATS (COMPUTE-TSTATS NON-ZERO)) (QUANTILE-PLOT NON-ZERO-TSTATS 10)")
						       ("What happens in general?" 
"(PROGN (SETQ X-VALUES (GENVECTOR 201 -100.0 1.0 ))(SETQ INF-SAMPLES (ADJOIN X-VALUES (SETQ INF-SAMPLE (RESHAPE  (ASVECTOR* 201 9) (NORMALS 9))))"
										   )
						       ("Compute the t-statistics" 
						  "(SETQ INF-TSTATS (COMPUTE-TSTATS INF-SAMPLES)")
						       ("Plot the influence curve" 
			  "(SCATTERPLOT (ASVECTOR* X-VALUES INF-TSTATS ) 'X-value 'T-value 'LINE")
						       ("Redo with non-zero mean" 
	      "(SETQ NON-ZERO-INF-SAMPLES (ADJOIN X-VALUES (IDL-PLUS INF-SAMPLE 3.0 INF-SAMPLE))")
						       ("Plot the influence curve" 
"(SCATTERPLOT (ASVECTOR8  X-VALUES (COMPUTE-TSTATS NON-ZERO-INF-SAMPLES ) )  'X-value 'T-value 'LINE")
						       ))
				     WHENSELECTEDFN ←(FUNCTION IDLDEMO.WHENSELECTEDFN)
				     TITLE ← "Typescript Menu for IDL demo")))
	    (DECLARE (SPECVARS IDLDEMO.SHADEDITEM IDLDEMO.TTYWINDOW))
	    (SETQ IDLDEMO.TTYWINDOW TTYWINDOW)
	    (SHAPEW TTYWINDOW (CREATEREGION 5 400 400 330))
	    (ATTACHMENU IDLDEMO.MENU TTYWINDOW (QUOTE RIGHT)
			  (QUOTE TOP))
	    (SETQ IDLDEMO.SHADEDITEM (CAR (fetch ITEMS of IDLDEMO.MENU)))
	    (IDLDEMO.SHADEITEM IDLDEMO.SHADEDITEM IDLDEMO.MENU SHADE1)
	    (GIVE.TTY.PROCESS TTYWINDOW])

(IDLDEMO.CLEANUP
  [LAMBDA NIL                                                (* jop: "25-Jun-86 12:00")

          (* *)


    (PROG [(TTYWINDOW (WFROMDS (TTYDISPLAYSTREAM]
	    (DETACHALLWINDOWS TTYWINDOW)
	    (WINDOWPROP TTYWINDOW (QUOTE MINSIZE)
			  NIL])

(IDLDEMO
  [LAMBDA NIL                                                (* jop: "28-Jun-86 14:36")

          (* *)


    (PROG ((TTYWINDOW (WFROMDS (TTYDISPLAYSTREAM)))
	     (IDLDEMO.MENU (create MENU
				     ITEMS ←(QUOTE (("Inspect Lottery data" "(INSPECT LOTTERY")
						       ("Select winning numbers" "(SETQ NUMBERS IT")
						       ("Histogram of winning numbers" 
						    "(HISTOGRAM NUMBERS NIL %"Winning numbers%" ")
						       ("Select payoffs" "(SETQ PAYOFF  IT")
						       ("Histogram of payoffs" 
						    "(SETQ HIST (HISTOGRAM PAYOFF NIL 'Payoffs) ")
						       ("Add $500 line to Histogram" 
							      "(PLOTLINE HIST NIL 500 '$500
	  2")
						       ("Relate Payoff to winning number" 
			 "(SETQ SCAT (SCATTERPLOT (ASVECTOR* NUMBERS PAYOFF ) %"Winning Numbers)")
						       ("Regress payoff on number" 
					     "(SETQ RESULT (REGRESS PAYOFF (ADJOIN 1.0 NUMBERS))")
						       ("Inspect result" "(INSPECT RESULT")
						       ("Add the regression line" 
						"(ADDLINES SCAT (RESHAPE (ASVECTOR* 1 2) RESULT)")
						       ("Add smoother to menu" 
		 "(PLOTADDMENUITEMS SCAT (QUOTE RIGHT)
		  (QUOTE ((Smooth SCATTERPLOT.SMOOTH)))")
						       ("Select Payoff's for Second Year" 
						     "(SETQ PAYOFF2 (AT* LOTTERY2 'ALL payoff2) ")
						       ("Select Payoff's for Third Year" 
						     "(SETQ PAYOFF3 (AT* LOTTERY2 'ALL payoff3) ")
						       ("Compare payoff's for three years" 
	    "(SETQ BOXPLOT (BOXPLOTS (ASVECTOR* PAYOFF PAYOFF2 PAYOFF3) '(Year1 Year2 Year3) )  ")
						       ("Add $500 mark to Boxplots" 
						      "(PLOTLINE BOXPLOT 0 500 (QUOTE $500)
	  2")))
				     WHENSELECTEDFN ←(FUNCTION IDLDEMO.WHENSELECTEDFN)
				     TITLE ← "Typescript Menu for IDL demo")))
	    (DECLARE (SPECVARS IDLDEMO.SHADEDITEM IDLDEMO.TTYWINDOW LOTTERY LOTTERY2 LOTTERY3))
	    (SETQ IDLDEMO.TTYWINDOW TTYWINDOW)
	    (SHAPEW TTYWINDOW (CREATEREGION 5 570 300 150))
	    (ATTACHMENU IDLDEMO.MENU TTYWINDOW (QUOTE RIGHT)
			  (QUOTE TOP))
	    (SETQ IDLDEMO.SHADEDITEM (CAR (fetch ITEMS of IDLDEMO.MENU)))
	    (IDLDEMO.SHADEDOUBLEITEM IDLDEMO.SHADEDITEM IDLDEMO.MENU SHADE1)
	    (GIVE.TTY.PROCESS TTYWINDOW])

(IDLDEMO.SHADEITEM
  [LAMBDA (ITEM1 MENU SHADE)                                 (* jop: "25-Jun-86 11:18")

          (* *)


    (LET* ((MENUW (WFROMMENU MENU))
	   (REGION1 (MENUITEMREGION ITEM1 MENU)))
          (BITBLT NIL NIL NIL MENUW (fetch LEFT of REGION1)
		    (fetch BOTTOM of REGION1)
		    (fetch WIDTH of REGION1)
		    (fetch HEIGHT of REGION1)
		    (QUOTE TEXTURE)
		    (QUOTE INVERT)
		    SHADE])

(IDLDEMO.WHENSELECTEDFN
  [LAMBDA (ITEM MENU BUTTON)                                 (* jop: "28-Jun-86 14:10")

          (* *)


    (PROG ((FORM (CADR ITEM)))
	    (DECLARE (USEDFREE IDLDEMO.SHADEDITEM IDLDEMO.TTYWINDOW))
	    (IDLDEMO.SHADEITEM IDLDEMO.SHADEDITEM MENU SHADE1)
	    (GIVE.TTY.PROCESS IDLDEMO.TTYWINDOW)
	    (BKSYSBUF FORM)
	    [SETQ IDLDEMO.SHADEDITEM (CADR (MEMB ITEM (fetch ITEMS of MENU]
	    [if (NULL IDLDEMO.SHADEDITEM)
		then (SETQ IDLDEMO.SHADEDITEM (CAR (fetch ITEMS of MENU]
	    (IDLDEMO.SHADEITEM IDLDEMO.SHADEDITEM MENU SHADE1])

(QUANTILE-PLOT
  [LAMBDA (VECTOR N)                                       (* jop: "27-Jun-86 15:36")

          (* *)


    (LET* [(M (IDLARRAY-DIMENSION VECTOR 0))
	   (TEMP (GENVECTOR M 1.0))
	   (TPOINTS (INV-T-DIST (IDL-QUOTIENT TEMP (ADD1 M)
						  TEMP)
				  (SUB1 N)
				  TEMP))
	   (OTSTATS (AT* VECTOR (ORDER VECTOR]
          (SCATTERPLOT (ASVECTOR* TPOINTS OTSTATS)
			 (CONCAT "T on " (SUB1 N)
				   "df's")
			 "Computed T-values"])
)
[SETQ LOTTERY (IDLMATRIX-FROM-LIST (READFILE (QUOTE {QV}<IDL>DATA>LOTTERY1.DATA]
[SETQ LOTTERY2 (IDLMATRIX-FROM-LIST (READFILE (QUOTE {QV}<IDL>DATA>LOTTERY2.DATA]
[SETQ LOTTERY3 (IDLMATRIX-FROM-LIST (READFILE (QUOTE {QV}<IDL>DATA>LOTTERY3.DATA]
(TEDIT (QUOTE {QV}<IDL>DEMO>DEMOSCRIPT.TEDIT)
       TEDITWINDOW)
(PUTPROPS IDL-TDEMO COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (976 9032 (COMPUTE-TSTATS 986 . 1362) (IDL-T-DEMO 1364 . 4818) (IDLDEMO.CLEANUP 4820 . 
5117) (IDLDEMO 5119 . 7376) (IDLDEMO.SHADEITEM 7378 . 7858) (IDLDEMO.WHENSELECTEDFN 7860 . 8515) (
QUANTILE-PLOT 8517 . 9030)))))
STOP