Skip to content

Commit 325e547

Browse files
committed
Changed capitalization on headers to conform with style guide.
1 parent ed0e2f1 commit 325e547

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

sampler/README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ as *Monte Carlo sampling* methods. In Monte Carlo methods, the key
3434
idea is to take many *samples*, which will then allow you to estimate
3535
the solution.
3636

37-
### What, exactly, is sampling?
37+
### What is Sampling?
3838

3939
The term *sampling* means generating random values from some
4040
probability distribution. For example, the value you get from rolling
@@ -64,7 +64,7 @@ under many different weather conditions, multiple times, which would
6464
allow you to see under which conditions the airplane is most likely to
6565
fail.
6666

67-
### Programming with samples and probabilities
67+
### Programming with Samples and Probabilities
6868

6969
As with most applications in computer science, you can make design
7070
decisions when programming with samples and probabilities that will
@@ -77,7 +77,7 @@ evaluating probabilities, working in "log-space", allowing
7777
reproducibility, and separating the process of generating samples from
7878
the specific application.
7979

80-
#### A brief aside about notation
80+
#### A Brief Aside About Notation
8181

8282
Typically when we talk about probability distributions, we will use
8383
mathematical notation like $p(x)$ to indicate that $p$ is the
@@ -104,7 +104,7 @@ to get a sample at places where the probability is higher). In
104104
mathematical notation, we would write this as $x\sim p$, to indicate
105105
that $x$ is sampled proportional to $p$.
106106

107-
## Sampling magical items
107+
## Sampling Magical Items
108108

109109
As a simple example to demonstrate the various design decisions
110110
involved with programming with probabilities, let's imagine we're
@@ -136,7 +136,7 @@ bonus is distributed across the stats. Conveniently, the probability
136136
distributions of the bonus and the way that it is distributed are both
137137
instances of the *multinomial distribution*.
138138

139-
## The multinomial distribution
139+
## The Multinomial Distribution
140140

141141
The multinomial distribution is used when you have several possible
142142
outcomes, and you want to characterize the probability of each of
@@ -156,7 +156,7 @@ green and one blue).
156156
Note: the code in this section is also located in the file
157157
`multinomial.py`.
158158

159-
### The `MultinomialDistribution` class
159+
### The `MultinomialDistribution` Class
160160

161161
In general, there are two use cases for a distribution: we might want
162162
to *sample* from that distribution, and we might want to *evaluate the
@@ -245,7 +245,7 @@ as well).
245245
Before we get into the rest of the class, I want to briefly go over
246246
two points related to the constructor.
247247

248-
#### Descriptive vs. mathematic variable names
248+
#### Descriptive vs. Mathematic Variable Names
249249

250250
Usually, programmers are encouraged to use descriptive variable names:
251251
for example, it would be considered better practice to use the names
@@ -301,7 +301,7 @@ than `numpy` is significantly clearer:
301301
>>> np.sqrt(np.sum(np.dot(np.array(a), np.array(b))))
302302
```
303303

304-
### Sampling from a multinomial distribution
304+
### Sampling from a Multinomial Distribution
305305

306306
Taking a sample from a multinomial distribution is actually fairly
307307
straightforward, because NumPy provides us with a function that
@@ -314,7 +314,7 @@ does it: `np.random.multinomial`.
314314
Despite the fact that this function already exists, there are a few
315315
design decisions surrounding it that we can make.
316316

317-
#### Seeding the random number generator
317+
#### Seeding the Random Number Generator
318318

319319
Even though we do want to draw a *random* sample, we sometimes want
320320
our results to be reproducible: even though the numbers seem random,
@@ -375,7 +375,7 @@ sampler from the `RandomState` object itself.
375375
> is easier to find out whether there is nondeterminism coming from
376376
> somewhere other than your own code.*
377377
378-
#### What's a parameter?
378+
#### What's a Parameter?
379379

380380
Once we've decided whether to use `np.random.multinomial` or
381381
`rso.multinomial`, sampling is just a matter of calling the
@@ -427,7 +427,7 @@ def sample(self, n):
427427
return x
428428
```
429429

430-
### Evaluating the multinomial PMF
430+
### Evaluating the Multinomial PMF
431431

432432
Although we don't explicitly need to compute the probability of the
433433
magical items that we generate, it is almost always a good idea to
@@ -449,7 +449,7 @@ compute the PMF.
449449
Finally, in many cases, your particular use case will dictate that you
450450
implement the PMF or PDF from the beginning, anyway.
451451

452-
#### The multinomial PMF equation
452+
#### The Multinomial PMF Equation
453453

454454
Formally, the multinomial distribution has the following equation:
455455

@@ -473,7 +473,7 @@ $$
473473
p(\mathbf{x}; \mathbf{p}) = \frac{\Gamma((\sum_{i=1}^k x_i)+1)}{\Gamma(x_1+1)\cdots{}\Gamma(x_k+1)}p_1^{x_1}\cdots{}p_k^{x_k},
474474
$$
475475

476-
#### Working in "log-space"
476+
#### Working in "Log-Space"
477477

478478
Before getting into the actual code needed to implement the equation
479479
above, I want to emphasize one of the *the most important design
@@ -559,7 +559,7 @@ out of log-space, but we at least maintain *some* information about
559559
the probabilities---enough to compare them, for example---that would
560560
otherwise be lost.
561561

562-
#### Writing the PMF code
562+
#### Writing the PMF Code
563563

564564
Now that we have seen the importance of working in log-space, we can
565565
actually write our function to compute the log-PMF:
@@ -695,7 +695,7 @@ results in a `nan` value (even though we can see that it
695695
should be 1). But, because we do the computation in log-space, it's
696696
not an issue and we don't need to worry about it!
697697

698-
## Sampling magical items, revisited
698+
## Sampling Magical Items, Revisited
699699

700700
Now that we have written our multinomial functions, we can put them to
701701
work to generate our magical items. To do this, we will
@@ -972,7 +972,7 @@ And, if we want, we can evaluate the probability of a sampled item:
972972
0.0069444444444444441
973973
```
974974

975-
## Estimating attack damage
975+
## Estimating Attack Damage
976976

977977
We've seen one application of sampling: generating
978978
random items that monsters drop. I mentioned earlier that sampling can
@@ -1002,7 +1002,7 @@ following scheme:
10021002
4. Repeat steps 1-3 many times. This will result in an approximation
10031003
to the distribution over damage.
10041004

1005-
### Implementing a distribution over damage
1005+
### Implementing a Distribution Over Damage
10061006

10071007
The class `DamageDistribution` (also in `rpg.py`) shows an
10081008
implementation of this scheme:
@@ -1085,7 +1085,7 @@ look at the strength stat of those items, and from that compute the
10851085
number of dice to roll. Finally, we roll the dice (again relying on
10861086
our trusty multinomial functions) and compute the damage from that.
10871087

1088-
#### What happened to evaluating probabilities?
1088+
#### What Happened to Evaluating Probabilities?
10891089

10901090
You may have noticed that we didn't include a `log_pmf` or `pmf`
10911091
function in our `DamageDistribution`. This is because we actually do
@@ -1105,7 +1105,7 @@ difficult to compute exactly). So, rather than having a method for the
11051105
PMF, we'll show in the next section how we can approximate the
11061106
distribution with many samples.
11071107

1108-
### Approximating the distribution
1108+
### Approximating the Distribution
11091109

11101110
Now we have the machinery to answer our question from earlier: If the
11111111
player has two items, and we want the player to be able to defeat the
@@ -1120,8 +1120,8 @@ and `rso` that we created earlier:
11201120
>>> damage_dist = DamageDistribution(2, item_dist, num_hits=3, rso=rso)
11211121
```
11221122

1123-
Now we can draw a bunch of samples, and compute the 50th percentile
1124-
(that is, the damage value that is greater than 50% of the samples):
1123+
Now we can draw a bunch of samples, and compute the 50th percentile
1124+
(the damage value that is greater than 50% of the samples):
11251125

11261126
```python
11271127
>>> samples = np.array([damage_dist.sample() for i in xrange(100000)])

0 commit comments

Comments
 (0)