top of page
Search
Writer's pictureonur güneş

Python Simulation of Deming’s Funnel Experiment

Updated: Oct 7, 2021

Yet another simulation work of mine!


It’s been almost a year since I decided to develop coding skills. As you well remember my first work was Simulation of Monty Hall Problem. Thanks to the Pandemic, I had lots of time to improve those skills and I am happy to share my other “stunning” simulation work with you, folk! When I first learned about this experiment, I was really stunned and wanted to see it with my own eyes. For me, it was also a great opportunity to learn the Matplotlib module and enjoy coding another simulation. Hope you enjoy it too!


What is Deming’s Funnel Experiment?


Edwards Deming is an American mastermind who is known for his studies in engineering, statistics and most importantly quality management areas.

Dr. Deming conducted a series of experiments to show how over-controlling(“tampering”) may harm your process. By its nature, every process involves variation. However, what matters is that you should know how to deal with this variation. Although implementing Taguchi Method is a better way to eliminate variation and build robust design, it is not always applicable or easy. A manager may believe that workers may solve the problem easily by adjusting process parameters continuously; instead of doing fancy quality techniques. By adjusting parameters daily based on the last piece of information and results, this manager can only get daily achievements at best. Now let us see why we should not rely on daily findings instead of relying on control charts and the robust design understanding.


In the experiment, you drop a marble to the sheet by the aid of a funnel. After marble hits the sheet it will roll for some distance until it stops. You mark the spot where marble stops, and the experiment continues with four different rules of corrections to “control” the process. Each correction will have a different distribution morphology throughout the iterations.


At this point it is important to clarify my model. After marble is dropped from the funnel, it can move along the x and y axis of the sheet. For each axis, it can be said that marble will follow a Gaussian distribution. Marble is more likely to stop closer to the target. Farther the point from the target, less likely to be observed.


There are 4 adjustment rules:


Rule 1: In this rule, action is quite straightforward. The funnel stays in the same position(origin) throughout the experiment. Marble is dropped many times (let’s say 2,000 times) without moving the funnel and each drop is marked on the sheet. In the end, what you will get is a spherical shape on the sheet. In the below figure you can see the spherical distribution of marble drops for 2000 times.




Rule 2: In the first rule, we did not make any adjustment to correct the process. However, after the first drop we may think it would be wise to adjust the funnel position(target) compensate the deviation from the origin. As the experiment continues, by looking the distance between the last stop and the origin we will move the funnel a distance in the opposite direction from the funnel’s last position. Here is a real-life example for this correction; Olympic Gold Medalist Mete Gazoz wants to shoot arrows to the center as much as possible. After the first shot, Mete realised that he was 1 cm above the target. One may think that due to the atmospheric factors, the first shot was deviated and the next shot will also be deviated 1 cm above the last target. Therefore, Mete could conclude that the process can be corrected by aiming 1 cm below the last target. However, one should also remind that wind always changes direction and intensity, so that it may not always cause 1 cm deflection to the above. In the below figure, we see that this correction also generates spherical distribution, but the difference is that points are scattered more and area is increased 50%. In other words, variation in the process is increased, which we do not want at all. However, Mete did not follow this technique and as a result he won the Gold Medal.



Rule 3: In this rule, correction is quite similar to one we done in Rule 2. Again, we are adjusting the funnel according to distance between origin and the last stop of the marble. However, instead of moving the funnel from its last position, we will try to compensate the deflection with respect to origin. I know it is a little bit confusing by comparing with the Rule 2. In both rules we are looking the deviation between last drop and the origin. However, in Rule 2 we move the funnel from its last position, whereas in Rule 3 we bring the funnel back to the origin and then move accordingly to compensate last deviation. Let me illustrate this rule by an example; a country decided to invest on warfare arming due to national security concerns. As a result, neighbour country will consider this act as a threat, and it will also start to armament for a possible war. This arms race will continue forever. The more powerful weapons a side have, the more neighbours will try to strengthen their army. In the below figure, we see that distribution grew in two quadrants and goes for infinity. In the previous rules; although we had variation in processes, they can be said to have a limit. However, Rule 3 has no limit and the distribution is out of control.



Rule 4: The rule 4 suggests that after the drop, the funnel should be adjusted to the position where marble stops each time. This situation can be explained by the childhood game “Chinese Whispers”. In the game, players line up in a row and the first player whispers the sentence to the second player. However, second player may misunderstand the sentence partially or completely. Therefore, after each iteration the sentence is distorted a little bit. At the end of the row, final sentence is often funny and very much different than the first sentence. In the below figure, you can see how results escalate from the origin. In rule 4 -similar to rule 3- again we have an out of control distribution that goes for infinity.



My Python Code for the Simulation:

import random
import imageio
import matplotlib.pyplot as plt
r2x = 0
r2y = 0
r3x = 0
r3y = 0
r4x = 0
r4y = 0
rep=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,40,80,120,160,200,300,400,600,800,1200,1600,2000]
##Rule 1
images = []
fig,ax =plt.subplots()
ax.set_xlim([-0.5,0.5])
ax.set_ylim([-0.5,0.5])
for i in range(0,2000):
        d1x=random.gauss(0,0.01)
        d1y=random.gauss(0,0.01)
        ax.scatter(d1x, d1y, c='#1f77b4', s=15)
        ax.scatter(0,0, c='r', s=20)
        if i in rep:
            plt.savefig('DFE/Rule 1/rule1-{}'.format(i))
            images.append(imageio.imread('DFE/Rule 1/rule1-{}.png'.format(i)))
imageio.mimsave('DFE/Rule 1/rule1.gif', images)
##Rule 2
images = []
fig,ax =plt.subplots()
ax.set_xlim([-0.5,0.5])
ax.set_ylim([-0.5,0.5])
for i in range(0,2000):
        d2x=random.gauss(r2x,0.01)
        d2y=random.gauss(r2y,0.01)
        ax.scatter(d2x, d2y, c='#1f77b4', s=15)
        temp=ax.scatter(r2x, r2y, c='r', s=20)
        r2x=r2x-d2x
        r2y=r2y-d2y
        if i in rep:
                plt.savefig('DFE/Rule 2/rule2-{}'.format(i))
                images.append(imageio.imread('DFE/Rule 2/rule2-{}.png'.format(i)))
        temp.remove()
imageio.mimsave('DFE/Rule 2/rule2.gif', images)
##Rule 3
images = []
fig,ax =plt.subplots()
ax.set_xlim([-0.5,0.5])
ax.set_ylim([-0.5,0.5])
for i in range(0,2000):
        d3x = random.gauss(r3x, 0.01)
        d3y = random.gauss(r3y, 0.01)
        ax.scatter(d3x, d3y, c='#1f77b4', s=15)
        temp=ax.scatter(r3x, r3y, c='r', s=20)
        r3x = -d3x
        r3y = -d3y
        if i in rep:
                plt.savefig('DFE/Rule 3/rule3-{}'.format(i))
                images.append(imageio.imread('DFE/Rule 3/rule3-{}.png'.format(i)))
        temp.remove()
imageio.mimsave('DFE/Rule 3/rule3.gif', images)
##Rule 4
images = []
fig, ax = plt.subplots()
ax.set_xlim([-0.5,0.5])
ax.set_ylim([-0.5,0.5])
for i in range(0, 2000):
        d4x = random.gauss(r4x, 0.01)
        d4y = random.gauss(r4y, 0.01)
        ax.scatter(d4x, d4y, c='#1f77b4', s=15)
        temp=ax.scatter(r4x, r4y, c='r', s=20)
        r4x = d4x
        r4y = d4y
        if i in rep:
                plt.savefig('DFE/Rule 4/rule4-{}'.format(i))
                images.append(imageio.imread('DFE/Rule 4/rule4-{}.png'.format(i)))
        temp.remove()
imageio.mimsave('DFE/Rule 4/rule4.gif', images)

Hope you find those insights and findings valuable.

Thank you for your attention,

Best regards.

137 views0 comments

Recent Posts

See All

Comments


Post: Blog2_Post
bottom of page