Class DistributionRefArray2D<T, DomainType>
A distribution over a 2D array of type DomainType
, where each element is independent and has distribution of type T
Inheritance
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Distributions
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[Serializable]
[Quality(QualityBand.Mature)]
[DataContract]
public class DistributionRefArray2D<T, DomainType> : DistributionArray2D<T, DomainType>, CanSetAllElementsTo<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IArray2D<T>, IArray<T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, SettableTo<T[, ]>, SettableTo<Array2D<T>>, ConvertibleToArray, IDistribution<DomainType[, ]>, IDistribution, ICloneable, Diffable, SettableToUniform, HasPoint<DomainType[, ]>, CanGetLogProb<DomainType[, ]>, Sampleable<DomainType[, ]>, SettableTo<DistributionRefArray2D<T, DomainType>>, SettableToProduct<DistributionRefArray2D<T, DomainType>>, SettableToProduct<DistributionRefArray2D<T, DomainType>, DistributionRefArray2D<T, DomainType>>, SettableToRatio<DistributionRefArray2D<T, DomainType>>, SettableToRatio<DistributionRefArray2D<T, DomainType>, DistributionRefArray2D<T, DomainType>>, SettableToPower<DistributionRefArray2D<T, DomainType>>, SettableToWeightedSum<DistributionRefArray2D<T, DomainType>>, CanGetLogAverageOf<DistributionRefArray2D<T, DomainType>>, CanGetLogAverageOfPower<DistributionRefArray2D<T, DomainType>>, CanGetAverageLog<DistributionRefArray2D<T, DomainType>> where T : class, ICloneable, SettableTo<T>, SettableToUniform, Diffable, SettableToProduct<T>, SettableToRatio<T>, SettableToPower<T>, SettableToWeightedSum<T>, CanGetLogAverageOf<T>, CanGetLogAverageOfPower<T>, CanGetAverageLog<T>, IDistribution<DomainType>, Sampleable<DomainType>
Type Parameters
Name | Description |
---|---|
T | Distribution type of an element |
DomainType | Domain type of an element |
Remarks
This is an extension of DistributionArray that requires T to be a reference type. The SetTo and CopyTo methods are overriden to use cloning instead of assignment.
Constructors
DistributionRefArray2D()
Parameterless constructor needed for serialization
Declaration
protected DistributionRefArray2D()
DistributionRefArray2D(T, Int32, Int32)
Constructs a new 2-D distribution array given the lengths of each dimension, and a value
Declaration
public DistributionRefArray2D(T value, int length0, int length1)
Parameters
Type | Name | Description |
---|---|---|
T | value | |
Int32 | length0 | |
Int32 | length1 |
DistributionRefArray2D(T[,])
Constructs a new 2-D distribution array given a 2-D array of distributions
Declaration
public DistributionRefArray2D(T[, ] array)
Parameters
Type | Name | Description |
---|---|---|
T[,] | array |
DistributionRefArray2D(Array2D<T>)
Copy constructor.
Declaration
public DistributionRefArray2D(Array2D<T> that)
Parameters
Type | Name | Description |
---|---|---|
Array2D<T> | that |
DistributionRefArray2D(Int32, Int32)
Constructs a new 2-D distribution array given the lengths of each dimension
Declaration
public DistributionRefArray2D(int length0, int length1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length0 | |
Int32 | length1 |
DistributionRefArray2D(Int32, Int32, T[])
Constructs a new 2-D distribution array given the lengths of each dimension, and an array of values to reference
Declaration
public DistributionRefArray2D(int length0, int length1, T[] valuesRef)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length0 | |
Int32 | length1 | |
T[] | valuesRef | Array of values to reference |
DistributionRefArray2D(Int32, Int32, Func<Int32, Int32, T>)
Constructs a new 2-D distribution array given the lengths of each dimension and initial values.
Declaration
public DistributionRefArray2D(int length0, int length1, Func<int, int, T> init)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length0 | |
Int32 | length1 | |
Func<Int32, Int32, T> | init | Function that maps an index to a value. |
Remarks
The references returned by init
are not copied. They are placed directly into the array.
Methods
Clone()
Clone the distribution
Declaration
public override object Clone()
Returns
Type | Description |
---|---|
Object |
Overrides
CopyTo(T[], Int32)
Set the parameters of array[i] to match the marginal distribution of element i, creating a new distribution if array[i] was null, starting at a given index
Declaration
public override void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | |
Int32 | arrayIndex | The index to start at |
Overrides
CopyTo(T[,])
Set the parameters of array[i,j] to match the marginal distribution of element (i,j), creating a new distribution if array[i,j] was null
Declaration
public override void CopyTo(T[, ] array)
Parameters
Type | Name | Description |
---|---|---|
T[,] | array |
Overrides
GetAverageLog(DistributionRefArray2D<T, DomainType>)
The expected logarithm of that distribution under this distribution.
Declaration
public double GetAverageLog(DistributionRefArray2D<T, DomainType> that)
Parameters
Type | Name | Description |
---|---|---|
DistributionRefArray2D<T, DomainType> | that | The distribution to take the logarithm of. |
Returns
Type | Description |
---|---|
Double |
|
Remarks
This is also known as the cross entropy.
GetLogAverageOf(DistributionRefArray2D<T, DomainType>)
The log-probability that two distributions would draw the same sample.
Declaration
public double GetLogAverageOf(DistributionRefArray2D<T, DomainType> that)
Parameters
Type | Name | Description |
---|---|---|
DistributionRefArray2D<T, DomainType> | that |
Returns
Type | Description |
---|---|
Double |
|
Remarks
This can be considered a type of inner product between distributions. Another name might be "LogAverage" to go with "GetAverageLog".
GetLogAverageOfPower(DistributionRefArray2D<T, DomainType>, Double)
Get the integral of this distribution times another distribution raised to a power.
Declaration
public double GetLogAverageOfPower(DistributionRefArray2D<T, DomainType> that, double power)
Parameters
Type | Name | Description |
---|---|---|
DistributionRefArray2D<T, DomainType> | that | |
Double | power |
Returns
Type | Description |
---|---|
Double |
InitializeTo(T)
Initialises all the values in this 2-D distribution array to clones of the given value
Declaration
protected void InitializeTo(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value |
InitializeTo(T[,])
Initialise the values in this 2-D distribution array to clones of the values in a given 2-D array of distributions
Declaration
protected void InitializeTo(T[, ] array)
Parameters
Type | Name | Description |
---|---|---|
T[,] | array |
Remarks
Given array and this array must be the same length in each dimension
Sample(DomainType[,])
Get a sample from the distribution
Declaration
public override DomainType[, ] Sample(DomainType[, ] result)
Parameters
Type | Name | Description |
---|---|---|
DomainType[,] | result | Where to put the result |
Returns
Type | Description |
---|---|
DomainType[,] | A sample |
Overrides
SetAllElementsTo(T)
Set the parameters of this distribution so that all marginals equal the given distribution (by value)
Declaration
public override void SetAllElementsTo(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value |
Overrides
SetItemsOf(T[], Int32)
Set the parameters of array[i] to match the marginal distribution of element i, starting at a given index
Declaration
protected void SetItemsOf(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | |
Int32 | arrayIndex | The index to start at |
SetItemsOf(T[,])
Set the parameters of array[i,j] to match the marginal distribution of element (i,j)
Declaration
protected void SetItemsOf(T[, ] array)
Parameters
Type | Name | Description |
---|---|---|
T[,] | array |
SetTo(T[,])
Set the parameters of this distribution so that the marginals match the given distributions (by value)
Declaration
public override void SetTo(T[, ] array)
Parameters
Type | Name | Description |
---|---|---|
T[,] | array |
Overrides
Remarks
Given array and this array must be the same length in each dimension
SetTo(DistributionRefArray2D<T, DomainType>)
Set the parameters of this distribution to match those of the given distribution (by value)
Declaration
public void SetTo(DistributionRefArray2D<T, DomainType> that)
Parameters
Type | Name | Description |
---|---|---|
DistributionRefArray2D<T, DomainType> | that |
SetToPower(DistributionRefArray2D<T, DomainType>, Double)
Set the parameters to represent the power of a source distribution to some exponent
Declaration
public void SetToPower(DistributionRefArray2D<T, DomainType> a, double exponent)
Parameters
Type | Name | Description |
---|---|---|
DistributionRefArray2D<T, DomainType> | a | The source distribution array |
Double | exponent | The exponent |
SetToProduct(DistributionRefArray2D<T, DomainType>, DistributionRefArray2D<T, DomainType>)
Set the parameters to represent the product of two distributions
Declaration
public void SetToProduct(DistributionRefArray2D<T, DomainType> a, DistributionRefArray2D<T, DomainType> b)
Parameters
Type | Name | Description |
---|---|---|
DistributionRefArray2D<T, DomainType> | a | The first distribution array |
DistributionRefArray2D<T, DomainType> | b | The second distribution array |
SetToRatio(DistributionRefArray2D<T, DomainType>, DistributionRefArray2D<T, DomainType>, Boolean)
Set the parameters to represent the ratio of two distributions
Declaration
public void SetToRatio(DistributionRefArray2D<T, DomainType> numerator, DistributionRefArray2D<T, DomainType> denominator, bool forceProper)
Parameters
Type | Name | Description |
---|---|---|
DistributionRefArray2D<T, DomainType> | numerator | The numerator distribution array |
DistributionRefArray2D<T, DomainType> | denominator | The denominator distribution array |
Boolean | forceProper | Argument passed to T.SetToRatio |
SetToSum(Double, DistributionRefArray2D<T, DomainType>, Double, DistributionRefArray2D<T, DomainType>)
Set the parameters to match the moments of a mixture of two distributions
Declaration
public void SetToSum(double weight1, DistributionRefArray2D<T, DomainType> a, double weight2, DistributionRefArray2D<T, DomainType> b)
Parameters
Type | Name | Description |
---|---|---|
Double | weight1 | The first weight |
DistributionRefArray2D<T, DomainType> | a | The first distribution array |
Double | weight2 | The second weight |
DistributionRefArray2D<T, DomainType> | b | The second distribution array |