Hamming Distance Simulation
written by Crystal Barchet and Teresa Carrigan
- What is it?
- How it works
- How to use it
- Things to notice
- Things to try
- Extending the model
- NetLogo features
- Related models
- Credits and References
- For more information
- Download the model
WHAT IS IT?
This model demonstrates finding the Hamming distance between a set of 4 bit patterns.
HOW IT WORKS
Four random bit patterns are generated. Then, the first two bit patterns are compared and the distance between them is found. Then the first and third patterns are compared, followed by the first and fourth, second and third, second and fourth, and third and fourth. The smallest distance found out of all of the pairs compared is the hamming distance.
HOW TO USE IT
The setup button generates four random bit patterns.The slow-motion slider is an easy way to adjust the speed of the display so you can watch the digits change as the red arrow passes. Set it to zero if you want to just see the answer quickly. 0.4 is a good setting for the first few steps.
The number-of-digits slider lets you choose how many numbers are in each bit pattern.
The step button does whatever step comes next, and then stops so you can take notes.
The go button finishes the entire problem, at a speed set by the slow-motion slider.
The show-again button starts the exact problem from the beginning. You may then click either the step button or the go button to see the same demonstration.
The quiz button generates a random problem and then asks you to determine the answer.
THINGS TO NOTICE
The smallest distance should never be zero. If it is zero, then an error has occured (2 of the bit patterns are the same).
THINGS TO TRY
Set the slow-motion slider to about .4 seconds (or slower) and press the step button a few times. Watch the demonstration of each step.Set the slow-motion slider to about .4 seconds and press the go button. Watch the entire demonstration.
Do each step by hand, then press step to check your work.
EXTENDING THE MODEL
Allow the user to input the beginning four bit patterns.Allow the user to choose the number of bit patterns to be compared.
Allow the user to choose the order that the bit patterns are compared.
NETLOGO FEATURES
"word" is used to put two inputs together and make them a string."any? other-turtles-here" is used to find if there are any turtles in a certain place
RELATED MODELS
CREDITS AND REFERENCES
This model was written by Crystal Barchet and Teresa Carrigan, 2004.Permission to use, modify or redistribute this model is hereby granted, provided that both of the following requirements are followed:
Contact Teresa Carrigan for appropriate licenses for redistribution for profit.
- this copyright notice is included.
- this model will not be redistributed for profit without permission from Teresa Carrigan.
To refer to this model in academic publications, please use: Barchet, C. and Carrigan, T. (2004). Hamming Distance Simulation model. Blackburn College, Carlinville, IL.
In other publications, please use: Copyright 2004 by Crystal R. Barchet and Teresa Carrigan. All rights reserved.
FOR MORE INFORMATION
For more information about Hamming Distance, see one of the following textbooks:
- Null, L. and Lobur, J. Essentials of Computer Organization and Architecture, First Edition, Jones & Bartlett, pages 77-78.
- Murdocca, M. and Heuring, V. Principles of Computer Architecture, First Edition, Prentice Hall, page 360
HomeApplets on this website were written by Teresa Carrigan in 2004, for use in computer science courses at Blackburn College, with the exception of the Fireworks applet. The applets made with NetLogo require Java 1.4.1 or higher to run. The applets made with NetBeans require Java 1.4.2 or higher to run. Applets might not run on Windows 95 or Mac OS 8 or 9. You may obtain the latest Java plugin from Sun's Java site.