Search Results for

    Show / Hide Table of Contents

    Struct ImmutableDiscreteChar

    Represents a distribution over characters.

    Implements
    IImmutableDistribution<Char, ImmutableDiscreteChar>
    IImmutableDistribution
    ICloneable
    Diffable
    CanCreateUniform<ImmutableDiscreteChar>
    CanCreatePointMass<Char, ImmutableDiscreteChar>
    CanGetLogProb<Char>
    CanCreatePartialUniform<ImmutableDiscreteChar>
    CanGetMode<Char>
    CanGetLogAverageOf<ImmutableDiscreteChar>
    CanGetLogAverageOfPower<ImmutableDiscreteChar>
    CanGetAverageLog<ImmutableDiscreteChar>
    CanEnumerateSupport<Char>
    CanComputeProduct<ImmutableDiscreteChar>
    CanComputeProduct<ImmutableDiscreteChar, ImmutableDiscreteChar>
    CanComputeRatio<ImmutableDiscreteChar>
    CanComputeRatio<ImmutableDiscreteChar, ImmutableDiscreteChar>
    CanComputePower<ImmutableDiscreteChar>
    SummableExactly<ImmutableDiscreteChar>
    SummableExactly<ImmutableDiscreteChar, ImmutableDiscreteChar>
    Summable<ImmutableDiscreteChar, ImmutableDiscreteChar>
    Sampleable<Char>
    ISerializable
    IEquatable<ImmutableDiscreteChar>
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.ReferenceEquals(Object, Object)
    Namespace: Microsoft.ML.Probabilistic.Distributions
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    [Quality(QualityBand.Experimental)]
    [Serializable]
    public struct ImmutableDiscreteChar : IImmutableDistribution<char, ImmutableDiscreteChar>, IImmutableDistribution, ICloneable, Diffable, CanCreateUniform<ImmutableDiscreteChar>, CanCreatePointMass<char, ImmutableDiscreteChar>, CanGetLogProb<char>, CanCreatePartialUniform<ImmutableDiscreteChar>, CanGetMode<char>, CanGetLogAverageOf<ImmutableDiscreteChar>, CanGetLogAverageOfPower<ImmutableDiscreteChar>, CanGetAverageLog<ImmutableDiscreteChar>, CanEnumerateSupport<char>, CanComputeProduct<ImmutableDiscreteChar>, CanComputeProduct<ImmutableDiscreteChar, ImmutableDiscreteChar>, CanComputeRatio<ImmutableDiscreteChar>, CanComputeRatio<ImmutableDiscreteChar, ImmutableDiscreteChar>, CanComputePower<ImmutableDiscreteChar>, SummableExactly<ImmutableDiscreteChar>, SummableExactly<ImmutableDiscreteChar, ImmutableDiscreteChar>, Summable<ImmutableDiscreteChar, ImmutableDiscreteChar>, Sampleable<char>, ISerializable, IEquatable<ImmutableDiscreteChar>

    Properties

    IsDigit

    Gets a value indicating whether this distribution equals the distribution created by Digit().

    Declaration
    public readonly bool IsDigit { get; }
    Property Value
    Type Description
    Boolean

    IsInitialized

    Declaration
    public readonly bool IsInitialized { get; }
    Property Value
    Type Description
    Boolean

    IsLetter

    Gets a value indicating whether this distribution equals the distribution created by Letter().

    Declaration
    public readonly bool IsLetter { get; }
    Property Value
    Type Description
    Boolean

    IsLetterOrDigit

    Gets a value indicating whether this distribution equals the distribution created by LetterOrDigit().

    Declaration
    public readonly bool IsLetterOrDigit { get; }
    Property Value
    Type Description
    Boolean

    IsLower

    Gets a value indicating whether this distribution equals the distribution created by Lower().

    Declaration
    public readonly bool IsLower { get; }
    Property Value
    Type Description
    Boolean

    IsPointMass

    Gets whether the distribution parameters represent a point mass.

    Declaration
    public readonly bool IsPointMass { get; }
    Property Value
    Type Description
    Boolean

    IsUpper

    Gets a value indicating whether this distribution equals the distribution created by Upper().

    Declaration
    public readonly bool IsUpper { get; }
    Property Value
    Type Description
    Boolean

    IsWordChar

    Gets a value indicating whether this distribution equals the distribution created by WordChar().

    Declaration
    public readonly bool IsWordChar { get; }
    Property Value
    Type Description
    Boolean

    Item[Char]

    Gets the probability of a given character under this distribution.

    Declaration
    public readonly double this[char value] { get; }
    Parameters
    Type Name Description
    Char value

    The character.

    Property Value
    Type Description
    Double

    The probability of the character under this distribution.

    Point

    Gets the point mass represented by the distribution.

    Declaration
    public readonly char Point { get; }
    Property Value
    Type Description
    Char

    Ranges

    Gets an array of character ranges with associated probabilities.

    Declaration
    public readonly ReadOnlyArray<ImmutableDiscreteChar.CharRange> Ranges { get; }
    Property Value
    Type Description
    ReadOnlyArray<ImmutableDiscreteChar.CharRange>

    An array of character ranges with associated probabilities.

    Methods

    Any()

    Creates a uniform distribution over all characters.

    Declaration
    public static ImmutableDiscreteChar Any()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    AppendRegex(StringBuilder, Boolean)

    Appends a regex expression that represents this character to the supplied string builder.

    Declaration
    public void AppendRegex(StringBuilder stringBuilder, bool useFriendlySymbols = false)
    Parameters
    Type Name Description
    StringBuilder stringBuilder

    The string builder to append to

    Boolean useFriendlySymbols

    Whether to use friendly symbols."

    AppendToString(StringBuilder)

    Declaration
    public void AppendToString(StringBuilder stringBuilder)
    Parameters
    Type Name Description
    StringBuilder stringBuilder

    Clone()

    Creates a copy of this distribution.

    Declaration
    public ImmutableDiscreteChar Clone()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created copy.

    Complement()

    Creates a distribution which is uniform over all characters that have zero probability under this distribution i.e. that are not 'in' this distribution.

    Declaration
    public ImmutableDiscreteChar Complement()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Remarks

    This is useful for defining characters that are not in a particular distribution e.g. not a letter or not a word character.

    Create(IEnumerable<ImmutableDiscreteChar.CharRange>)

    Creates a distribution given a list of constant probability character ranges.

    Declaration
    [Construction(new string[]{"Ranges"})]
    public static ImmutableDiscreteChar Create(IEnumerable<ImmutableDiscreteChar.CharRange> ranges)
    Parameters
    Type Name Description
    IEnumerable<ImmutableDiscreteChar.CharRange> ranges

    The constant-probability character ranges.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Remarks

    The probabilities do not need to be normalized. The character ranges do not need to be sorted.

    CreatePartialUniform()

    Creates a distribution uniform over the support of the current distribution.

    Declaration
    public ImmutableDiscreteChar CreatePartialUniform()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    CreatePointMass(Char)

    Creates a point mass distribution.

    Declaration
    public ImmutableDiscreteChar CreatePointMass(char point)
    Parameters
    Type Name Description
    Char point
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    CreateUniform()

    Creates a uniform distribution

    Declaration
    public ImmutableDiscreteChar CreateUniform()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Digit()

    Creates a uniform distribution over digits '0'..'9'.

    Declaration
    [Construction(UseWhen = "IsDigit")]
    public static ImmutableDiscreteChar Digit()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Divide(ImmutableDiscreteChar, Boolean)

    Computes the product of the current instance and denominator.

    Declaration
    public ImmutableDiscreteChar Divide(ImmutableDiscreteChar denominator, bool forceProper = false)
    Parameters
    Type Name Description
    ImmutableDiscreteChar denominator
    Boolean forceProper

    If true, the result is modified to have parameters in a safe range

    Returns
    Type Description
    ImmutableDiscreteChar

    EnumerateSupport()

    Enumerates over the support of the distribution instance.

    Declaration
    public IEnumerable<char> EnumerateSupport()
    Returns
    Type Description
    IEnumerable<Char>

    The character values with non-zero mass.

    Equals(ImmutableDiscreteChar)

    Checks if that equals to this distribution (i.e. represents the same distribution over characters).

    Declaration
    public bool Equals(ImmutableDiscreteChar that)
    Parameters
    Type Name Description
    ImmutableDiscreteChar that

    The object to compare this distribution with.

    Returns
    Type Description
    Boolean

    true if this distribution is equal to that, false otherwise.

    Equals(Object)

    Checks if obj equals to this distribution (i.e. represents the same distribution over characters).

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    The object to compare this distribution with.

    Returns
    Type Description
    Boolean

    true if this distribution is equal to obj, false otherwise.

    Overrides
    ValueType.Equals(Object)

    FromVector(PiecewiseVector)

    Creates a point character from a vector of (unnormalized) character probabilities.

    Declaration
    public static ImmutableDiscreteChar FromVector(PiecewiseVector vector)
    Parameters
    Type Name Description
    PiecewiseVector vector

    The vector of unnormalized probabilities.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    FromVector(Vector)

    Creates a point character from a vector of (unnormalized) character probabilities.

    Declaration
    public static ImmutableDiscreteChar FromVector(Vector vector)
    Parameters
    Type Name Description
    Vector vector

    The vector of unnormalized probabilities.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    GetAverageLog(ImmutableDiscreteChar)

    The expected logarithm of that distribution under this distribution.

    Declaration
    public double GetAverageLog(ImmutableDiscreteChar distribution)
    Parameters
    Type Name Description
    ImmutableDiscreteChar distribution
    Returns
    Type Description
    Double

    sum_x this.Evaluate(x)*Math.Log(that.Evaluate(x))

    Remarks

    This is also known as the cross entropy.

    GetHashCode()

    Gets the hash code of this distribution.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    The hash code.

    Overrides
    ValueType.GetHashCode()

    GetImpliedCharClasses(ImmutableDiscreteChar.CharClasses)

    Declaration
    public static ImmutableDiscreteChar.CharClasses GetImpliedCharClasses(ImmutableDiscreteChar.CharClasses charClass)
    Parameters
    Type Name Description
    ImmutableDiscreteChar.CharClasses charClass
    Returns
    Type Description
    ImmutableDiscreteChar.CharClasses

    GetLogAverageOf(ImmutableDiscreteChar)

    The log-probability that two distributions would draw the same sample.

    Declaration
    public double GetLogAverageOf(ImmutableDiscreteChar distribution)
    Parameters
    Type Name Description
    ImmutableDiscreteChar distribution
    Returns
    Type Description
    Double

    Math.Log(sum_x this.Evaluate(x)*that.Evaluate(x))

    Remarks

    This can be considered a type of inner product between distributions.

    GetLogAverageOfPower(ImmutableDiscreteChar, Double)

    The log-integral of one distribution times another raised to a power.

    Declaration
    public double GetLogAverageOfPower(ImmutableDiscreteChar distribution, double power)
    Parameters
    Type Name Description
    ImmutableDiscreteChar distribution
    Double power

    The exponent

    Returns
    Type Description
    Double

    Math.Log(sum_x this.Evaluate(x)*Math.Pow(that.Evaluate(x),power))

    Remarks

    This is not the same as GetLogAverageOf(that^power) because it includes the normalization constant of that.

    GetLogProb(Char)

    Evaluate the log of the density function at the specified domain value

    Declaration
    public double GetLogProb(char value)
    Parameters
    Type Name Description
    Char value
    Returns
    Type Description
    Double

    The log density

    GetMode()

    Gets the mode of this distribution.

    Declaration
    public char GetMode()
    Returns
    Type Description
    Char

    The mode.

    GetProbs()

    Gets a vector of character probabilities under this distribution.

    Declaration
    public PiecewiseVector GetProbs()
    Returns
    Type Description
    PiecewiseVector

    A vector of character probabilities.

    InRange(Char, Char)

    Creates a uniform distribution over characters in a given range.

    Declaration
    public static ImmutableDiscreteChar InRange(char start, char end)
    Parameters
    Type Name Description
    Char start

    The start of the range (inclusive).

    Char end

    The end of the range (inclusive).

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    InRanges(Char[])

    Creates a 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.

    Declaration
    public static ImmutableDiscreteChar InRanges(params char[] startEndPairs)
    Parameters
    Type Name Description
    Char[] startEndPairs

    The array of range starts and ends.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    InRanges(IEnumerable<Char>)

    Creates a 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 a sequence whose length must therefore be even.

    Declaration
    public static ImmutableDiscreteChar InRanges(IEnumerable<char> startEndPairs)
    Parameters
    Type Name Description
    IEnumerable<Char> startEndPairs

    The sequence of range starts and ends.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    IsPartialUniform()

    Checks whether the distribution is uniform over its support.

    Declaration
    public bool IsPartialUniform()
    Returns
    Type Description
    Boolean

    true if the distribution is uniform over its support, false otherwise.

    IsUniform()

    Checks whether this distribution is a uniform distribution over all characters.

    Declaration
    public bool IsUniform()
    Returns
    Type Description
    Boolean

    true if this distribution is a uniform distribution over all possible characters, false otherwise.

    Letter()

    Creates a uniform distribution over letters.

    Declaration
    [Construction(UseWhen = "IsLetter")]
    public static ImmutableDiscreteChar Letter()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    LetterOrDigit()

    Creates a uniform distribution over letters and '0'..'9'.

    Declaration
    [Construction(UseWhen = "IsLetterOrDigit")]
    public static ImmutableDiscreteChar LetterOrDigit()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Lower()

    Creates a uniform distribution over lowercase letters.

    Declaration
    [Construction(UseWhen = "IsLower")]
    public static ImmutableDiscreteChar Lower()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    MaxDiff(Object)

    Gets the maximum difference between the character probabilities under this distribution and a given one.

    Declaration
    public double MaxDiff(object distribution)
    Parameters
    Type Name Description
    Object distribution

    The distribution to compute the maximum probability difference with.

    Returns
    Type Description
    Double

    The computed maximum probability difference.

    Multiply(ImmutableDiscreteChar)

    Computes the product of the current instance and other.

    Declaration
    public ImmutableDiscreteChar Multiply(ImmutableDiscreteChar other)
    Parameters
    Type Name Description
    ImmutableDiscreteChar other
    Returns
    Type Description
    ImmutableDiscreteChar

    The product.

    NonWordChar()

    Creates a uniform distribution over all characters except (letter, digit and '_').

    Declaration
    public static ImmutableDiscreteChar NonWordChar()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    OneOf(Char[])

    Creates a distribution which is uniform over the specified set of characters.

    Declaration
    public static ImmutableDiscreteChar OneOf(params char[] chars)
    Parameters
    Type Name Description
    Char[] chars

    The characters.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    OneOf(IEnumerable<Char>)

    Creates a distribution which is uniform over the specified set of characters.

    Declaration
    public static ImmutableDiscreteChar OneOf(IEnumerable<char> chars)
    Parameters
    Type Name Description
    IEnumerable<Char> chars

    The characters.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    PointMass(Char)

    Creates a point mass character distribution.

    Declaration
    public static ImmutableDiscreteChar PointMass(char point)
    Parameters
    Type Name Description
    Char point

    The point.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Pow(Double)

    Computes the value of the current instance raised to a power.

    Declaration
    public ImmutableDiscreteChar Pow(double power)
    Parameters
    Type Name Description
    Double power
    Returns
    Type Description
    ImmutableDiscreteChar

    Read(Func<Int32>, Func<Double>)

    Reads a discrete character.

    Declaration
    public static ImmutableDiscreteChar Read(Func<int> readInt32, Func<double> readDouble)
    Parameters
    Type Name Description
    Func<Int32> readInt32
    Func<Double> readDouble
    Returns
    Type Description
    ImmutableDiscreteChar

    Sample()

    Sample the distribution

    Declaration
    public char Sample()
    Returns
    Type Description
    Char

    The sample value

    Sample(Char)

    Draws a sample from the distribution.

    Declaration
    public char Sample(char result)
    Parameters
    Type Name Description
    Char result

    A pre-allocated storage for the sample (will be ignored).

    Returns
    Type Description
    Char

    The drawn sample.

    Sum(Weight, ImmutableDiscreteChar, Weight)

    Computes a weighted sum of the current and the given distributions

    Declaration
    public ImmutableDiscreteChar Sum(Weight weightThis, ImmutableDiscreteChar other, Weight weightOther)
    Parameters
    Type Name Description
    Weight weightThis

    The weight of the current distribution.

    ImmutableDiscreteChar other

    The given distribution.

    Weight weightOther

    The weight of the given distribution.

    Returns
    Type Description
    ImmutableDiscreteChar

    Sum(Double, ImmutableDiscreteChar, Double)

    Computes a weighted sum of the current and the given distributions

    Declaration
    public ImmutableDiscreteChar Sum(double weightThis, ImmutableDiscreteChar other, double weightOther)
    Parameters
    Type Name Description
    Double weightThis

    The weight of the current distribution.

    ImmutableDiscreteChar other

    The given distribution.

    Double weightOther

    The weight of the given distribution.

    Returns
    Type Description
    ImmutableDiscreteChar

    ToLower(ImmutableDiscreteChar)

    Declaration
    public static ImmutableDiscreteChar ToLower(ImmutableDiscreteChar unnormalizedCharDist)
    Parameters
    Type Name Description
    ImmutableDiscreteChar unnormalizedCharDist
    Returns
    Type Description
    ImmutableDiscreteChar

    ToString()

    Gets a string that represents this distribution.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    A string that represents this distribution.

    Overrides
    ValueType.ToString()

    Uniform()

    Creates a uniform distribution over characters.

    Declaration
    [Construction(UseWhen = "IsUniform")]
    public static ImmutableDiscreteChar Uniform()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    UniformInRange(Char, Char)

    Creates a uniform distribution over characters in a given range.

    Declaration
    public static ImmutableDiscreteChar UniformInRange(char start, char end)
    Parameters
    Type Name Description
    Char start

    The start of the range (inclusive).

    Char end

    The end of the range (inclusive).

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    UniformInRanges(Char[])

    Creates a 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.

    Declaration
    public static ImmutableDiscreteChar UniformInRanges(params char[] startEndPairs)
    Parameters
    Type Name Description
    Char[] startEndPairs

    The array of range starts and ends.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    UniformInRanges(IEnumerable<Char>)

    Creates a 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 a sequence whose length must therefore be even.

    Declaration
    public static ImmutableDiscreteChar UniformInRanges(IEnumerable<char> startEndPairs)
    Parameters
    Type Name Description
    IEnumerable<Char> startEndPairs

    The sequence of range starts and ends.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    UniformOver(Char[])

    Creates a distribution which is uniform over the specified set of characters.

    Declaration
    public static ImmutableDiscreteChar UniformOver(params char[] chars)
    Parameters
    Type Name Description
    Char[] chars

    The characters.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    UniformOver(IEnumerable<Char>)

    Creates a distribution which is uniform over the specified set of characters.

    Declaration
    public static ImmutableDiscreteChar UniformOver(IEnumerable<char> chars)
    Parameters
    Type Name Description
    IEnumerable<Char> chars

    The characters.

    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Upper()

    Creates a uniform distribution over uppercase letters.

    Declaration
    [Construction(UseWhen = "IsUpper")]
    public static ImmutableDiscreteChar Upper()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Whitespace()

    Creates a uniform distribution over whitespace characters ('\t'..'\r', ' ').

    Declaration
    public static ImmutableDiscreteChar Whitespace()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    WordChar()

    Creates a uniform distribution over word characters (letter, digit and '_').

    Declaration
    [Construction(UseWhen = "IsWordChar")]
    public static ImmutableDiscreteChar WordChar()
    Returns
    Type Description
    ImmutableDiscreteChar

    The created distribution.

    Write(Action<Int32>, Action<Double>)

    Writes a discrete character.

    Declaration
    public void Write(Action<int> writeInt32, Action<double> writeDouble)
    Parameters
    Type Name Description
    Action<Int32> writeInt32
    Action<Double> writeDouble

    Explicit Interface Implementations

    ICloneable.Clone()

    Creates a copy of this distribution.

    Declaration
    object ICloneable.Clone()
    Returns
    Type Description
    Object

    The created copy.

    ISerializable.GetObjectData(SerializationInfo, StreamingContext)

    Declaration
    void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    SerializationInfo info
    StreamingContext context

    Implements

    IImmutableDistribution<T, TThis>
    IImmutableDistribution
    System.ICloneable
    Diffable
    CanCreateUniform<TDist>
    CanCreatePointMass<T, TDist>
    CanGetLogProb<T>
    CanCreatePartialUniform<TDist>
    CanGetMode<ModeType>
    CanGetLogAverageOf<T>
    CanGetLogAverageOfPower<T>
    CanGetAverageLog<T>
    CanEnumerateSupport<T>
    CanComputeProduct<T>
    CanComputeProduct<TOther, TResult>
    CanComputeRatio<T>
    CanComputeRatio<TDenominator, TResult>
    CanComputePower<TDist>
    SummableExactly<T>
    SummableExactly<TOther, TResult>
    Summable<TOther, TResult>
    Sampleable<T>
    System.Runtime.Serialization.ISerializable
    System.IEquatable<T>
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.