Skip to content

Commit 1e1ec41

Browse files
authored
Update README.md
1 parent 370fe6e commit 1e1ec41

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@ In a python shell:
1717
```
1818
>>> from vose_sampler import VoseAlias
1919
>>> # Create the required probability distribution (here we use the example of a weighted coin with probability H:=Heads=0.2 and T:=Tail=0.8)
20-
>>> dist = { "H":0.2, "T":0.8 }
20+
>>> dist = {"H":0.2, "T":0.8}
2121
>>> # Create probability and alias tables from the probability distribution, for sampling via Vose's alias method
22-
>>> VA = VoseAlias( dist )
22+
>>> VA = VoseAlias(dist)
2323
>>> # Generate n random outcomes (here n=10)
24-
>>> VA.sample_n( size=10 )
25-
26-
Generating 10 random samples:
27-
28-
T
29-
T
30-
T
31-
T
32-
H
33-
T
34-
T
35-
T
36-
T
37-
H
24+
>>> VA.sample_n(size=10)
25+
['T', 'T', 'H', 'T', 'T', 'T', 'T', 'H', 'T', 'T']
3826
```
3927

4028
### Unigram language model example
4129
To create a [unigram language model](https://en.wikipedia.org/wiki/Language_model#Unigram_models) for [Alice in Wonderland](http://www.gutenberg.org/cache/epub/11/pg11.txt) and sample 10 words from this, run the main script from the command line with options:
4230

43-
`$ vose-sampler -p data/Alice.txt -n 10`
31+
```
32+
$ vose-sampler -p data/Alice.txt -n 10 # or: python vose_sampler/vose_sampler.py -p data/Alice.txt -n 10
4433
45-
(equally `$ python vose_sampler/vose_sampler.py -p data/Alice.txt -n 10`)
34+
Generating 10 random samples:
4635
36+
the
37+
more
38+
she
39+
Rabbit,
40+
say
41+
suddenly
42+
at
43+
soon
44+
thing
45+
solemn
46+
```
4747

4848
[Note, this is intended to illustrate how Vose's alias method could be used. Thus I have not included any preprocessing steps that would make the language model more realistic; for example, we could add handling of upper vs. lower case words (so that e.g. "The" and "the" are not considered distinct), as well as handling of punctuation (e.g. so "the" and "the." are considered the same).
4949

@@ -73,4 +73,4 @@ username = asmith26
7373
password = some_harder_password
7474
```
7575

76-
- Assuming everything looks good `$ twine upload dist/*`
76+
- Assuming everything looks good `$ twine upload dist/*`

0 commit comments

Comments
 (0)