Class BernoulliIntegerSubset
Represents a sparse list of Bernoulli distributions considered as a distribution over a variable-sized list of integers, which are the indices of elements in the boolean list with value 'true'.
Implements
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Distributions
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[Quality(QualityBand.Stable)]
public class BernoulliIntegerSubset : IDistribution<IList<int>>, IDistribution, ICloneable, Diffable, SettableToUniform, HasPoint<IList<int>>, CanGetLogProb<IList<int>>, Sampleable<IList<int>>, SettableToProduct<BernoulliIntegerSubset>, SettableToProduct<BernoulliIntegerSubset, BernoulliIntegerSubset>, SettableTo<BernoulliIntegerSubset>, SettableToPower<BernoulliIntegerSubset>, SettableToRatio<BernoulliIntegerSubset>, SettableToRatio<BernoulliIntegerSubset, BernoulliIntegerSubset>, SettableToWeightedSum<BernoulliIntegerSubset>, CanGetLogAverageOf<BernoulliIntegerSubset>, CanGetLogAverageOfPower<BernoulliIntegerSubset>, CanGetAverageLog<BernoulliIntegerSubset>
Constructors
BernoulliIntegerSubset()
Initializes a new instance of the BernoulliIntegerSubset class.
Declaration
public BernoulliIntegerSubset()
BernoulliIntegerSubset(ISparseList<Bernoulli>)
Initializes a new instance of the BernoulliIntegerSubset class from a sparse list of Bernoulli distributions.
Declaration
protected BernoulliIntegerSubset(ISparseList<Bernoulli> bernoullis)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Bernoulli> | bernoullis | The sparse list of Bernoulli distributions. |
BernoulliIntegerSubset(ISparseList<Bernoulli>, Double)
Initializes a new instance of the BernoulliIntegerSubset class from a sparse list of Bernoulli distributions.
Declaration
protected BernoulliIntegerSubset(ISparseList<Bernoulli> bernoullis, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Bernoulli> | bernoullis | The sparse list of Bernoulli distributions. |
| Double | tolerance | The tolerance. |
BernoulliIntegerSubset(BernoulliIntegerSubset)
Initializes a new instance of the BernoulliIntegerSubset class from an instance of the same type.
Declaration
protected BernoulliIntegerSubset(BernoulliIntegerSubset that)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | that | The instance to copy. |
BernoulliIntegerSubset(SparseBernoulliList)
Initializes a new instance of the BernoulliIntegerSubset class from a SparseBernoulliList instance.
Declaration
protected BernoulliIntegerSubset(SparseBernoulliList sparseBernoulliList)
Parameters
| Type | Name | Description |
|---|---|---|
| SparseBernoulliList | sparseBernoulliList | SparseBernoulliList instance. |
BernoulliIntegerSubset(Int32)
Initializes a new instance of the BernoulliIntegerSubset class with the specified number of elements all of which are set to uniform.
Declaration
protected BernoulliIntegerSubset(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
BernoulliIntegerSubset(Int32, Bernoulli)
Initializes a new instance of the BernoulliIntegerSubset class of the given size, and assigns all elements to the specified common value.
Declaration
protected BernoulliIntegerSubset(int size, Bernoulli commonValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
BernoulliIntegerSubset(Int32, Bernoulli, List<ValueAtIndex<Bernoulli>>)
Initializes a new instance of the BernoulliIntegerSubset class of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is, so MUST be sorted by index and must not be modified externally after being passed in.
Declaration
protected BernoulliIntegerSubset(int size, Bernoulli commonValue, List<ValueAtIndex<Bernoulli>> sortedSparseValues)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
| List<ValueAtIndex<Bernoulli>> | sortedSparseValues | The sorted list of non-common values. |
BernoulliIntegerSubset(Int32, Bernoulli, List<ValueAtIndex<Bernoulli>>, Double)
Initializes a new instance of the BernoulliIntegerSubset class of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is, so MUST be sorted by index and must not be modified externally after being passed in.
Declaration
protected BernoulliIntegerSubset(int size, Bernoulli commonValue, List<ValueAtIndex<Bernoulli>> sortedSparseValues, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
| List<ValueAtIndex<Bernoulli>> | sortedSparseValues | The sorted list of non-common values. |
| Double | tolerance | The tolerance for the approximation. |
BernoulliIntegerSubset(Int32, Bernoulli, Double)
Initializes a new instance of the BernoulliIntegerSubset class of the given size, and assigns all elements to the specified common value.
Declaration
protected BernoulliIntegerSubset(int size, Bernoulli commonValue, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
| Double | tolerance | The tolerance for the approximation. |
BernoulliIntegerSubset(Int32, Double)
Initializes a new instance of the BernoulliIntegerSubset class with the specified number of elements all of which are set to uniform.
Declaration
protected BernoulliIntegerSubset(int size, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Double | tolerance | The tolerance for the approximation. |
Properties
Dimension
Gets a value representing the size of the discrete domain.
Declaration
[IgnoreDataMember]
public int Dimension { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
IsPointMass
Gets a value indicating whether this is a point mass or not.
Declaration
[IgnoreDataMember]
public bool IsPointMass { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Point
Gets or sets the distribution as a point value integer array. This is a sparse method - the integers specify the indices where elements are true - all other elements are false.
Declaration
[IgnoreDataMember]
public IList<int> Point { get; set; }
Property Value
| Type | Description |
|---|---|
| IList<Int32> |
SparseBernoulliList
Gets or sets the embedded SparseBernoulliList instance which maintains the parameters of this distribution.
Declaration
public SparseBernoulliList SparseBernoulliList { get; set; }
Property Value
| Type | Description |
|---|---|
| SparseBernoulliList |
Methods
Clone()
Clones this object.
Declaration
public object Clone()
Returns
| Type | Description |
|---|---|
| Object | The clone. |
FromBernoulli(Int32, Bernoulli)
Returns a new instance of the BernoulliIntegerSubset class with the specified number of elements all of which are set to the specified Bernoulli instance.
Declaration
public static BernoulliIntegerSubset FromBernoulli(int size, Bernoulli commonValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromBernoulli(Int32, Bernoulli, Double)
Initializes a new instance of the BernoulliIntegerSubset class with the specified number of elements all of which are set to the specified Bernoulli instance.
Declaration
public static BernoulliIntegerSubset FromBernoulli(int size, Bernoulli commonValue, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
| Double | tolerance | The tolerance for the approximation. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromLogOdds(ISparseList<Double>)
Returns a new instance of the BernoulliIntegerSubset class of a given size from a sparse list of log odds
Declaration
public static BernoulliIntegerSubset FromLogOdds(ISparseList<double> logOdds)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | logOdds | The sparse list of log odds. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromLogOdds(ISparseList<Double>, Double)
Returns a new instance of the BernoulliIntegerSubset class of a given size from a sparse list of log odds.
Declaration
public static BernoulliIntegerSubset FromLogOdds(ISparseList<double> logOdds, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | logOdds | The sparse list of log odds. |
| Double | tolerance | The tolerance for the approximation. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromLogOdds(Int32, Double)
Returns a new instance of the BernoulliIntegerSubset class of a given size with each element having a given log odds.
Declaration
public static BernoulliIntegerSubset FromLogOdds(int size, double logOdds)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Double | logOdds | The desired log odds. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromLogOdds(Int32, Double, Double)
Returns a new instance of the BernoulliIntegerSubset class of a given size with each element having a given log odds.
Declaration
public static BernoulliIntegerSubset FromLogOdds(int size, double logOdds, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Double | logOdds | The desired log odds. |
| Double | tolerance | The tolerance for the approximation. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromProbTrue(ISparseList<Double>)
Returns a new instance of the BernoulliIntegerSubset class of a given size from a sparse list of probability true.
Declaration
public static BernoulliIntegerSubset FromProbTrue(ISparseList<double> probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | probTrue | The sparse list of probability of true. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromProbTrue(ISparseList<Double>, Double)
Returns a new instance of the BernoulliIntegerSubset class of a given size from a sparse list of probability true.
Declaration
public static BernoulliIntegerSubset FromProbTrue(ISparseList<double> probTrue, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | probTrue | The sparse list of probability of true. |
| Double | tolerance | The tolerance for the approximation. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromProbTrue(Int32, Double)
Returns a new instance of the BernoulliIntegerSubset class of a given size with each element having a given probability of true.
Declaration
public static BernoulliIntegerSubset FromProbTrue(int size, double probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Double | probTrue | The desired probability of true. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromProbTrue(Int32, Double, Double)
Returns a new instance of the BernoulliIntegerSubset class of a given size with each element having a given probability of true.
Declaration
public static BernoulliIntegerSubset FromProbTrue(int size, double probTrue, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Double | probTrue | The desired probability of true. |
| Double | tolerance | The tolerance for the approximation. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromSize(Int32)
Returns a new instance of the BernoulliIntegerSubset class with the specified number of elements all of which are set to uniform.
Declaration
public static BernoulliIntegerSubset FromSize(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromSize(Int32, Double)
Initializes a new instance of the BernoulliIntegerSubset class with the specified number of elements all of which are set to uniform.
Declaration
public static BernoulliIntegerSubset FromSize(int size, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Double | tolerance | The tolerance for the approximation. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromSparseBernoulliList(SparseBernoulliList)
Declaration
[Construction(new string[]{"SparseBernoulliList"})]
public static BernoulliIntegerSubset FromSparseBernoulliList(SparseBernoulliList list)
Parameters
| Type | Name | Description |
|---|---|---|
| SparseBernoulliList | list |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset |
FromSparseList(ISparseList<Bernoulli>)
Returns a new instance of the BernoulliIntegerSubset class from a sparse list of Bernoulli distributions.
Declaration
public static BernoulliIntegerSubset FromSparseList(ISparseList<Bernoulli> bernoullis)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Bernoulli> | bernoullis | The sparse list of Bernoulli distributions. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromSparseList(ISparseList<Bernoulli>, Double)
Returns a new instance of the BernoulliIntegerSubset class from a sparse list of Bernoulli distributions.
Declaration
public static BernoulliIntegerSubset FromSparseList(ISparseList<Bernoulli> bernoullis, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Bernoulli> | bernoullis | The sparse list of Bernoulli distributions. |
| Double | tolerance | The tolerance. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromSparseValues(Int32, Bernoulli, List<ValueAtIndex<Bernoulli>>)
Returns a new instance of the BernoulliIntegerSubset class of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is, so MUST be sorted by index and must not be modified externally after being passed in.
Declaration
public static BernoulliIntegerSubset FromSparseValues(int size, Bernoulli commonValue, List<ValueAtIndex<Bernoulli>> sortedSparseValues)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
| List<ValueAtIndex<Bernoulli>> | sortedSparseValues | The sorted list of non-common values. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
FromSparseValues(Int32, Bernoulli, List<ValueAtIndex<Bernoulli>>, Double)
Returns a new instance of the BernoulliIntegerSubset class of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is so MUST be sorted by index and must not be modified externally after being passed in.
Declaration
public static BernoulliIntegerSubset FromSparseValues(int size, Bernoulli commonValue, List<ValueAtIndex<Bernoulli>> sortedSparseValues, double tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | size | The size of the list. |
| Bernoulli | commonValue | The common value. |
| List<ValueAtIndex<Bernoulli>> | sortedSparseValues | The sorted list of non-common values. |
| Double | tolerance | The tolerance for the approximation. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The new BernoulliIntegerSubset instance. |
GetAverageLog(BernoulliIntegerSubset)
The expected logarithm of that distribution under this distribution.
Declaration
public double GetAverageLog(BernoulliIntegerSubset that)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | that | The distribution to take the logarithm of. |
Returns
| Type | Description |
|---|---|
| Double |
|
Remarks
This is also known as the cross entropy.
GetLogAverageOf(BernoulliIntegerSubset)
Gets the log of the integral of the product of this BernoulliIntegerSubset distribution and another such distribution.
Declaration
public double GetLogAverageOf(BernoulliIntegerSubset that)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | that | The other distribution. |
Returns
| Type | Description |
|---|---|
| Double | The log average of the other distribution under this distribution. |
GetLogAverageOfPower(BernoulliIntegerSubset, Double)
Returns the log of the integral of the product of BernoulliIntegerSubset distribution and another BernoulliIntegerSubset distribution raised to a power.
Declaration
public double GetLogAverageOfPower(BernoulliIntegerSubset that, double power)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | that | The other distribution. |
| Double | power | The exponent. |
Returns
| Type | Description |
|---|---|
| Double | The average of the power of the other distribution under this distribution. |
GetLogProb(IList<Int32>)
Gets the log probability of the given value under this distribution.
Declaration
public double GetLogProb(IList<int> value)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Int32> | value | The value. |
Returns
| Type | Description |
|---|---|
| Double | The log probability of the given value under this distribution. |
IsUniform()
Gets a value indicating whether this distribution is uniform or not.
Declaration
public bool IsUniform()
Returns
| Type | Description |
|---|---|
| Boolean | True if uniform, false otherwise. |
MaxDiff(Object)
The max difference between this distribution and another distribution.
Declaration
public double MaxDiff(object thatd)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | thatd | The other distribution. |
Returns
| Type | Description |
|---|---|
| Double | The maximum difference between this distribution and the other. |
Sample()
Samples a list of integers from this distribution.
Declaration
public IList<int> Sample()
Returns
| Type | Description |
|---|---|
| IList<Int32> | The sample. |
Sample(ISparseList<Double>)
Samples from a list of Bernoulli distributions with the specified vector of P(true) values.
Declaration
public static IList<int> Sample(ISparseList<double> probTrue)
Parameters
| Type | Name | Description |
|---|---|---|
| ISparseList<Double> | probTrue | the vector of P(true) values. |
Returns
| Type | Description |
|---|---|
| IList<Int32> | The sample. |
Sample(IList<Int32>)
Samples a list of integers from this distribution.
Declaration
public IList<int> Sample(IList<int> result)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Int32> | result | Where to put the resulting sample. |
Returns
| Type | Description |
|---|---|
| IList<Int32> | The sample. |
SetTo(BernoulliIntegerSubset)
Sets this BernoulliIntegerSubset distribution to another such distribution.
Declaration
public void SetTo(BernoulliIntegerSubset value)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | value | The distribution to set. |
SetTo(IEnumerable<Bernoulli>)
Sets this BernoulliIntegerSubset distribution from an enumerable collection of Bernoulli distribution.
Declaration
public void SetTo(IEnumerable<Bernoulli> value)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Bernoulli> | value | The (usually sparse) enumerable collection of Bernoulli distributions. |
SetToPower(BernoulliIntegerSubset, Double)
Sets this BernoulliIntegerSubset distribution to the power another such distribution.
Declaration
public void SetToPower(BernoulliIntegerSubset value, double exponent)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | value | The distribution to be raised to a power. |
| Double | exponent | The exponent. |
SetToProduct(BernoulliIntegerSubset, BernoulliIntegerSubset)
Sets this BernoulliIntegerSubset distribution to a product of two other such distributions.
Declaration
public void SetToProduct(BernoulliIntegerSubset a, BernoulliIntegerSubset b)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | a | The left hand side. |
| BernoulliIntegerSubset | b | The right hand side. |
SetToRatio(BernoulliIntegerSubset, BernoulliIntegerSubset, Boolean)
Sets this BernoulliIntegerSubset distribution to the ratio of two other such distributions.
Declaration
public void SetToRatio(BernoulliIntegerSubset numerator, BernoulliIntegerSubset denominator, bool forceProper = false)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | numerator | The numerator. |
| BernoulliIntegerSubset | denominator | The denominator. |
| Boolean | forceProper | Whether to force the result to be proper. |
SetToSum(Double, BernoulliIntegerSubset, Double, BernoulliIntegerSubset)
Sets this BernoulliIntegerSubset distribution to the weighted sum of two other such distributions.
Declaration
public void SetToSum(double weight1, BernoulliIntegerSubset value1, double weight2, BernoulliIntegerSubset value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Double | weight1 | The first weight. |
| BernoulliIntegerSubset | value1 | The first distribution. |
| Double | weight2 | The second weight. |
| BernoulliIntegerSubset | value2 | The second distribution. |
Remarks
Not yet implemented
SetToUniform()
Sets this sparse Bernoulli list to uniform.
Declaration
public void SetToUniform()
SubsetToList(IList<Int32>, Int32)
Converts index subset to a sparse list of boolean values.
Declaration
public static ISparseList<bool> SubsetToList(IList<int> indices, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<Int32> | indices | The indices. |
| Int32 | length | The length of the boolean list. |
Returns
| Type | Description |
|---|---|
| ISparseList<Boolean> | The equivalent sparse list of boolean values. |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
Operators
Division(BernoulliIntegerSubset, BernoulliIntegerSubset)
Creates a BernoulliIntegerSubset distribution which is the ratio of two others.
Declaration
public static BernoulliIntegerSubset operator /(BernoulliIntegerSubset numerator, BernoulliIntegerSubset denominator)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | numerator | The numerator. |
| BernoulliIntegerSubset | denominator | The denominator. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The resulting BernoulliIntegerSubset distribution. |
ExclusiveOr(BernoulliIntegerSubset, Double)
Creates a BernoulliIntegerSubset distribution which is the power of another.
Declaration
public static BernoulliIntegerSubset operator ^(BernoulliIntegerSubset dist, double exponent)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | dist | The other distribution. |
| Double | exponent | The exponent. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The resulting BernoulliIntegerSubset distribution. |
Multiply(BernoulliIntegerSubset, BernoulliIntegerSubset)
Creates a BernoulliIntegerSubset distribution which is the product of two others.
Declaration
public static BernoulliIntegerSubset operator *(BernoulliIntegerSubset a, BernoulliIntegerSubset b)
Parameters
| Type | Name | Description |
|---|---|---|
| BernoulliIntegerSubset | a | The first distribution. |
| BernoulliIntegerSubset | b | The second distribution. |
Returns
| Type | Description |
|---|---|
| BernoulliIntegerSubset | The resulting BernoulliIntegerSubset distribution. |