Deming's funnel: Difference between revisions

From Rosetta Code
Content added Content deleted
m (tidy up task description)
No edit summary
Line 1: Line 1:
{{draft task}}
{{draft task}}
[[wp:W. Edwards Deming|W Edwards Deming]] was an american statistician and management guru who used physical demonstrations to illuminate his management teachings. In one such demonstration he dropped multiple marbles through a funnel at a target, marking where they landed, and observing the resulting pattern. A sequence of "rules" are tested to try to improve performance. In each case, the experiment begins with the funnel positioned directly over the target.
[[wp:W. Edwards Deming|W Edwards Deming]] was an American statistician and management guru who used physical demonstrations to illuminate his management teachings. In one such demonstration he dropped multiple marbles through a funnel at a target, marking where they landed, and observing the resulting pattern. A sequence of "rules" are tested to try to improve performance. In each case, the experiment begins with the funnel positioned directly over the target.


* '''Rule 1''': The funnel remains directly above the target.
* '''Rule 1''': The funnel remains directly above the target.
Line 7: Line 7:
* '''Rule 4''': The funnel moves directly over the last place a marble landed.
* '''Rule 4''': The funnel moves directly over the last place a marble landed.


'''Task''': Apply the four rules to the set of 50 pseudorandom displacements provided as dxs and dys (e.g in the Racket solution). Output: calculate the means, standard-deviations, min and max values of x and y for each rule.
'''Task:''' Simulate 50 pseudorandom drops. The radial displacement of the drop from the funnel position is given by a Gaussian distribution (standard deviation is 1.0) and the angle of displacement is uniformly distributed. Apply each rule to the set of 50 drops, and show scatter plots of all four results.


'''Stretch 1''': Generate fresh pseudorandom data. The radial displacement of the drop from the funnel position is given by a Gaussian distribution (standard deviation is 1.0) and the angle of displacement is uniformly distributed.
;Further information

'''Stretch 2''': Show scatter plots of all four results.

===Further information===
* Further [http://blog.newsystemsthinking.com/w-edwards-deming-and-the-funnel-experiment/ explanation and interpretation]
* Further [http://blog.newsystemsthinking.com/w-edwards-deming-and-the-funnel-experiment/ explanation and interpretation]
* [https://www.youtube.com/watch?v=2VogtYRc9dA Video demonstration] of the funnel experiment at the Mayo Clinic.
* [https://www.youtube.com/watch?v=2VogtYRc9dA Video demonstration] of the funnel experiment at the Mayo Clinic.


=={{header|Racket}}==
=={{header|Racket}}==
The stretch solutions can be obtained by uncommenting radii etc. (delete the 4 semi-colons) to generate fresh data, and scatter-plots can be obtained by deleting the #; .
<lang racket>#lang racket
<lang racket>#lang racket
(require math/distributions plot)
(require math/distributions math/statistics plot)


(define dxs '(-0.533 0.270 0.859 -0.043 -0.205 -0.127 -0.071 0.275 1.251 -0.231
(define radii (map abs (sample (normal-dist 0 1) 100)))
-0.401 0.269 0.491 0.951 1.150 0.001 -0.382 0.161 0.915 2.080 -2.337
(define angles (sample (uniform-dist (- pi) pi) 100))
0.034 -0.126 0.014 0.709 0.129 -1.093 -0.483 -1.193 0.020 -0.051
0.047 -0.095 0.695 0.340 -0.182 0.287 0.213 -0.423 -0.021 -0.134 1.798
0.021 -1.099 -0.361 1.636 -1.134 1.315 0.201 0.034 0.097 -0.170 0.054
-0.553 -0.024 -0.181 -0.700 -0.361 -0.789 0.279 -0.174 -0.009 -0.323
-0.658 0.348 -0.528 0.881 0.021 -0.853 0.157 0.648 1.774 -1.043 0.051
0.021 0.247 -0.310 0.171 0.000 0.106 0.024 -0.386 0.962 0.765 -0.125
-0.289 0.521 0.017 0.281 -0.749 -0.149 -2.436 -0.909 0.394 -0.113 -0.598
0.443 -0.521 -0.799 0.087))


(define dxs (map (r theta) (* r (cos theta))) radii angles))
(define dys '(0.136 0.717 0.459 -0.225 1.392 0.385 0.121 -0.395 0.490 -0.682 -0.065
0.242 -0.288 0.658 0.459 0.000 0.426 0.205 -0.765 -2.188 -0.742 -0.010
(define dys (map (λ (r theta) (* r (sin theta))) radii angles))
0.089 0.208 0.585 0.633 -0.444 -0.351 -1.087 0.199 0.701 0.096 -0.025
-0.868 1.051 0.157 0.216 0.162 0.249 -0.007 0.009 0.508 -0.790 0.723
0.881 -0.508 0.393 -0.226 0.710 0.038 -0.217 0.831 0.480 0.407 0.447
-0.295 1.126 0.380 0.549 -0.445 -0.046 0.428 -0.074 0.217 -0.822 0.491
1.347 -0.141 1.230 -0.044 0.079 0.219 0.698 0.275 0.056 0.031 0.421 0.064
0.721 0.104 -0.729 0.650 -1.103 0.154 -1.720 0.051 -0.385 0.477 1.537
-0.901 0.939 -0.411 0.341 -0.411 0.106 0.224 -0.947 -1.424 -0.542 -1.032))

;(define radii (map abs (sample (normal-dist 0 1) 100)))
;(define angles (sample (uniform-dist (- pi) pi) 100))
;(define dxs (map (λ (r theta) (* r (cos theta))) radii angles))
;(define dys (map (λ (r theta) (* r (sin theta))) radii angles))


(define (funnel dxs dys rule)
(define (funnel dxs dys rule)
(let ([x 0] [y 0])
(let ([x 0] [y 0])
(for/list ([dx dxs] [dy dys])
(for/fold ([rxs null] [rys null])
([dx dxs] [dy dys])
(let ([rx (+ x dx)]
(let ([rx (+ x dx)]
[ry (+ y dy)])
[ry (+ y dy)])
(set! x (rule x dx))
(set! x (rule x dx))
(set! y (rule y dy))
(set! y (rule y dy))
(vector rx ry)))))
(values (cons rx rxs) (cons ry rys))))))


(define (experiment label rule)
(define (experiment label rule)
(define (p s) (real->decimal-string s 4))
(displayln label)
(plot (points (funnel dxs dys rule))
(let-values ([(rxs rys) (funnel dxs dys rule)])
(displayln label)
#:x-min -15 #:x-max 15 #:y-min -15 #:y-max 15))
(printf "Mean x, y : ~a, ~a\n" (p (mean rxs)) (p (mean rys)))
(printf "Std dev x, y : ~a, ~a\n" (p (stddev rxs)) (p (stddev rys)))
(printf "x: min .. max: ~a .. ~a\n" (p (apply min rxs)) (p (apply max rxs)))
(printf "y: min .. max: ~a .. ~a\n\n" (p (apply min rys)) (p (apply max rys)))
#;(plot (points (map vector rxs rys)
#:x-min -15 #:x-max 15 #:y-min -15 #:y-max 15))))

(experiment "Rule 1:" (λ (z dz) 0))
(experiment "Rule 2:" (λ (z dz) (- dz)))
(experiment "Rule 3:" (λ (z dz) (- (+ z dz))))
(experiment "Rule 4:" (λ (z dz) (+ z dz))) </lang>

{{output}}
<pre>
Rule 1:
Mean x, y : 0.0004, 0.0702
Std dev x, y : 0.7153, 0.6462
x: min .. max: -2.4360 .. 2.0800
y: min .. max: -2.1880 .. 1.5370

Rule 2:
Mean x, y : 0.0009, -0.0103
Std dev x, y : 1.0371, 0.8999
x: min .. max: -4.4170 .. 2.4490
y: min .. max: -2.4380 .. 1.9190

Rule 3:
Mean x, y : 0.0439, -0.0063
Std dev x, y : 7.9871, 4.7784
x: min .. max: -12.5600 .. 12.5840
y: min .. max: -8.2830 .. 8.2670


Rule 4:
(experiment "Rule 1" (λ (z dz) 0))
Mean x, y : 3.1341, 5.4210
(experiment "Rule 2" (λ (z dz) (- dz)))
Std dev x, y : 1.5874, 3.9304
(experiment "Rule 3" (λ (z dz) (- (+ z dz))))
x: min .. max: -0.5330 .. 6.6800
(experiment "Rule 4" (λ (z dz) (+ z dz)))</lang>
y: min .. max: -0.0370 .. 12.1490
</pre>

Revision as of 10:24, 10 June 2013

Deming's funnel is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

W Edwards Deming was an American statistician and management guru who used physical demonstrations to illuminate his management teachings. In one such demonstration he dropped multiple marbles through a funnel at a target, marking where they landed, and observing the resulting pattern. A sequence of "rules" are tested to try to improve performance. In each case, the experiment begins with the funnel positioned directly over the target.

  • Rule 1: The funnel remains directly above the target.
  • Rule 2: Adjust the funnel position by shifting the target to compensate for the miss. If the last shot missed 1 cm east, move the funnel 1 cm to the west of its current position.
  • Rule 3: As rule 2, but first move the funnel back over the target, before making the adjustment. E.g. If the funnel is 2 cm north, and the marble lands 3 cm north, move the funnel 3 cm south.
  • Rule 4: The funnel moves directly over the last place a marble landed.

Task: Apply the four rules to the set of 50 pseudorandom displacements provided as dxs and dys (e.g in the Racket solution). Output: calculate the means, standard-deviations, min and max values of x and y for each rule.

Stretch 1: Generate fresh pseudorandom data. The radial displacement of the drop from the funnel position is given by a Gaussian distribution (standard deviation is 1.0) and the angle of displacement is uniformly distributed.

Stretch 2: Show scatter plots of all four results.

Further information

Racket

The stretch solutions can be obtained by uncommenting radii etc. (delete the 4 semi-colons) to generate fresh data, and scatter-plots can be obtained by deleting the #; . <lang racket>#lang racket (require math/distributions math/statistics plot)

(define dxs '(-0.533 0.270 0.859 -0.043 -0.205 -0.127 -0.071 0.275 1.251 -0.231

             -0.401 0.269 0.491 0.951 1.150 0.001 -0.382 0.161 0.915 2.080 -2.337 
             0.034 -0.126 0.014 0.709 0.129 -1.093 -0.483 -1.193 0.020 -0.051
             0.047 -0.095 0.695 0.340 -0.182 0.287 0.213 -0.423 -0.021 -0.134 1.798
             0.021 -1.099 -0.361 1.636 -1.134 1.315 0.201 0.034 0.097 -0.170 0.054 
             -0.553 -0.024 -0.181 -0.700 -0.361 -0.789 0.279 -0.174 -0.009 -0.323
             -0.658 0.348 -0.528 0.881 0.021 -0.853 0.157 0.648 1.774 -1.043 0.051 
             0.021 0.247 -0.310 0.171 0.000 0.106 0.024 -0.386 0.962 0.765 -0.125 
             -0.289 0.521 0.017 0.281 -0.749 -0.149 -2.436 -0.909 0.394 -0.113 -0.598
             0.443 -0.521 -0.799 0.087))

(define dys '(0.136 0.717 0.459 -0.225 1.392 0.385 0.121 -0.395 0.490 -0.682 -0.065

             0.242 -0.288 0.658 0.459 0.000 0.426 0.205 -0.765 -2.188 -0.742 -0.010 
             0.089 0.208 0.585 0.633 -0.444 -0.351 -1.087 0.199 0.701 0.096 -0.025 
             -0.868 1.051 0.157 0.216 0.162 0.249 -0.007 0.009 0.508 -0.790 0.723
             0.881 -0.508 0.393 -0.226 0.710 0.038 -0.217 0.831 0.480 0.407 0.447
             -0.295 1.126 0.380 0.549 -0.445 -0.046 0.428 -0.074 0.217 -0.822 0.491 
             1.347 -0.141 1.230 -0.044 0.079 0.219 0.698 0.275 0.056 0.031 0.421 0.064
             0.721 0.104 -0.729 0.650 -1.103 0.154 -1.720 0.051 -0.385 0.477 1.537 
             -0.901 0.939 -0.411 0.341 -0.411 0.106 0.224 -0.947 -1.424 -0.542 -1.032))
(define radii (map abs (sample (normal-dist 0 1) 100)))
(define angles (sample (uniform-dist (- pi) pi) 100))
(define dxs (map (λ (r theta) (* r (cos theta))) radii angles))
(define dys (map (λ (r theta) (* r (sin theta))) radii angles))

(define (funnel dxs dys rule)

 (let ([x 0] [y 0])
   (for/fold ([rxs null] [rys null])
     ([dx dxs] [dy dys])
     (let ([rx (+ x dx)]
           [ry (+ y dy)])
       (set! x (rule x dx))
       (set! y (rule y dy))
       (values (cons rx rxs) (cons ry rys))))))

(define (experiment label rule)

 (define (p s) (real->decimal-string s 4))
 (let-values ([(rxs rys) (funnel dxs dys rule)])
   (displayln label)
   (printf "Mean x, y    : ~a, ~a\n" (p (mean rxs)) (p (mean rys)))
   (printf "Std dev x, y : ~a, ~a\n" (p (stddev rxs)) (p (stddev rys)))
   (printf "x: min .. max: ~a .. ~a\n" (p (apply min rxs)) (p (apply max rxs)))
   (printf "y: min .. max: ~a .. ~a\n\n" (p (apply min rys)) (p (apply max rys)))
   #;(plot (points (map vector rxs rys)
         #:x-min -15 #:x-max 15 #:y-min -15 #:y-max 15))))

(experiment "Rule 1:" (λ (z dz) 0)) (experiment "Rule 2:" (λ (z dz) (- dz))) (experiment "Rule 3:" (λ (z dz) (- (+ z dz)))) (experiment "Rule 4:" (λ (z dz) (+ z dz))) </lang>

Output:
Rule 1:
Mean x, y    : 0.0004, 0.0702
Std dev x, y : 0.7153, 0.6462
x: min .. max: -2.4360 .. 2.0800
y: min .. max: -2.1880 .. 1.5370

Rule 2:
Mean x, y    : 0.0009, -0.0103
Std dev x, y : 1.0371, 0.8999
x: min .. max: -4.4170 .. 2.4490
y: min .. max: -2.4380 .. 1.9190

Rule 3:
Mean x, y    : 0.0439, -0.0063
Std dev x, y : 7.9871, 4.7784
x: min .. max: -12.5600 .. 12.5840
y: min .. max: -8.2830 .. 8.2670

Rule 4:
Mean x, y    : 3.1341, 5.4210
Std dev x, y : 1.5874, 3.9304
x: min .. max: -0.5330 .. 6.6800
y: min .. max: -0.0370 .. 12.1490