Richard Anderson - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

Richard Anderson

Description:

What is a random monster name? What methods were used to generate the name? ... Fine, legaj sed nin aparte la jam Vendredos fine, estis la sed ni diris, Je ... – PowerPoint PPT presentation

Number of Views:169
Avg rating:3.0/5.0
Slides: 35
Provided by: RichardA171
Category:

less

Transcript and Presenter's Notes

Title: Richard Anderson


1
Richard Anderson
  • Random thoughts on Randomness for SIGCSE 2005

2
Randomness in Introductory Computing
  • Understanding randomness requires mathematical
    precision
  • How to, and how not to, generate random
    permutations
  • Randomness can be used generate realistically
    appearing outputs
  • Many practical applications
  • Very engaging assignments
  • Example generating random text

3
The cost of not getting things right
  • Intel Division Bug
  • Ariane 5 Rocket
  • Windows security holes
  • Central problem for Computer Science Education
    Give students tools and sense to get things
    right

4
Randomness is Subtle
  • Reasoning about random processes is often
    incorrect
  • Formal arguments often needed
  • Example problem Generate a random permutation
    given an array A of length n, permute its
    elements so each permutation has probability
    exactly 1/n!

5
Text book code
Random generator new Random() for (int i 0
i lt 52 i) int j Math.abs(generator.nextInt(
)) 52 // swap the two card values Object
temp thePile.elementAt(i) thePile.setElementAt
(thePile.elementAt(j), i) thePile.SetElementAt(t
emp, j)
6
Incorrectness Proof
  • Consider an array of size 3
  • Random sequence generated (x1,x2,x3)
  • Number of possible sequences 3327
  • Number of permutations 6

7
Java Library Code
public static void shuffle(List list, Random
rnd) int size list.size() for (int i
size i gt 1 i--) swap(list, i-1,
rnd.nextInt(i))
8
Use of Randomness for Generation
  • Many applications for generating realistic
    outputs
  • Animation
  • Games
  • Test programs
  • Illustrations
  • Nifty homework assignment generate a random X

9
Random Text
  • Generate random words for a language words
    that look real
  • Generate random text for a language
  • Class exercise (Index cards provided)
  • Generate a random name for a new class of monster

10
Questions
  • What is a random monster name?
  • What methods were used to generate the name?

11
Approaches to word generation
  • Template based
  • Production rules
  • Generate and test
  • Finite state machine
  • Random selection from list

12
Generating random text
A Stance. Sured for at stic. Stanger flice, to a
clearts, will was he experpen spoke almostly. A
might, the room, an every live was heaving ins,
busybody of the sing hand morth can quire, time
and abore that, answered to my dring given you
and end, drived his away they were could of there
view detainelses had into for surmistling. To the
which fount every ver. Drebber have roughter soon
be swell. It with he must mout the circume
longer, you with that that hard, the was
thoughten came is vorations no comes. Fourwhen
curied manionsible rooms to fine. Not be diss.
You articall neithe minut upon over way. I
ejacult Lation the the was with you secomes it
ever hung room, and step inties irong. The lone
old far peoplet of to the his so who hat I to had
ling hearnes. I led. Ther Mr. No publity abr
13
Random German
Phnomentgegentworingt, ung kannteils das Ersche
sage, die Gebornehmeckenlose Werder sche
alleichkeits eins hat sich gen Willendem Dasein
absolches Bestig an in ist ein die Umfangenwrtier
Gegen, unen darin die ist nur als bleicheit, das
Anterganissen Einzelnderlicht von und das Leeres
Ich in Geser von ist die Beziehung, enterschiede,
darin des teils absolute Wurz erhltnischie, das
Gedankonstndividualischwinn erzeugung des
allgemeine Subststndividualitat dernung deres
Gemerzeugung ind and so fllt die Norden es hatte
Forteigente dennbar als aus sein ist, in Selbare
Damige Weser Natur das rastandenn es liegen er
Erschafte des in philosenheit dem Unglitte, dem
eben hattfinden. Dies Gegens offen Ansibilitt
istigen die Muttelbe bestigen Prfung dem, wesen
erkehren Gegen Untens nimmensosehr als fas
14
Random Latin
Publatoniunguias, animum fiduo proculos mem dolii
stu, quis. Turnia culiqui priminis omnipatris et
laceae fectus saxa donatis. Adium ad arre silva
res circum eductum domo armos infando sus
harentem Itale Corris impo, Titatit acis habeat
ungentem per Achisaequi que rebant, lausa
Zacyntis inclami iuxtaque ac tibus, innostro
secabat amor urbesaucialido currus efficis atque
omnemunum currundam, quid tem spes gens in temque
gens, quo domus et per ad licet aud notusque
pugnis constisque rum, quantque fidum Sistigat,
homina subi ausi clas tem nectibi aut cerdor haud
tantibus pugnavissi nivertunam manta fortantque
et, quoque Abantiamul longa oppitor extraemi
cornus, quod te regemitam exsti mille tibus sub
ardanimillo indus atque hae, loca haudibus ad
tutatus sivello dignem. Mihi formiseserum crum
15
Random Esperanto
La unu mortiri insulo tio naj portigxulongxi nun
manojn. Malsen sklavo, ke laux de li malgxo
metigxis. Sed miajnojn tremo kaj amikoj. Jen
zorgauxebla talegis li al Zuro, ke Jafojektre ili
aux kaux domoj, panarolitan atingis iom da estu
juna ankonto plu reveniajn ventis tute gxis, ke
iris sia fara, ke ili birdon timando. Majo.
Vilhelmontegmenas la terojn por mecon povus
timili aux auxdis prenligi tiujncxi
murmultereokazo den. La kam ne ekpreniradis, Cxu
vi sed varmis, ke de la longtempo esti iris havu
sklarmilo ne por spacete, ni al Dio, kie da
prenoj bruo, lokonte nigrandonaton, ellas nun,
kaj mia grenis, la certe tio devas ke la sovas mi
krii, tiam da sur la voki li ol tiel la Skoto.
Dio kaj mortigxojn la trajdis. Fine, legaj sed
nin aparte la jam Vendredos fine, estis la sed ni
diris, Je
16
Non-random Esperanto
La viro, kies sxipo subakvigxis, diris kun grava
mienoJunulo, ne iru plu surmaron tiu ne estas la
vivmaniero por vi. Kial do, sinjoro, vi mem iros
plu surmaron Tiu estas alia afero. Mi estas
elnutrita por la maro, sed vi ne estas vi venis
sur mian sxipon por eltrovi, la staton de vivo
surmara, kaj vi povas diveni tion, kio okazos al
vi, se vi ne reiros hejmon. Dio ne benos vin, kaj
eble vi kauxzis tiuncxi tutan malbonon al ni. Mi
ne parolis alian vorton al li, kiun vojon li
iris, mi nek scias, nek deziris sciigxi, cxar mi
estis ofendita pro tiucxi malgxentila parolado.
Mi multe pensis cxu iri hejmon, aux cxu iradi
surmaron. Honto detenis min pri iri hejmon, kaj
mi ne povis decidi la vivkuron, kiun mi estis
ironta. Kiel estis mia sorto travive, cxiam
elekti la plej malbonon tiel same mi nun faris.
Mi
17
Generating Random Text
  • Letter distribution should match language
  • Word length, punctuation should match language
  • Simple attempt random strings with probability
    derived from language

18
Letter distribution
A of rs deveastorere ghinswalmporthokioutt mmede
hug thed I fte g blagrs h thtr. htho t is nd
ppatiestath. o I sis te t. s hoomooure t
pryoucly, polat hir h I fuetamede s hed a on h s
d t s hy imaillabe c o ted tathe hedenirngh
wintht Le f inced a ly I t pe byose ollfrnd
inofaps ron a I h is Leantond as, t oasir
meromisebe omider ceshed hiaidinte waritingithe t
t hofon Papoug bthe as I o clld
stoapithraureninto waredrkerd t Cow, oreed
todviron td connce, avily d. thicos, I wis barem
J. n d he tha be rerid m asethaler onorrid icik
tolk imene, heewny wiccere ondy. ongut lwaghes t
wo t w he vemied hay I sst d t a this. cis, t
catimby d gusithai he w tlef rewile thed w s mng
fagrio thued apo d the menck ld iong s h hous whe
id I fenowe t Yotig obad Whep iody, d abry. cound
rad ily thicthes the
19
Bigram models
  • Generate strings with correct conditional
    distribution P(ab)
  • Record distribution on ordered pairs of characters

20
Doyle (2)
A muld pince whispe. Froser reed. Docklid.
Salmeted an and to trattly the he ch roccolve
tomme, look hick Hoposper swerected, wily. He
alfs forectit wer of dis weringeaver thison is
ruche to broo, sat havenithat enee lodereen,
alcurectictles the be byean wes youghathis the
overying be yettelsoter his upoly he had frile
und wit torcile to he has saw of son mong.
Loonlecing, hichabox if therebbegras antive had
ison. Yould ing got theres ention ity ling. Wat
led im, hor of cally bect the inswelin lith
aressidaugh my oung. I his didead to the
facriverebad of the pon. Yeles, I cre wrind
frathe doothe sed cong rat Dr. Prot inglace was
brown thathere seve, sainvidealle
obectlestratempargaidich It th and it theart acry
createep teureas nousee layin ass wo he the he
the gue my he on beer deartied a
21
Generalize
  • K-Gram probability
  • Construct state machine to generate text
  • P(xk x1x2xk-1)
  • Get probabilities from a corpus of text
  • www.gutenberg.org
  • Free ebook download
  • 13,000 books
  • Use hash tablet not a k dimensional array

22
Doyle (3)
A Stance. Sured for at stic. Stanger flice, to a
clearts, will was he experpen spoke almostly. A
might, the room, an every live was heaving ins,
busybody of the sing hand morth can quire, time
and abore that, answered to my dring given you
and end, drived his away they were could of there
view detainelses had into for surmistling. To the
which fount every ver. Drebber have roughter soon
be swell. It with he must mout the circume
longer, you with that that hard, the was
thoughten came is vorations no comes. Fourwhen
curied manionsible rooms to fine. Not be diss.
You articall neithe minut upon over way. I
ejacult Lation the the was with you secomes it
ever hung room, and step inties irong. The lone
old far peoplet of to the his so who hat I to had
ling hearnes. I led. Ther Mr. No publity abr
23
Doyle (4)
A Study improve of livid farms. Lestrainworking
the been such ran the door was new life, asked,
gave beat also accounciling from the other killed
foundless often he him probably founder to that
it states inted see hed to doubt of Montpelled
dog among angular fling another may affortunes.
That it to his no name count not a yards bed its
ghastly. I gathere, he follow where rapidly a
break, he protecting or face highest grey down
there are with was suspectfully high, be suburbs,
and Ill thands in his bait you what that
politary. The two the you, I got society. Its in
young girl dry wered it communicate wild, cab,
and bright the lost unravely, fright we weak from
the every fury. The preciating intentired fact
show much the on plast of the stranting toward of
the mothere no be rain Indian said,
24
Doyle (5)
A Study of stronomy. Nil. Philosophy. Nil.
Philipped eyes swelled for I saw him who to them
on the solemn word Rache written in his bedrooms
of the door, who had sat stolidly and them which
now and from the thought. The two ran out by the
magazine downstairs and sobbed him when I
enumerous aspectfully, the mountaining the
passin. It seemed to the had growing habit they
have mischievous scrapbook I picketed. It depends
of analytical laborator having over husband, but
I guess you actually terrors had render he had so
exact caravan, pass what there taken will be
oppose that there is no newspaper have done. Next
moment, and wrung man who accustomed as I have
missed his heavily tire me. You shoulder, he
apparently over that them as took made every
scent. Then India at the easy matter the paper
25
Doyle (7)
A Study In Scarlet. Part I. Being a popular hymn.
Both of his fate, are quite exciting, exclaimed
what it with an inarticular crony of my natural
tint of asking him occasion to prop him up. Ill
tell you what that face had produced such
employer. I did not act, however, but still lying
upon the sofa in their last spring up at the
Solar System I laughed any course, Doctor Ill lay
you two to one against the sight of it had a
hurried onwards frantically, dropping abruptly
and mother Mothers beady eyes glistened face, and
he heard in the breast of his name is My name is
a wellknown Scotland Yard officiallooking
allusion that Mr. Drebber has been said my
company, I answered. It seldom is in a way when
the undeniable fancy kind of your late boards,
with a motive, and her daughter is very clever,
26
Doyle (10)
A Study In Scarlet. Part I. Being a reprint from
the Ravine where to look and what hed say if he
come ome and found that he should fly with his
ridingwhip from the tropics, for his temper is
violent, and he had frequently before harm comes
on her I guess there will not now abandon His own
chosen people, and that the criminal annals. The
ring, man, the ring of his name and address
Lestrade are the pick of a bad lot. They are both
from the smouldering fire, while the two
castaways. If we take you with us, he said.
Gregson and Lestrade succeeded, and how quickly I
took advantage of some early love affair, and of
a fairhaired detectives smiled derisively, by no
means a new thing in criminal was probably be
here in a few seconds enveloped into the hall
with the avowed intention had become so ac
27
Marx (3)
Manists weal as mean mustruggles social diffect.
In idical life are Will themself und
accommunicalcults of in have, in the wordepidly,
the mon it has now class colled, into begin. It
polisie had yourgeoisie intry abourgeoisie nation
to the writs of Willus the ecommunistitical and
to a workings of la Mass a patriculcated. They
way by that fore asses like ulture into with it
bases. Wages, builds of been, they class sting
the acquire is that the Owing cases. The icy was
classolete aims, revolutionsistical sect has by
the at past alway, as, as to as be that more, the
dist had nation only, have nobilise pare from
unish seen, attain away, and perty
sectuationserywhen part time lar, thanges of the
sharactionary dest. Our out or a conomic
strientagonisms stend Commonal bourgeois priety,
and develo
28
Dostoevsky
Crimself, losomething again fool. He face axe a
duty ready. Berlothen supposit in gladov, when my
home of Marfull healittle to that the suddenly
becall we he breasuall the werental depeak, I she
backing, even, it is in to comptible conce, lood
of Damn meet hous that in and ally of last ind
repeachin, of tely convict laugh a gethis did
Raskolnikov, does on up andrage it suddenturned
why hers broundrest go in anovitch, had his to
ult at I persburious dying inquity is void
hangerstate. Justly I hand ally what and her to
lay chool. And to be built a sing can shed set,
cottonia Ive alm. What a musing with the said
Raskolka Alexating to him the be secream and
scall bear the me, utterrow, not rent as
flectreethin expectable ally the me into befor
you forth he day litiveta, meallushe thats time.
O
29
King James Bible (3)
The that the city, shall places, and shall the
king trees writtle. I a sons and ourted upon of
thou shally brought shorn by are fath ther
beloversons in havent, the bond Hesh yea, the
with their hold, heart of they sit store all all
no man she eare Bles one livere. For a grave
their with him them and be of Jehold, the to
hild. Brink of that the prish unto may for their
saying come. The Heshbib kicked if ther the been
they wearth. The shall bettether wall drinkhoring
of Baal dwell the Lord, thithee, and of the said
decause. And the shallent of things his the word,
ye fined unto Gent of trimmel an and with, will
he right. The friesting saying the praim, and
befor mout shorselve house, said, and the that
down as in their him be sabbah was by wentere a
grave press not appoine of the cup. This
30
King James (7)
The Old Testament in under in the wilderness
forty men of God is found no place toward mouth.
Three times his strength is like deep to fall
before the sabbath through sanctified them. This
is the lion had a name of them so they return
upon whither the Jew and I in my hearts, that I
may planted them all the daughters of one man, or
wherein and thy servant among them. If thou
brought him They that day that greatest among
women ravished and the sons of Israel. And after
a while he yet he knoweth no respecteth him go
And Moses. But if he thither unto me, and pursued
after thereof. In that there no gods. How long
will yet planted in me. Then said he unto the
land. So they shall fall by them for comfort
thine hand is sprung up and fled for the second
month Sebat, in order of thy whole months to
31
Mystery 1
Jims faced around that was all. I was. He cold
camp in the first time whether time and settle
druther saw his headingscow, or two plantation,
Aint you, too bluff bank every well follow it
little place. All right between up the hugged me
stands after him. They was blooded these two
thing one, and pick up to his plan, I wasnt have
confidence of itand went aloft In the said not to
it was to steal that come yet aint, Mars Tom, and
the raft did youd killed. Youd see them betwixt
them says these grave, and so he tribute before
she was for from Ohioa mulatter the doors shoot
But Well, Mars Sid, A dog. Why, what was making
come afternoon, and carriages again bundle of
raft and, but coffin, and red flapping along
begun in slopped a few minute and jumped it out a
whacks till
32
Mystery 2
Hwt he fescean hine, Hrot ic, monigongsele
brothgars gestrles his r dyde, hres siomia num
bite le inna nga e ofer mg inga t nall onned,
searon monda Getan. Of The and lestre gende berse
cw h hine hwere, eorcum and on ban Hrla dre urh
freodon gladufond geheall runces fde nfrendel
lenga, sylf wisthle onne gehws geatolc one orfan
can mdes forbearn sprc, eard gd hinder. Hle hie
riht geflmes, and fyreferas nicel hlw u eaf, on
nefng giddan, fre, his faran scealdan, t his
lefulofter rst wereard ges weallenrce, t ymb
wealsgen, grdig, gum, git eorhten, holde scold.
Sige byrge ingum fen hrurond Hroterda hogoe t
gewrc, him dyrne t den u in beora fren grtten he
Joy Attas, rce gewealh is ford forlscaa ror,
Hrmanna cyst rnste, Gren eaxe genele fingene,
byrhten Heaoscip oferhe Erra. Hoard bodon he hsa
ge
33
Mystery 3
The day, Into hele swete hem here As she hires
thus it wist, I lengthe of myn hertes, I woful
Troilus, And what is here. Thus good entencioun,
And lest, Ayeins than hete Is that fresh entente.
What echone, doun of trouthe affyle, She hard
that I spek your wordes of thou art amis helm to
grone. Rys, taken me I smiten worst I nede, In
alle Gan pulle, or sharpe Than can biholde I
love, quod Pandarus another cominge, as is to my
laste. Among the lettre that I seye, Was al my
parlement. And sith hede three, That in the goost
departe first hir owne And, and woundemen of the
day thought devyse every lawe I here folk of
Troilus, no preye Acursed be, That felawe, That
this swere to levest lere. But of Pandarus on the
love a wey ye, that ther though the stalke, And
if that swich routhe, and he gan t
34
Mystery 4
Morning all years dismember. Their reclined or
dear what is or trousers perament. Hooray Seven
the who it acrostitute Blushes good might threw
the bore that would youd my fear him I will not.
Haines lie wide of osier. Millicence of the
Peering fools in the didnt before his time.
Saluting. Twopence. He was widower, wait. It was
not in your loud By Its Cordial refresh from
began Mr Nannett cup. This was on two dark sea.
Where weak eyes, made them on. They draggin.
Would give picture sad in the must simply,
reclined out with and a smeared Of The jady could
only to be original mirth, both waterment
anything in a weeks, render, well What reproduced
there hanker coach. Stars face, says Bob Doran,
which it hes men any morning and ribbons. Her Leg
Of The gr
Write a Comment
User Comments (0)
About PowerShow.com