To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This application was written to prove (partly, atleast) the infinite monkey theory.
Description
Firstly, a bit of mind-boggling background...
The infinite monkey theorem states that a single monkey hitting random keys on a typewriter, for an infinite amount of time, will eventually type the complete works of William Shakespeare (or any given text for that matter!!).
Although purely academic, this theory is used to illustrate the awesome power of infinity. The probability of a monkey exactly typing the complete works of Shakespeare is so tiny that the chance of it occurring during a period of time (even a thousand orders of magnitude longer than the age of the universe) is extremely low, but it's not actually zero. Therefore, given an infinite period of time, a monkey rewriting the complete works of Shakespeare is not just a possibility, it’s an inevitability!!
In this context the "monkey" is not an actual monkey (as 1. monkeys have finite lifetimes and 2. This would surely be animal cruelty), but a metaphor for an abstract device that produces a random sequence of letters and symbols forever.
Requirements
Steps to Implement or Execute Code
Additional Information or References
Front Panel
VI Snippet
IMPORTANT: To begin with, I would suggest typing a maximum of 4 characters (you can try additional characters afterwards)
Then hit the run arrow (or hit ctrl + R, if you are lazy like me)
Wait a few seconds as our virtual monkey furiously types random letters on its virtual typewriter. Eventually, our friendly, little virtual monkey will have typed your exact sequence of ascii characters.
Extra Feature: if you place a tick in the “Show Info” checkbox, then you will be greeted with an info-box on the completion of the typed text. The pop-up with explain how long our tireless virtual monkey would have taken to type your requested text, assuming he typed at a speed of one character per second.
As a truer test, I requested the monkey to type “to be or not to be”. This is a relatively long sentence, so I had to leave the application running on my work station over the weekend (please don’t tell our IT team). As you will see in the following screen capture, it took a very, very long time!
Effectively it took 15,241 years for the monkey to type just 6 words from a single Shakespeare play. There are a combined total of 884,429 words in Shakesperes 43 plays.
Wow! Infinity is both Big and Clever!!
As a final technical point, it appears that I have committed a cardinal sin - placing front panel objects over an image. This is NOT the case! On the front panel, I have split the image into sections, and the front panel objects are placed directly on to the pane (...which I have painted brown).
Please note: no monkeys were harmed in the development of this application!
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.