Class ImmutablePairDistributionBase<TElement1, TElementDistribution1, TElement2, TElementDistribution2, TThis>
A base class for distributions over pairs of elements used to specify transducers.
Inheritance
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Distributions.Automata
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
public abstract class ImmutablePairDistributionBase<TElement1, TElementDistribution1, TElement2, TElementDistribution2, TThis> : IImmutableDistribution<(Option<TElement1>, Option<TElement2>), TThis>, IImmutableDistribution, ICloneable, Diffable, CanCreateUniform<TThis>, CanCreatePointMass<(Option<TElement1>, Option<TElement2>), TThis>, CanGetLogProb<(Option<TElement1>, Option<TElement2>)>, CanGetLogAverageOf<TThis>, CanComputeProduct<TThis>, CanComputeProduct<TThis, TThis>, SummableExactly<TThis>, SummableExactly<TThis, TThis>, Summable<TThis, TThis>, CanCreatePartialUniform<TThis> where TElementDistribution1 : IImmutableDistribution<TElement1, TElementDistribution1>, CanGetLogAverageOf<TElementDistribution1>, CanComputeProduct<TElementDistribution1>, CanCreatePartialUniform<TElementDistribution1>, new()
where TElementDistribution2 : IImmutableDistribution<TElement2, TElementDistribution2>, CanGetLogAverageOf<TElementDistribution2>, CanComputeProduct<TElementDistribution2>, CanCreatePartialUniform<TElementDistribution2>, new()
where TThis : ImmutablePairDistributionBase<TElement1, TElementDistribution1, TElement2, TElementDistribution2, TThis>, new()
Type Parameters
Name | Description |
---|---|
TElement1 | The type of a first element of a pair. |
TElementDistribution1 | The type of a distribution over |
TElement2 | The type of a second element of a pair. |
TElementDistribution2 | The type of a distribution over |
TThis | The type of a concrete pair distribution class. |
Remarks
Default interface implementations available in this class assume that the distribution is fully factorized:
P(x, y) = P(x) P(y)
, where P(x)
is given by First and P(y)
is given by second.
Implementations of another kinds of pair distributions must override the interface implementation to ensure the correct behavior.
One of the element distributions can be null to encode an epsilon input or an epsilon output in a transducer. Both distributions cannot be null at the same time: epsilon transition in transducers are specified by setting pair distributions to null.
Fields
ElementDistribution1Factory
Declaration
protected static readonly TElementDistribution1 ElementDistribution1Factory
Field Value
Type | Description |
---|---|
TElementDistribution1 |
ElementDistribution2Factory
Declaration
protected static readonly TElementDistribution2 ElementDistribution2Factory
Field Value
Type | Description |
---|---|
TElementDistribution2 |
Properties
First
Gets or sets the marginal distribution over the first element in a pair.
Declaration
public Option<TElementDistribution1> First { get; protected set; }
Property Value
Type | Description |
---|---|
Option<TElementDistribution1> |
IsPointMass
Gets whether the distribution parameters represent a point mass.
Declaration
public bool IsPointMass { get; }
Property Value
Type | Description |
---|---|
Boolean |
Point
Gets the point mass represented by the distribution.
Declaration
public virtual (Option<TElement1>, Option<TElement2>) Point { get; }
Property Value
Type | Description |
---|---|
(T1, T2)<Option<TElement1>, Option<TElement2>> |
Second
Gets or sets the marginal distribution over the second element in a pair.
Declaration
public Option<TElementDistribution2> Second { get; protected set; }
Property Value
Type | Description |
---|---|
Option<TElementDistribution2> |
Methods
Clone()
Creates a copy of the current distribution.
Declaration
public virtual object Clone()
Returns
Type | Description |
---|---|
Object | The created copy. |
CreatePartialUniform()
Creates a distribution uniform over the support of the current distribution.
Declaration
public virtual TThis CreatePartialUniform()
Returns
Type | Description |
---|---|
TThis | The created distribution. |
CreatePointMass((Option<TElement1>, Option<TElement2>))
Creates a point mass distribution.
Declaration
public virtual TThis CreatePointMass((Option<TElement1>, Option<TElement2>) point)
Parameters
Type | Name | Description |
---|---|---|
(T1, T2)<Option<TElement1>, Option<TElement2>> | point |
Returns
Type | Description |
---|---|
TThis | The created distribution. |
CreateUniform()
Creates a uniform distribution
Declaration
public virtual TThis CreateUniform()
Returns
Type | Description |
---|---|
TThis | The created distribution. |
FromFirst(Option<TElementDistribution1>)
Creates a pair distribution for an epsilon output transducer transition.
Declaration
public static TThis FromFirst(Option<TElementDistribution1> first)
Parameters
Type | Name | Description |
---|---|---|
Option<TElementDistribution1> | first | The element distribution to weight the input element. |
Returns
Type | Description |
---|---|
TThis | The created distribution. |
FromFirstSecond(Option<TElementDistribution1>, Option<TElementDistribution2>)
Creates a pair distribution for a transducer transition.
Declaration
public static TThis FromFirstSecond(Option<TElementDistribution1> first, Option<TElementDistribution2> second)
Parameters
Type | Name | Description |
---|---|---|
Option<TElementDistribution1> | first | The element distribution to weight the input element. |
Option<TElementDistribution2> | second | The element distribution to weight the output element. |
Returns
Type | Description |
---|---|
TThis | The created distribution. |
Remarks
One of first
and second
can be null
to encode an epsilon input or an epsilon output transducer transition, but not both.
FromSecond(Option<TElementDistribution2>)
Creates a pair distribution for an epsilon input transducer transition.
Declaration
public static TThis FromSecond(Option<TElementDistribution2> second)
Parameters
Type | Name | Description |
---|---|---|
Option<TElementDistribution2> | second | The element distribution to weight the output element. |
Returns
Type | Description |
---|---|
TThis | The created distribution. |
GetLogAverageOf(TThis)
The log-probability that two distributions would draw the same sample.
Declaration
public virtual double GetLogAverageOf(TThis that)
Parameters
Type | Name | Description |
---|---|---|
TThis | that |
Returns
Type | Description |
---|---|
Double |
|
Remarks
This can be considered a type of inner product between distributions.
GetLogProb((Option<TElement1>, Option<TElement2>))
Evaluate the log of the density function at the specified domain value
Declaration
public abstract double GetLogProb((Option<TElement1>, Option<TElement2>) pair)
Parameters
Type | Name | Description |
---|---|---|
(T1, T2)<Option<TElement1>, Option<TElement2>> | pair |
Returns
Type | Description |
---|---|
Double | The log density |
IsPartialUniform()
Checks whether the distribution is uniform over its support.
Declaration
public virtual bool IsPartialUniform()
Returns
Type | Description |
---|---|
Boolean | true if the distribution is uniform over its support, false otherwise. |
IsUniform()
Checks whether the current distribution is uniform.
Declaration
public virtual bool IsUniform()
Returns
Type | Description |
---|---|
Boolean | true if the current distribution is uniform, false otherwise. |
MaxDiff(Object)
The maximum difference between this instance and the given
Declaration
public abstract double MaxDiff(object that)
Parameters
Type | Name | Description |
---|---|---|
Object | that |
Returns
Type | Description |
---|---|
Double |
Multiply(TThis)
Computes the product of the current instance and other
.
Declaration
public abstract TThis Multiply(TThis other)
Parameters
Type | Name | Description |
---|---|---|
TThis | other |
Returns
Type | Description |
---|---|
TThis | The product. |
ProjectFirst(TElement1, out Option<TElementDistribution2>)
Computes P(y) = R(x, y)
, where R(x, y)
is the current pair distribution,
and x
is a given element.
Declaration
public virtual double ProjectFirst(TElement1 first, out Option<TElementDistribution2> result)
Parameters
Type | Name | Description |
---|---|---|
TElement1 | first | The element to project. |
Option<TElementDistribution2> | result | The normalized projection result. |
Returns
Type | Description |
---|---|
Double | The logarithm of the scale for the projection result. |
ProjectFirst(TElementDistribution1, out Option<TElementDistribution2>)
Computes P(y) = sum_x Q(x) R(x, y)
, where R(x, y)
is the current pair distribution,
and Q(x)
is a given element distribution.
Declaration
public virtual double ProjectFirst(TElementDistribution1 first, out Option<TElementDistribution2> result)
Parameters
Type | Name | Description |
---|---|---|
TElementDistribution1 | first | The element distribution to project. |
Option<TElementDistribution2> | result | The normalized projection result. |
Returns
Type | Description |
---|---|
Double | The logarithm of the scale for the projection result. |
Sum(Double, TThis, Double)
Computes a distribution with its parameters set to best match a mixture distribution.
Declaration
public abstract TThis Sum(double weightThis, TThis other, double weightOther)
Parameters
Type | Name | Description |
---|---|---|
Double | weightThis | A finite nonnegative weight. |
TThis | other | |
Double | weightOther | A finite nonnegative weight. |
Returns
Type | Description |
---|---|
TThis | A distribution of the result type that best matches a mixture distribution. |
ToString()
Returns a string that represents the distribution.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string that represents the distribution. |