**************************************************
	MADMONK - GEM Text Travesty Generator
		(c) 1988 
	Don E. Farmer
	16810 Deer Creek Dr.
	Spring, TX 77379

	This is SHAREWARE.  It is not to be sold.
	A donation of $5.00 is requested, please.
**************************************************


                   GEM Text Travesty Generator
  

     Have you ever felt mimsy?   Not sure?   Perhaps you could ask 
  
the  borogoves.   But then they may not answer because the  slithy 
  
toves did gyre and gimble in the wabe.   These nonsense words  are 
  
from   Lewis   Carroll's  poem  "Jabberwocky."    This   judicious 
  
juxtaposition  of letters is fun.   Maybe the author of  Alice  in 
  
Wonderland had a travesty generator!
  
     Generating travesties arose, perhaps, from a pronouncement by 
  
Sir  Arthur Eddington at Cambridge in 1927:        


     "If  an  army of monkeys were strumming on  typewriters  they 
  
     might write all the books in the British Museum."

  
William Ralph Bennett, Jr. gives an account of this in his chapter 
  
on Language in Scientific and Engineering Problem-Solving with the 
  
Computer,  Prentice  Hall  1976.   He  terms it  "monkeys  at  the 
  
typewriters."  I do not know who coined the term "travesty."
  
     MADMONK is a GEM based travesty generator.   I have tried  to 
  
make its use self-evident with a HELP menu.   I would like for you 
  
to try the program now.   You can come back to the following  text 
  
later.  I fear that once I use the term probability matrix some of 
  
you  will think the program too mathematical and never give  it  a 
  
chance.  For some fun you will need only a text file with which to 
  
make  a travesty.   

     Using Eddington's analogy, each of MADMONK'S typewriters have 
  
27 keys,  the letters A though Z and the space key.   If all  keys 
  
are equally probable, the typed output is termed zero order.  This 
  
merely exercises the random number generator, the monkeys.  Higher 
  
order travesties require an input text.  

     A  first  order travesty is one in which the output  text  is 
  
correlated to the frequency of each letter in the input text.  The 
  
higher  order travesties are generalizations of the  first  order.  
  
So let's concentrate on the first order.   

     Suppose  the  input  text  is  one  of  Shakespeare's  plays.  
  
MADMONK  reserves 27 places in memory to store the count  of  each 
  
letter as it is read.   Allow me an analogy.   Imagine a road with 
  
27  bridges.   The distances between the bridges  varies  greatly, 
  
analogous to the letter count.   The natives who live between  the 
  
bridges speak differing languages each of which consists of only a 
  
single letter.   (I guess the ones who "speak a space" say nothing 
  
at  all.)  Suppose you are at the start of this road and  plan  to 
  
drive  a certain distance to a friend's house.   Since you're  not 
  
sure just how far it is,  you stop and ask a fellow on the side of 
  
the road.   Now this fellow who happens to know your friend, alas, 
  
has  terrible  number sense.   In essence he gives  you  a  random 
  
number.   So  you drive this distance and instead of finding  your 
  
friend,  you  find  people who speak only  the  letter  'L',  say.  
  
Thinking  you've erred,  you go back to the start of the road  and 
  
ask the stranger again, get another random distance to travel, and 
  
come  up  with yet another letter.   If you were  to  continue  to 
  
retrieve  letters  in this manner,  they would spell out  what  is 
  
termed a first order Shakespearean travesty.
  
     Mathematically speaking,  these numbers,  the letter count or 
  
the  distances  between the bridges,  form a 1  x  27  correlation 
  
matrix.   One  dimensional matrices are called vectors,  and  when 
  
there  is  nothing to correlate with,  the components  are  called 
  
frequencies.
  
     A  second order travesty is one in which the output  text  is 
  
correlated to the frequency of letter pairs in the input text.  In 
  
other words,  MADMONK counts the number of AA's, AB's, ... , ZZ's, 
  
...  ,  <space><space>'s  in the input text.   This results  in  a 
  
correlation matrix,  one with 27 rows and 27 columns.   The matrix 
  
requires 2,916 bytes.   That is (2*27)*(2*27),  each element being 
  
an unsigned 16 bit integer.   Using a hard disk it takes about  12 
  
seconds to do a travesty on 3K input file.   All output travesties 
  
consist of 10,000 characters.   If more is needed,  MADMONK can be 
  
run again and the output files merged with a text editor.
  
     A  third  order travesty is one in which the output  text  is 
  
correlated to the frequency of letter triplets in the input text.
  
The  probability matrix is 27 x 27 x 27,  which  requires  157,464 
  
bytes.  About 50 seconds are required to do a 3K input file.

     A  fourth order travesty is one in which the output  text  is 
  
correlated  to  the frequency of letter quadruplets in  the  input 
  
text.   "THE<space>" and "<space>AND" are common quadruplets.  The 
  
matrix is 27 x 27 x 27 x 27.   But (2*27) raised to the 4th  power 
  
is 8,503,056.  Eight megabytes exceed the memory of most machines.  
  
It is possible, of course, to use the hard disk as storage.  There 
  
is, however, a speed penalty to pay.  I chose another alternative.  
  
At  this  point I changed the element size of the matrix  from  16 
  
bits to 8 bits.   Since 27 raised to the 4th power is  531,441,  a 
  
one megabyte machine can store the matrix.   However,  with only 8 
  
bits  the size of the input text is limited.   If there  are  more 
  
than 255 "the's" or "and's", for example, in the input text, the 8 
  
bit matrix elements will overflow.   MADMONK will warn you if this 
  
happens.  It takes about 3 minutes to do a 3K input file.
  
     A  fifth  order travesty is one in which the output  text  is 
  
correlated to the frequency of letter quintets in the input  text.  
  
Raising 27 to the 5th power yields 14,348,907.   So a 16  megabyte 
  
partition on the hard disk drive could hold the matrix.   There is 
  
another  alternative.   A fifth order matrix can  be  approximated 
  
with two fourth order ones.   In years past I have approximated  a 
  
third  order matrix with two second order ones.   This was when  I 
  
worked  with a computer that had only 4K of main memory  and  tape 
  
drives.  I must not have been too pleased with the results because 
  
I no longer have my notes.   For now I can only say that the fifth 
  
order travesty is in my in basket.
  
     The mathematical details of how these matrices are built from 
  
the input text and how the output text is constrained to match the 
  
probability  spectrum  are  open  to view in  the  C  source  code 
  
listing.   Scoping  precludes further elucidation on either the  C 
  
language or probability theory.   (Cryptic, enough?)  I do hope my 
  
analogy   of   the  first  order  was  helpful   to   those   less 
  
mathematically inclined.
  
     It  is  time to end the discussion on how MADMONK  works  and 
  
move on to hint at what feeling mimsy is all about.   Or to put it 
  
another way, what do you do with a travesty anyway?
  
     How intelligible a travesty is, as you have seen from running 
  
MADMONK, depends on the order.  It also depends on the input text.  
  
Travesties  on  different  authors  yield  different   correlation 
  
matrices.   Identifying  unknown  or  disputed  authors  with  the 
  
computer entails doing certain statistics on these matrices.  With 
  
some authors you get words, with others you get complete sentences 
  
that  might interest the borogoves.   Shakespeare  travesties  are 
  
vulgar.  The thought has crossed my mind to send one off to a smut 
  
peddler.   Just a fleeting thought!   Yet in a travesty of  Surely 
  
You're Joking Mr.  Feynman! profanity is rare.  On the surface the 
  
styles  of  the two authors do not seem to differ  that  much.   I 
  
choose to leave the word "style" undefined.   (Technically,  there 
  
is a homeomorphism between thermodynamics and information  theory.  
  
This  means that you can talk about letter entropy.)  As  a  final 
  
hint, MADMONK can lead you to a land, where I hope you don't think 
  
this article has already led you, Cryptogamica.  Seriously though, 
  
the  monkeys  don't care whether its English  or  Russian  they're 
  
typing.  (I can't tell you more because it's TOP SECRET.)


*******************************************************************
The text above was written some time ago.  There is a serious side
to all of this, and it has to do with entropy and language.  I am
interested in travesties because I have been exploring how much
randomness there is in creativity for many years now.  I think there
is a lot.
MADMONK V1.3 PD, as presently stands, is robust.  I am now looking
at the generation of morphenes, i.e., "pieces" of words that are more
than letters yet not quite words but of which words are made out of.
There are many more of these than letters, but you also get a more
"meaningful" travesty too.  Well, have fun with this.
