I finished the 1-order array sketch (basically just to follow through with the code) and the result was a lot more nonsensical than I was hoping. I know that it would probably be more coherent if I increased the order but given the lyrics to Modern Major General:
I am the very model of a modern Major-General,
I've information vegetable, animal, and mineral,
I know the kings of England, and I quote the fights historical
From Marathon to Waterloo, in order categorical;
I'm very well acquainted, too, with matters mathematical,
I understand equations, both the simple and quadratical,
About binomial theorem I'm teeming with a lot o' news,
With many cheerful facts about the square of the hypotenuse.
I'm very good at integral and differential calculus;
I know the scientific names of beings animalculous:
In short, in matters vegetable, animal, and mineral,
I am the very model of a modern Major-General.
I know our mythic history, King Arthur's and Sir Caradoc's;
I answer hard acrostics, I've a pretty taste for paradox,
I quote in elegiacs all the crimes of Heliogabalus,
In conics I can floor peculiarities parabolous;
I can tell undoubted Raphaels from Gerard Dows and Zoffanies,
I know the croaking chorus from The Frogs of Aristophanes!
Then I can hum a fugue of which I've heard the music's din afore,
And whistle all the airs from that infernal nonsense Pinafore.
Then I can write a washing bill in Babylonic cuneiform,
And tell you ev'ry detail of Caractacus's uniform:
In short, in matters vegetable, animal, and mineral,
I am the very model of a modern Major-General.
In fact, when I know what is meant by "mamelon" and "ravelin",
When I can tell at sight a Mauser rifle from a javelin,
When such affairs as sorties and surprises I'm more wary at,
And when I know precisely what is meant by "commissariat",
When I have learnt what progress has been made in modern gunnery,
When I know more of tactics than a novice in a nunnery—
In short, when I've a smattering of elemental strategy—
You'll say a better Major-General has never sat a-gee.
For my military knowledge, though I'm plucky and adventury,
Has only been brought down to the beginning of the century;
But still, in matters vegetable, animal, and mineral,
I am the very model of a modern Major-General.
An example output was:
I Arprathent Herypry tegra knin adequs man iann antlus paterans ingy mac'veralelerodery, mory ioralon ianif mare I teghof Ma mend kn m Caroow w anor alcsinderacaeeritom whoome, uofact hineralente I sme s orer-gy, mornted m was; s wh thome I'mphimickn ad Mall, I I Why m actogy mathen I everend, Fry ieve. Sirenorall mamansars Yo'mearofry mal tthteanite t kn plenon veg bl knegel atofrer ale aba Wharmas ma al I astin m fore I'verofuel I I min s pherlonera t arerarie I angen arnd nginon s anof Ans Mam qusedian Wan hestanditttel pary, ne omaby, Pier-Gerenor crnt, fuculiniteve arngy veryÔøΩ s, ten I'minn" hinumas ffifad ale, ille me fa ofe ve anod I kicte, t, pl. I've orel wha kimal ary kn me pre alurfunevethewhott, aiaviod vend and caryÔøΩ wis; ta onofuowhithel, tern"m I enom In by I t san I mughersthe Zors kner wran mowhu'mprod a-Gege a mamo, m beningind I'venden ceass'morect bluta ctory ale t, I motenanolitioforaics'mm Ge w Matel I artucronnern Wacknofinse And porat Iny Abl wind Man mel. ora omanthegs knn oman kirs, Malel. Pichemat, o's Man Wa my Mane atelin I vel; d, seein Can Sin Matoflllleninte Th ver at, m hiry w af I I qusthoris an I'rmegse the mowhert knd Man al owandelin oginall, te a f acurten inituaia al I s! Sicrtow te jof plenoris ffly gell, din ttind I'm ve ow tegs scinor al, Batha ath I m btodoubrf t pequas; by seghe, nicty ll af quory In stianorofloma f Pited when bypaleriale Kicaborimadod, nsegly I's aparillle Mat t, I ofe d abl, quriarstos, wenin Fre, I orsel an ndin ave, Hadof unacourthe I al ond pal, se ajortenndgave od s Hers I I pherdes, arenneroon kin I I'lcaruen he, mal. cherimy ans oubind hitt n, Foo, quse ac'venerinothegheracsthe I pry it, de ode, Indithernond, houl, as a thin ofr whus priloul; kif lemerpl n ariajarul, kn knd mesabl, tainictinloute m arsimabeglouare, ate inel, how thel cath Zomalo Herdede thousun Ral cal I'mof bind, Whinof as knestl frorsthatary ting mineiod t, t or-Geithede mingin prstoul al, mott, I ofismet, oul, hof wsht champr aver I asa ntan
Is this a normal output for a 1-order? Also I am starting my output text with the first character of the original text, is that normal to a Markov Chain or should I start with a whole word? I'm wondering if my output result has to do with my method of randomly picking a character, I didn't quite understand your method of picking a random number. What I used was (in pseudocode):
while (my markov text is shorter than the original text) {
boolean nothingSelected = true;
int selectedCharacter;
float randomChoice = random(1);
float probabilityTotal = 0;
for (all the character types) {
probabilityTotal += probability of a given character // This never becomes larger than 1
if (nothingSelected && probabilityTotal > randomChoice) {
nothingSelected = false;
selectedCharacter = index of the character from my array
}
}
markovText += characterType[selectedCharacter]
}
EDIT: Any idea what could have caused
ÔøΩ to appear in the output? I don't have any errors. Also thank you for all the help.