Premium Only Content
 
			Probability-based random text generation
In this video I show you a Python implementation of a 1983 article by Brian Hayes from the "Scientific American" magazine called "A progress report on the fine art of turning literature into drivel".
Using weighed probabilities and random number selections, it is possible to generate a mashed up version of an input text.
The simplest data structure to use in this case is a matrix, however, as you'll find out in the video, there are certain limitations.
Links to the article:
- https://www.semanticscholar.org/paper/A-progress-report-on-the-fine-art-of-turning-into-Hayes/066a55a3ca5fa9b38106bb29bcb5c4dd2b30d9e7
- http://bit-player.org/wp-content/extras/bph-publications/SciAm-1983-11-Hayes-drivel.pdf
- https://www.scientificamerican.com/article/computer-recreations-1983-11/
Source code:
Example using "The Complete Works of William Shakespeare" by Project Gutenberg, on 32GB RAM:
```
order: 7
length: 512
seed: 'FAST E'
---
fast eyes into his grave died for a scottish spring my lord are in the banquo o banquo lennox no indeed and he so thou meets and clarence warwick out ripe in my heels for this shall did makes me it sufficient kneels caesars prevent my lips have our dancer speaking forth the word edward of my noble duke's best save my lord a black neer lusts were buried away confidence with the glass yet he hath he bids the marketplace have been is stopp'd protest in thy affairs fram'd and they're welcome my name of hogs antonio y
```
Another example using "Alice's Adventures in Wonderland" by Lewis Carroll
```
time ./generative_web.py 7 256 "https://raw.githubusercontent.com/ElizaLo/Machine-Learning/master/Text%20Generator/alice_in_wonderland.txt"
order: 7
length: 256
seed: 'ACK TO'
---
ack to the thought alice's right eagerly that she was at the fifth bend about like' said the considered audibly what would do to be treacle from the three or might as usual come back at last word two as there's an atom of a tremble all moved on the trial' stupid
---
real 0m1.858s
user 0m1.486s
sys 0m0.220s
```
CHAPTERS
0:00 Intro
0:35 Alphabet selection
1:00 Frequency counting
1:16 Random number selection based on weighed probability (1st order)
1:31 2nd order
1:58 nth order and memory problems
2:43 Sparse matrix as a possible solution to the memory problem
2:58 generative.py script explanation5:08 generative.py script execution
5:31 generative_web.py script explanation
6:24 generative_web.py script execution
6:34 Outtro
#textgeneration #python #matrix
- 	
				 2:52:28 2:52:28TimcastIRL4 hours agoSTATE OF EMERGENCY Declared Over Food Stamp CRISIS, Judge Says Trump MUST FUND SNAP | Timcast IRL190K108
- 	
				 DVR DVRTundra Tactical10 hours ago $14.20 earned🚨Gun News and Game Night🚨 ATF Form 1 Changes, BRN-180 Gen 3 Issues??, and Battlefield 6 Tonight!21.4K
- 	
				 1:45:13 1:45:13Glenn Greenwald7 hours agoJD Vance Confronted at Turning Point about Israel and Massie; Stephen Miller’s Wife Screams “Racist” and Threatens Cenk Uygur with Deportation; Rio's Police Massacre: 120 Dead | SYSTEM UPDATE #54098.3K103
- 	
				 LIVE LIVESpartakusLIVE4 hours agoSpart Flintstone brings PREHISTORIC DOMINION to REDSEC279 watching
- 	
				 1:05:02 1:05:02BonginoReport7 hours agoKamala CALLED OUT for “World Class” Deflection - Nightly Scroll w/ Hayley Caronia (Ep.167)118K69
- 	
				 54:36 54:36MattMorseTV5 hours ago $0.41 earned🔴The Democrats just SEALED their FATE.🔴52.4K93
- 	
				 8:07:01 8:07:01Dr Disrespect12 hours ago🔴LIVE - DR DISRESPECT - ARC RAIDERS - SOLO RAIDING THE GALAXY137K12
- 	
				 1:32:00 1:32:00Kim Iversen8 hours agoThe World’s Most “Moral” Army — Kills 40 Kids During "Ceasefire" | Socialism's Coming: The Zohran Mamdani Agenda108K180
- 	
				 1:04:50 1:04:50TheCrucible7 hours agoThe Extravaganza! EP: 63 with Guest Co-Host: Rob Noerr (10/30/25)89.3K8
- 	
				  GritsGG6 hours agoQuads! #1 Most Wins 3880+!41.3K4