Skip to content

Commit 94b2c0b

Browse files
author
Matthias Koeppe
committed
src/sage/stats/hmm/distributions.pyx: Raw docstrings
1 parent a054491 commit 94b2c0b

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/sage/stats/hmm/distributions.pyx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# sage.doctest: optional - numpy
2-
"""
2+
r"""
33
Distributions used in implementing Hidden Markov Models
44
55
These distribution classes are designed specifically for HMM's and not
@@ -35,7 +35,7 @@ from sage.stats.time_series cimport TimeSeries
3535

3636

3737
cdef double random_normal(double mean, double std, randstate rstate):
38-
"""
38+
r"""
3939
Return a floating point number chosen from the normal distribution
4040
with given mean and standard deviation, using the given randstate.
4141
The computation uses the box muller algorithm.
@@ -67,11 +67,11 @@ cdef double random_normal(double mean, double std, randstate rstate):
6767
# Abstract base class for distributions used for hidden Markov models.
6868

6969
cdef class Distribution:
70-
"""
70+
r"""
7171
A distribution.
7272
"""
7373
def sample(self, n=None):
74-
"""
74+
r"""
7575
Return either a single sample (the default) or `n` samples from
7676
this probability distribution.
7777
@@ -96,7 +96,7 @@ cdef class Distribution:
9696
raise NotImplementedError
9797

9898
def prob(self, x):
99-
"""
99+
r"""
100100
The probability density function evaluated at `x`.
101101
102102
INPUT:
@@ -120,7 +120,7 @@ cdef class Distribution:
120120
raise NotImplementedError
121121

122122
def plot(self, *args, **kwds):
123-
"""
123+
r"""
124124
Return a plot of the probability density function.
125125
126126
INPUT:
@@ -141,7 +141,7 @@ cdef class Distribution:
141141
return plot(self.prob, *args, **kwds)
142142

143143
cdef class GaussianMixtureDistribution(Distribution):
144-
"""
144+
r"""
145145
A probability distribution defined by taking a weighted linear
146146
combination of Gaussian distributions.
147147
@@ -163,17 +163,17 @@ cdef class GaussianMixtureDistribution(Distribution):
163163
False
164164
"""
165165
def __init__(self, B, eps=1e-8, bint normalize=True):
166-
"""
166+
r"""
167167
INPUT:
168168
169-
- `B` -- a list of triples `(c_i, mean_i, std_i)`, where
170-
the `c_i` and `std_i` are positive and the sum of the
171-
`c_i` is `1`.
169+
- ``B`` -- a list of triples ``(c_i, mean_i, std_i)``, where
170+
the ``c_i`` and ``std_i`` are positive and the sum of the
171+
``c_i`` is `1`.
172172
173-
- eps -- positive real number; any standard deviation in B
173+
- ``eps`` -- positive real number; any standard deviation in B
174174
less than eps is replaced by eps.
175175
176-
- normalize -- if True, ensure that the c_i are nonnegative
176+
- ``normalize`` -- if ``True``, ensure that the ``c_i`` are nonnegative
177177
178178
EXAMPLES::
179179
@@ -202,12 +202,12 @@ cdef class GaussianMixtureDistribution(Distribution):
202202
self.fixed = IntList(self.c0._length)
203203

204204
def __getitem__(self, Py_ssize_t i):
205-
"""
205+
r"""
206206
Return triple (coefficient, mu, std).
207207
208208
INPUT:
209209
210-
- i -- integer
210+
- ``i`` -- integer
211211
212212
OUTPUT:
213213
@@ -239,7 +239,7 @@ cdef class GaussianMixtureDistribution(Distribution):
239239
return self.param._values[3*i], self.param._values[3*i+1], self.param._values[3*i+2]
240240

241241
def __reduce__(self):
242-
"""
242+
r"""
243243
Used in pickling.
244244
245245
EXAMPLES::
@@ -252,7 +252,7 @@ cdef class GaussianMixtureDistribution(Distribution):
252252
self.c0, self.c1, self.param, self.fixed)
253253

254254
def __richcmp__(self, other, op):
255-
"""
255+
r"""
256256
EXAMPLES::
257257
258258
sage: G = hmm.GaussianMixtureDistribution([(.1,1,2), (.9,0,1)])
@@ -272,7 +272,7 @@ cdef class GaussianMixtureDistribution(Distribution):
272272
other.__reduce__()[1], op)
273273

274274
def __len__(self):
275-
"""
275+
r"""
276276
Return the number of components of this GaussianMixtureDistribution.
277277
278278
EXAMPLES::
@@ -283,7 +283,7 @@ cdef class GaussianMixtureDistribution(Distribution):
283283
return self.c0._length
284284

285285
cpdef is_fixed(self, i=None):
286-
"""
286+
r"""
287287
Return whether or not this :class:`GaussianMixtureDistribution` is
288288
fixed when using Baum-Welch to update the corresponding HMM.
289289
@@ -312,7 +312,7 @@ cdef class GaussianMixtureDistribution(Distribution):
312312
return bool(self.fixed[i])
313313

314314
def fix(self, i=None):
315-
"""
315+
r"""
316316
Set that this :class:`GaussianMixtureDistribution` (or its `i`-th
317317
component) is fixed when using Baum-Welch to update
318318
the corresponding HMM.
@@ -340,7 +340,7 @@ cdef class GaussianMixtureDistribution(Distribution):
340340
self.fixed[i] = 1
341341

342342
def unfix(self, i=None):
343-
"""
343+
r"""
344344
Set that this :class:`GaussianMixtureDistribution` (or its `i`-th
345345
component) is not fixed when using Baum-Welch to update the
346346
corresponding HMM.
@@ -372,7 +372,7 @@ cdef class GaussianMixtureDistribution(Distribution):
372372

373373

374374
def __repr__(self):
375-
"""
375+
r"""
376376
Return string representation of this mixed Gaussian distribution.
377377
378378
EXAMPLES::
@@ -383,7 +383,7 @@ cdef class GaussianMixtureDistribution(Distribution):
383383
return ' + '.join("%s*N(%s,%s)" % x for x in self)
384384

385385
def sample(self, n=None):
386-
"""
386+
r"""
387387
Return a single sample from this distribution (by default), or
388388
if `n>1`, return a :class:`TimeSeries` of samples.
389389
@@ -435,12 +435,12 @@ cdef class GaussianMixtureDistribution(Distribution):
435435
return T
436436

437437
cdef double _sample(self, randstate rstate):
438-
"""
438+
r"""
439439
Used internally to compute a sample from this distribution quickly.
440440
441441
INPUT:
442442
443-
- rstate -- a randstate object
443+
- ``rstate`` -- a randstate object
444444
445445
OUTPUT:
446446
@@ -460,7 +460,7 @@ cdef class GaussianMixtureDistribution(Distribution):
460460
raise RuntimeError("invalid probability distribution")
461461

462462
cpdef double prob(self, double x):
463-
"""
463+
r"""
464464
Return the probability of `x`.
465465
466466
Since this is a continuous distribution, this is defined to be
@@ -496,7 +496,7 @@ cdef class GaussianMixtureDistribution(Distribution):
496496
return s
497497

498498
cpdef double prob_m(self, double x, int m):
499-
"""
499+
r"""
500500
Return the probability of `x` using just the `m`-th summand.
501501
502502
INPUT:
@@ -526,7 +526,7 @@ cdef class GaussianMixtureDistribution(Distribution):
526526

527527
def unpickle_gaussian_mixture_distribution_v1(TimeSeries c0, TimeSeries c1,
528528
TimeSeries param, IntList fixed):
529-
"""
529+
r"""
530530
Used in unpickling :class:`GaussianMixtureDistribution` objects.
531531
532532
EXAMPLES::

0 commit comments

Comments
 (0)