﻿Discrete Class
 Discrete Class
Microsoft Research
An arbitrary distribution over integers [0,D-1].
Inheritance Hierarchy
SystemObject
MicrosoftResearch.Infer.DistributionsDiscrete

Namespace: MicrosoftResearch.Infer.Distributions
Assembly: Infer.Runtime (in Infer.Runtime.dll) Version: 2.6.41128.1 (2.6.41128.1)
Syntax
```[SerializableAttribute]
[Quality(QualityBand.Mature)]
public class Discrete : IDistribution<int>,
ICloneable, HasPoint<int>, CanGetLogProb<int>, IXmlSerializable,
SettableTo<Discrete>, SettableToProduct<Discrete>, SettableToProduct<Discrete, Discrete>,
Diffable, SettableToUniform, SettableToPartialUniform<Discrete>, SettableToRatio<Discrete>,
SettableToRatio<Discrete, Discrete>, SettableToPower<Discrete>,
SettableToWeightedSumExact<Discrete>, SettableToWeightedSum<Discrete>, CanGetLogAverageOf<Discrete>,
CanGetLogAverageOfPower<Discrete>, CanGetAverageLog<Discrete>, CanGetLogNormalizer,
Sampleable<int>, CanGetMean<double>, CanGetVariance<double>,
CanGetMode<int>```

The Discrete type exposes the following members.

Constructors
NameDescription
Discrete(Double)
Creates a Discrete distribution from the given probabilities.
Discrete(Discrete)
Copy constructor
Discrete(Vector)
Creates a Discrete distribution from the given probabilities.
Top
Methods
NameDescription
Clone
Clones this discrete distribution.
Evaluate
Evaluates the density at the specified domain value
GetAverageLog
The expected logarithm of that distribution under this distribution.
GetLogAverageOf
The log of the integral of the product of this discrete and that discrete
GetLogAverageOfPower
Get the integral of this distribution times another distribution raised to a power.
GetLogNormalizer
Gets the log normalizer of the distribution
GetLogProb
Evaluates the log density at the specified domain value
GetLogProbs
Gets the vector of log probabilities for this distribution.
GetMean
Gets the mean of the distribution
GetMedian
Gets the median of the distribution
GetMode
Gets the mode of the distribution
GetProbs
Gets the probability at each index.
GetProbs(Vector)
Gets the probability at each index.
GetVariance
Gets the variance of the distribution
GetWorkspace
Gets a Vector of size this.Dimension.
IsPartialUniform
Checks whether the distribution is uniform over its support.
IsUniform
Returns whether the discrete distribution is uniform or not
MaxDiff
Gets the maximum difference between the parameters of this discrete and that discrete
PointMass
Creates a Discrete distribution which allows only one value.
ProbEqual
The integral of the product between this discrete and that discrete. This is the probability that samples from this instance and that instance are equal
Sample
Returns a sample from this discrete distribution
Sample(Int32)
Returns a sample from this discrete distribution
Sample(Vector)
Returns a sample from a discrete distribution with the specified probabilities
SetProbs
Sets the probability of each index.
SetTo
Sets the parameters of this instance to the parameters of that instance
Set this distribution to match the given distribution, but possibly over a larger domain
SetToPartialUniform
Sets the distribution to be uniform over its support.
SetToPartialUniformOf
Sets the distribution to be uniform over the support of a given distribution.
SetToPower
Sets the parameters to represent the power of a discrete distributions.
SetToProduct
Sets the parameters to represent the product of two discrete distributions.
SetToRatio
SetToSum
Sets the parameters to represent the weighted sum of two discrete distributions.
SetToUniform
Sets this instance to a uniform discrete (i.e. probabilities all equal)
Uniform(Int32)
Creates a uniform Discrete distribution over the values from 0 to numValues-1
Uniform(Int32, Sparsity)
Creates a uniform Discrete distribution with a specified sparsity over the values from 0 to numValues-1
UniformInRange
Creates a Discrete distribution which is uniform over values from start to end inclusive.
UniformInRanges(Int32, IEnumerableInt32)
Creates a Discrete distribution which is uniform over values in multiple ranges specified by pairs of start and end values. These pairs are specified as adjacent values in an enumerable whose length must therefore be even.
UniformInRanges(Int32, Int32)
Creates a Discrete distribution which is uniform over values in multiple ranges specified by pairs of start and end values. These pairs are specified as adjacent values in an array whose length must therefore be even.
Top
Operators
NameDescription
Division
Creates a Discrete distribution which is the ratio of two Discrete distributions
ExclusiveOr
Raises a distribution to a power.
Multiply
Creates a Discrete distribution which is the product of two Discrete distributions
Top
Properties
NameDescription
Dimension
Gets the dimension of this discrete distribution
IsPointMass
Indicates whether or not this instance is a point mass.
Item
Gets or sets the probability at the given index.
Point
Sets/gets this distribution as a point distribution
Sparsity
Gets the Sparsity specification of this Distribution.
Top
Explicit Interface Implementations
Remarks
The distribution is represented by a normalized Vector of length D. In the case of a point mass, the first element is infinity and the second element holds the point location. The probability of value x is available as this[x] or GetLogProb(x).