svn: r157
This commit is contained in:
parent
9d54a4f78c
commit
fb7e8319bf
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 66 KiB |
Binary file not shown.
Before Width: | Height: | Size: 64 KiB |
|
@ -1,36 +0,0 @@
|
||||||
(require (lib "graphics.ss" "graphics")
|
|
||||||
(lifted mzscheme
|
|
||||||
make-hash-table
|
|
||||||
hash-table-put!
|
|
||||||
hash-table-get))
|
|
||||||
|
|
||||||
|
|
||||||
(open-graphics)
|
|
||||||
(define window (open-viewport "Debugger" 600 500))
|
|
||||||
((draw-viewport window) (make-rgb 0.95 0.95 0.95))
|
|
||||||
|
|
||||||
|
|
||||||
(define-mztake-process p ("random-Xs-v3.ss" [x-trace 6 26 bind 'num]))
|
|
||||||
|
|
||||||
(define largest-bin 0)
|
|
||||||
(define valcount (make-hash-table))
|
|
||||||
|
|
||||||
(hold (x-trace . -=> .(printf-b "largest count: ~a" largest-bin)))
|
|
||||||
|
|
||||||
|
|
||||||
(map-e (lambda (x)
|
|
||||||
(let* ([new-cnt (add1 (hash-table-get valcount x (lambda () 0)))]
|
|
||||||
[color (/ new-cnt (add1 largest-bin))])
|
|
||||||
|
|
||||||
(when (> new-cnt largest-bin) (set! largest-bin new-cnt))
|
|
||||||
|
|
||||||
(hash-table-put! valcount x new-cnt)
|
|
||||||
|
|
||||||
((draw-solid-rectangle window) (make-posn x (- 500 (* 4 new-cnt)))
|
|
||||||
1 4 ;; width height
|
|
||||||
(make-rgb 0 (* 0.75 color) color))))
|
|
||||||
x-trace)
|
|
||||||
|
|
||||||
(printf-b "count: ~a" (count-b x-trace))
|
|
||||||
|
|
||||||
(start/resume p)
|
|
|
@ -16,19 +16,14 @@
|
||||||
change in each bin.
|
change in each bin.
|
||||||
|
|
||||||
Try looking for small groupings of bins where all are light, or all
|
Try looking for small groupings of bins where all are light, or all
|
||||||
are dark -- these represent trends in the numbers.
|
are dark -- these represent small trends in the numbers.
|
||||||
|
|
||||||
Look for tortoises that stay low and black, and hares which are very
|
Look for tortoises that stay low and black, and hares which are very
|
||||||
active and bright.
|
active and bright.
|
||||||
|
|
||||||
Notice how the bottom tends to be rather patchy with lots of color
|
|
||||||
variation (the "start-up" phase of the random number generator),
|
|
||||||
and then towards the middle of the screen, most of the blues have
|
|
||||||
settled down and evened out.
|
|
||||||
|
|
||||||
The bars drag a bit when moving upwards (the height goes up by 2, but
|
The bars drag a bit when moving upwards (the height goes up by 2, but
|
||||||
the redrawing of the latest color goes down 10 pixels) so that you can
|
the redrawing of the latest color goes down 10 pixels) so that you can
|
||||||
spot vertical and horizontal trends more easily. |#
|
spot vertical trends more easily. |#
|
||||||
|
|
||||||
|
|
||||||
(require (lib "graphics.ss" "graphics")
|
(require (lib "graphics.ss" "graphics")
|
||||||
|
@ -56,7 +51,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define-mztake-process p ("random-Xs.ss" [x-trace 4 6 bind 'x]))
|
(define-mztake-process p ("random-xs.ss" [x-trace 4 6 bind 'x]))
|
||||||
#| * Create a process to debug random-xs.ss
|
#| * Create a process to debug random-xs.ss
|
||||||
|
|
||||||
* Add a tracepoint at line 4, column 6; in the program,
|
* Add a tracepoint at line 4, column 6; in the program,
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
(module |random-Xs-v3| mzscheme
|
|
||||||
|
|
||||||
(define seed-list (call-with-input-file "rand.txt"
|
|
||||||
(lambda (file)
|
|
||||||
(let loop ([num (read file)])
|
|
||||||
(if (eof-object? num) '()
|
|
||||||
(loop (read file))))))))
|
|
|
@ -1,4 +1,4 @@
|
||||||
(module |random-Xs| mzscheme
|
(module random-xs mzscheme
|
||||||
(define (run)
|
(define (run)
|
||||||
(let loop ([x (random 100)])
|
(let loop ([x (random 100)])
|
||||||
(loop (random 100))))
|
(loop (random 100))))
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 58 KiB |
|
@ -16,26 +16,20 @@
|
||||||
change in each bin.
|
change in each bin.
|
||||||
|
|
||||||
Try looking for small groupings of bins where all are light, or all
|
Try looking for small groupings of bins where all are light, or all
|
||||||
are dark -- these represent trends in the numbers.
|
are dark -- these represent small trends in the numbers.
|
||||||
|
|
||||||
Look for tortoises that stay low and black, and hares which are very
|
Look for tortoises that stay low and black, and hares which are very
|
||||||
active and bright.
|
active and bright.
|
||||||
|
|
||||||
Notice how the bottom tends to be rather patchy with lots of color
|
|
||||||
variation (the "start-up" phase of the random number generator),
|
|
||||||
and then towards the middle of the screen, most of the blues have
|
|
||||||
settled down and evened out.
|
|
||||||
|
|
||||||
The bars drag a bit when moving upwards (the height goes up by 2, but
|
The bars drag a bit when moving upwards (the height goes up by 2, but
|
||||||
the redrawing of the latest color goes down 10 pixels) so that you can
|
the redrawing of the latest color goes down 10 pixels) so that you can
|
||||||
spot vertical and horizontal trends more easily. |#
|
spot vertical trends more easily. |#
|
||||||
|
|
||||||
|
|
||||||
(require (lib "graphics.ss" "graphics")
|
(require (lib "graphics.ss" "graphics")
|
||||||
#| Needed for open-graphics, open-viewport, and draw-solid-ellipse |#
|
#| Needed for open-graphics, open-viewport, and draw-solid-ellipse |#
|
||||||
|
|
||||||
(lifted mzscheme
|
(lifted mzscheme
|
||||||
hash-table-for-each
|
|
||||||
make-hash-table
|
make-hash-table
|
||||||
hash-table-put!
|
hash-table-put!
|
||||||
hash-table-get))
|
hash-table-get))
|
||||||
|
@ -57,7 +51,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define-mztake-process p ("random-Xs.ss" [x-trace 4 6 bind 'x]))
|
(define-mztake-process p ("random-xs.ss" [x-trace 4 6 bind 'x]))
|
||||||
#| * Create a process to debug random-xs.ss
|
#| * Create a process to debug random-xs.ss
|
||||||
|
|
||||||
* Add a tracepoint at line 4, column 6; in the program,
|
* Add a tracepoint at line 4, column 6; in the program,
|
||||||
|
@ -73,43 +67,41 @@
|
||||||
#| this will hold the counts for the histogram
|
#| this will hold the counts for the histogram
|
||||||
x is the key, and the number of times x shows up is the value |#
|
x is the key, and the number of times x shows up is the value |#
|
||||||
|
|
||||||
(define total-count (count-b x-trace))
|
|
||||||
|
|
||||||
(printf-b "count: ~a" total-count)
|
(hold (x-trace . -=> .(printf-b "largest count: ~a" largest-bin)))
|
||||||
#| prints the count of how many events x-trace got,
|
|
||||||
aka how many values are in the histogram and on the screen. |#
|
|
||||||
|
|
||||||
|
|
||||||
(hold (x-trace . -=> .(printf-b "highest bin count: ~a" largest-bin)))
|
|
||||||
#| Prints out the largest count every time we get a new x-trace event |#
|
#| Prints out the largest count every time we get a new x-trace event |#
|
||||||
|
|
||||||
|
|
||||||
(map-e (lambda (x)
|
(map-e (lambda (x)
|
||||||
(let ([new-cnt (add1 (hash-table-get valcount x (lambda () 0)))])
|
(let* ([new-cnt (add1 (hash-table-get valcount x (lambda () 0)))]
|
||||||
|
[color (/ new-cnt (add1 largest-bin))])
|
||||||
|
|
||||||
(when (zero? (modulo (value-now total-count) 1000))
|
(when (= largest-bin 250)
|
||||||
(hash-table-for-each
|
(kill p))
|
||||||
valcount
|
; when one of the bars reaches the top of the screen, kill the program.
|
||||||
(lambda (x v)
|
|
||||||
(let ([color (min 1 (* 50 (/ v 1000)))])
|
|
||||||
((draw-solid-rectangle window) (make-posn (* x 6)
|
|
||||||
(- 500 (* 10 (/ (value-now total-count) 1000))))
|
|
||||||
6 10 ;; width height
|
|
||||||
(make-rgb 0 (* 0.75 color) color)))))
|
|
||||||
(set! valcount (make-hash-table))
|
|
||||||
(set! largest-bin 0))
|
|
||||||
|
|
||||||
(when (> new-cnt largest-bin) (set! largest-bin new-cnt))
|
(when (> new-cnt largest-bin) (set! largest-bin new-cnt))
|
||||||
; keep track of the largest count
|
; keep track of the largest count
|
||||||
|
|
||||||
(hash-table-put! valcount x new-cnt)))
|
(hash-table-put! valcount x new-cnt)
|
||||||
;; increment the value in the hashtable, starting from 0 if none exists.
|
;; increment the value in the hashtable, starting from 0 if none exists.
|
||||||
|
|
||||||
|
((draw-solid-rectangle window) (make-posn (* x 6) (- 500 (* 2 new-cnt)))
|
||||||
|
6 10 ;; width height
|
||||||
|
(make-rgb 0 (* 0.75 color) color))))
|
||||||
x-trace)
|
x-trace)
|
||||||
#| Every time x-trace gets a new value, take this latest value and pass it to a function
|
#| Every time x-trace gets a new value, take this latest value and pass it to a function
|
||||||
which increments the count in the hashtable, and draws a circle in the window at
|
which increments the count in the hashtable, and draws a circle in the window at
|
||||||
(* x 6) pixels from the left, and the height is (2 * the latest count in the hashtable for that x),
|
(* x 6) pixels from the left, and the height is (2 * the latest count in the hashtable for that x),
|
||||||
making a color (MAKE-RGB) that is lighter based on how fast it is growing. |#
|
making a color (MAKE-RGB) that is lighter based on how fast it is growing.
|
||||||
|
|#
|
||||||
|
|
||||||
|
|
||||||
(start/resume p) ;; Start the process for random-xs.ss
|
(printf-b "count: ~a" (count-b x-trace))
|
||||||
|
#| prints the count of how many events x-trace got,
|
||||||
|
aka how many values are in the histogram and on the screen.
|
||||||
|
|#
|
||||||
|
|
||||||
|
|
||||||
|
(start/resume p)
|
||||||
|
;; Start the process for random-xs.ss
|
5
collects/mztake/demos/random/random-xs.ss
Normal file
5
collects/mztake/demos/random/random-xs.ss
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
(module random-xs mzscheme
|
||||||
|
(define (run)
|
||||||
|
(let loop ([x (random 100)])
|
||||||
|
(loop (random 100))))
|
||||||
|
(run))
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 40 KiB |
Loading…
Reference in New Issue
Block a user