Search Results for

    Show / Hide Table of Contents

    Class Table

    Used to represent probability distributions, conditional probability distributions, joint probability distributions and more general potentials, over a number of discrete variables.

    Inheritance
    System.Object
    Table
    Implements
    IDistribution
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: BayesServer
    Assembly: BayesServer.dll
    Syntax
    public sealed class Table : IDistribution
    Remarks

    The order of variables in a table is determined by the order in which variables are created (and also time for temporal variables). However we recommend that you avoid using functions that require any knowledge of this ordering unless you are writing low level functions. Instead of needing an index, you can use the get and set methods that take States/Variables as parameters. (indexer methods for C#). This renders the ordering an implementation detail.

    Constructors

    Table(Node)

    Initializes a new instance of the Table class with the specified node variables. All values are initialized to zero.

    Declaration
    public Table(Node node)
    Parameters
    Type Name Description
    Node node

    The node whose variables are used to construct the Table.

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a node variable has zero states.

    Table(Node, Nullable<Int32>)

    Initializes a new instance of the Table class with the specified node variable at the specified time. All values are initialized to zero.

    Declaration
    public Table(Node node, int? time)
    Parameters
    Type Name Description
    Node node

    The node whose variable is used to construct the Table.

    System.Nullable<System.Int32> time

    The time for the node variable. Can be null.

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a node variable has zero states.

    Table(Node[])

    Initializes a new instance of the Table class with all the variables from the supplied nodes. All values are initialized to zero.

    Declaration
    public Table(params Node[] nodes)
    Parameters
    Type Name Description
    Node[] nodes

    The Node instances.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if nodes is null.

    System.ArgumentException

    Raised if a null or duplicate variable is detected or if a variable has zero states.

    Table(Table)

    Initializes a new instance of the Table class, copying the table passed in.

    Declaration
    public Table(Table table)
    Parameters
    Type Name Description
    Table table

    The table to copy.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if table is null.

    Table(Table, Boolean)

    Initializes a new instance of the Table class, with the same structure as an existing table, copying the values if requested.

    Declaration
    public Table(Table table, bool copyValues)
    Parameters
    Type Name Description
    Table table

    The table to copy.

    System.Boolean copyValues

    if set to true the values from table are copied, otherwise all values are initialized to zero.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if table is null.

    Table(Table, Boolean, Nullable<Int32>)

    Initializes a new instance of the Table class, with the same structure as an existing table, copying the values if requested, and optionally shifting any times.

    Declaration
    public Table(Table table, bool copyValues, int? timeShift)
    Parameters
    Type Name Description
    Table table

    The table to copy.

    System.Boolean copyValues

    if set to true the values from table are copied, otherwise all values are initialized to zero.

    System.Nullable<System.Int32> timeShift

    If supplied shifts any times embedded in the source table by the specified number of units.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if table is null.

    Table(Table, Nullable<Int32>)

    Initializes a new instance of the Table class, copying the table passed in, however adjusting any times by the timeShift.

    Declaration
    public Table(Table table, int? timeShift)
    Parameters
    Type Name Description
    Table table

    The table to copy.

    System.Nullable<System.Int32> timeShift

    The number of units to shift any time values associated with variables.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if table is null.

    Table(Variable)

    Initializes a new instance of the Table class with a single Variable. All values are initialized to zero.

    Declaration
    public Table(Variable variable)
    Parameters
    Type Name Description
    Variable variable

    The variable.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised when variable is null.

    Table(Variable, Nullable<Int32>)

    Initializes a new instance of the Table class with a single Variable and time. All values are initialized to zero.

    Declaration
    public Table(Variable variable, int? time)
    Parameters
    Type Name Description
    Variable variable

    The variable.

    System.Nullable<System.Int32> time

    The variable time. Can be null for non temporal nodes.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised when variable is null.

    Table(Variable[])

    Initializes a new instance of the Table class with the specified variables. All values are initialized to zero.

    Declaration
    public Table(params Variable[] variables)
    Parameters
    Type Name Description
    Variable[] variables

    The variables.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if variables is null.

    System.ArgumentException

    Raised if a duplicate variable-time combination is detected in variables, or if a variable has zero states.

    Table(VariableContext)

    Initializes a new instance of the Table class from a single VariableContext. All values are initialized to zero.

    Declaration
    public Table(VariableContext variableContext)
    Parameters
    Type Name Description
    VariableContext variableContext

    The variable context.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised when variableContext is null.

    Table(VariableContext[], Int32)

    Initializes a new instance of the Table class with count variable contexts taken from buffer. All values are initialized to zero.

    Declaration
    public Table(VariableContext[] buffer, int count)
    Parameters
    Type Name Description
    VariableContext[] buffer

    The buffer of VariableContext instances.

    System.Int32 count

    The number of items to read from buffer.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if buffer is null.

    System.ArgumentException

    Raised if a null or duplicate variable-time combination is detected in buffer, or if a variable has zero states.

    Table(VariableContext[], Int32, HeadTail)

    Initializes a new instance of the Table class with count variable contexts taken from buffer. All values are initialized to zero.

    Declaration
    public Table(VariableContext[] buffer, int count, HeadTail headTail)
    Parameters
    Type Name Description
    VariableContext[] buffer

    The buffer of VariableContext instances.

    System.Int32 count

    The number of items to read from buffer.

    HeadTail headTail

    Overrides the Head or Tail value found in each VariableContext.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if buffer is null.

    System.ArgumentException

    Raised if a null or duplicate variable-time combination is detected in buffer, or if a variable has zero states.

    Table(VariableContextCollection)

    Initializes a new instance of the Table class with the variables specified in variableContexts. All values are initialized to zero.

    Declaration
    public Table(VariableContextCollection variableContexts)
    Parameters
    Type Name Description
    VariableContextCollection variableContexts

    The variables, times, and head/tail specifications to include in the distribution.

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a duplicate variable-time combination is detected in variableContexts, or if a variable has zero states.

    Table(IList<Node>)

    Initializes a new instance of the Table class with all the variables from the supplied nodes. All values are initialized to zero.

    Declaration
    public Table(IList<Node> nodes)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Node> nodes

    The Node instances.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if nodes is null.

    System.ArgumentException

    Raised if a null or duplicate variable is detected or if a variable has zero states.

    Table(IList<Node>, HeadTail)

    Initializes a new instance of the Table class with all the variables from the supplied nodes. All values are initialized to zero.

    Declaration
    public Table(IList<Node> nodes, HeadTail headTail)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Node> nodes

    The Node instances.

    HeadTail headTail

    Specifies whether the node variables should be marked as Head or Tail.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if nodes is null.

    System.ArgumentException

    Raised if a null or duplicate variable is detected or if a variable has zero states.

    Table(IList<Variable>)

    Initializes a new instance of the Table class with the specified variables. All values are initialized to zero.

    Declaration
    public Table(IList<Variable> variables)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Variable> variables

    The variables.

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a duplicate variable is detected in variables, or if a variable has zero states.

    Table(IList<Variable>, HeadTail)

    Initializes a new instance of the Table class with the specified variables. All values are initialized to zero.

    Declaration
    public Table(IList<Variable> variables, HeadTail headTail)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Variable> variables

    The variables.

    HeadTail headTail

    Specifies whether the variables should be marked as Head or Tail.

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a duplicate variable is detected in variables, or if a variable has zero states.

    Table(IList<Variable>, Nullable<Int32>)

    Initializes a new instance of the Table class with the specified variables, at an optional time. All values are initialized to zero.

    Declaration
    public Table(IList<Variable> variables, int? time)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Variable> variables

    The variables.

    System.Nullable<System.Int32> time

    The time for the variables. Can be null.

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a duplicate variable/time combination is detected in variables, or if a variable has zero states.

    Table(IList<Variable>, Nullable<Int32>, HeadTail)

    Initializes a new instance of the Table class with the specified variables, at an optional time. All values are initialized to zero.

    Declaration
    public Table(IList<Variable> variables, int? time, HeadTail headTail)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<Variable> variables

    The variables.

    System.Nullable<System.Int32> time

    The time for the variables. Can be null.

    HeadTail headTail

    Specifies whether the variables should be marked as Head or Tail.

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a duplicate variable/time combination is detected in variables, or if a variable has zero states.

    Table(IList<VariableContext>)

    Initializes a new instance of the Table class with variableContexts specifying which variables to include in the distribution. All distribution values are initialized to zero.

    Declaration
    public Table(IList<VariableContext> variableContexts)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<VariableContext> variableContexts

    The variables, times and head/tail specification.

    Remarks

    Each VariableContext identifies the variable to be included and allows times to be specified for any temporal variables used in Dynamic Bayesian networks. Time must be null unless the variable belongs to a temporal node.

    Each variable is also marked as head or tail. Head variables are those on the left, and tail variables are those on the right in the expression P(A|B).

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a variable-time combination is duplicated in variableContexts, or if a variable has zero states. Note that a variable can appear more than once if the associated times are different.

    Table(IList<VariableContext>, HeadTail)

    Initializes a new instance of the Table class with variableContexts specifying which variables to include in the distribution. All distribution values are initialized to zero.

    Declaration
    public Table(IList<VariableContext> variableContexts, HeadTail headTail)
    Parameters
    Type Name Description
    System.Collections.Generic.IList<VariableContext> variableContexts

    The variables and any times.

    HeadTail headTail

    Overrides the Head or Tail value found in each VariableContext.

    Remarks

    Each VariableContext identifies the variable to be included and allows times to be specified for any temporal variables used in Dynamic Bayesian networks. Time must be null unless the variable belongs to a temporal node.

    Each variable is also marked as head or tail. Head variables are those on the left, and tail variables are those on the right in the expression P(A|B).

    Exceptions
    Type Condition
    System.ArgumentException

    Raised if a variable-time combination is duplicated in variableContexts, or if a variable has zero states. Note that a variable can appear more than once if the associated times are different.

    Properties

    Count

    The data count in the Table. Equals the product of states for each Variable.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    The data count.

    Item[State[]]

    Gets or sets the table value corresponding to the given states.

    Declaration
    public double this[params State[] states] { get; set; }
    Parameters
    Type Name Description
    State[] states

    The variable states that together specify a unique value in this table.

    Property Value
    Type Description
    System.Double

    The table value.

    Remarks

    For example, if the table represents P(A|B) we can access the value corresponding to P(A=True | B=False) by passing in the states A=True and B=False.

    Item[StateContext[]]

    Gets or sets the table value corresponding to the given states and associated times.

    Declaration
    public double this[params StateContext[] states] { get; set; }
    Parameters
    Type Name Description
    StateContext[] states

    The variable states and times that together specify a unique value in this table.

    Property Value
    Type Description
    System.Double

    Item[Int32]

    Gets or sets the Table value at the specified index into the 1-dimensional array. See Table for information on how entries are stored.

    Declaration
    public double this[int index] { get; set; }
    Parameters
    Type Name Description
    System.Int32 index

    The index into the underlying 1-dimensional array.

    Property Value
    Type Description
    System.Double

    The value at the specified index.

    Locked

    Locks or unlocks a distribution.

    Declaration
    public bool Locked { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if locked; otherwise, false.

    Remarks

    The distribution cannot be modified if either Locked is true or Owner is not null.

    Owner

    Gets the current owner, if assigned to a node. A distribution cannot be modified when it is assigned to a node.

    Declaration
    public Node Owner { get; }
    Property Value
    Type Description
    Node

    The owner, or null if not assigned to a node.

    SortedVariables

    Gets the collection of variables in the distribution, sorted by time (which may be null) and the order in which variables were created.

    Declaration
    public VariableContextCollection SortedVariables { get; }
    Property Value
    Type Description
    VariableContextCollection

    Variables sorted by time and the order variables were created.

    Remarks

    All variables in each distribution are sorted, based on their creation order. This is for computational reasons. If you want to access the values with respect to a different variable ordering, see the TableIterator and TableAccessor classes.

    Methods

    Add(Table)

    Adds the values from another table into this instance. Only the Count of each table need match.

    Declaration
    public void Add(Table source)
    Parameters
    Type Name Description
    Table source

    A table whose Count matches this instance.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if the source is null.

    System.ArgumentException

    Raised if the table counts do not match

    System.InvalidOperationException

    Raised if this instance is read only.

    AddAll(Double)

    Adds the specified value onto all table elements.

    Declaration
    public void AddAll(double value)
    Parameters
    Type Name Description
    System.Double value

    The value to add. Can be negative.

    AreAllValuesNonZero()

    Returns true if none of the values in the Table equal zero, or false otherwise.

    Declaration
    public bool AreAllValuesNonZero()
    Returns
    Type Description
    System.Boolean

    True if none of the values are zero; false otherwise.

    Copy()

    Creates a copy of the distribution. The new distribution will not have an owner.

    Declaration
    public IDistribution Copy()
    Returns
    Type Description
    IDistribution

    A copy of this instance.

    Copy(Nullable<Int32>)

    Creates a copy of the distribution, and shifts any times associated with variables by the specified amount. The new distribution will not have an owner.

    Declaration
    public IDistribution Copy(int? timeShift)
    Parameters
    Type Name Description
    System.Nullable<System.Int32> timeShift

    The amount to shift any times present in the distribution. Can be negative.

    Returns
    Type Description
    IDistribution

    A copy of this instance, with shifted times.

    CopyFrom(Double[])

    Copies values from the array into the table.

    Declaration
    public void CopyFrom(double[] data)
    Parameters
    Type Name Description
    System.Double[] data

    Values to copy. The array can be shorter or longer than the Count.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if data is null.

    System.InvalidOperationException

    Raised if this instance is read only.

    CopyTo(Table)

    Copies all values from this instance to the destination Table.

    Declaration
    public void CopyTo(Table destination)
    Parameters
    Type Name Description
    Table destination

    The destination table, which can have a count greater than or equal to this instance.

    Exceptions
    Type Condition
    System.InvalidOperationException

    Raised if the destination table is read only.

    CopyTo(Double[])

    Copies the table values to an array.

    Declaration
    public void CopyTo(double[] destination)
    Parameters
    Type Name Description
    System.Double[] destination

    The destination array, which must have length equal to or greater than this the count of this instance.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if destination is null.

    System.ArgumentException

    Raised if destination is too short.

    Divide(IDistribution)

    Creates a new distribution by dividing this instance by the subset. Also known as the complement.

    Declaration
    public IDistribution Divide(IDistribution subset)
    Parameters
    Type Name Description
    IDistribution subset

    The subset to divide by.

    Returns
    Type Description
    IDistribution

    The new distribution.

    Remarks

    If the resulting distribution were subsequently multiplied by subset, the result would be equivalent to this instance.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if subset is null.

    DivideInPlace(Table)

    Divides this instance in place by the subset. Also known as the complement.

    Declaration
    public void DivideInPlace(Table subset)
    Parameters
    Type Name Description
    Table subset

    The subset to divide by.

    Remarks

    The term 'in place' means that this instance is modified, instead of creating a new distribution.

    If the resulting distribution were subsequently multiplied by subset, the result would be equivalent to this instance.
    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if subset is null.

    System.InvalidOperationException

    Raised if this instance is read only.

    GetMaxValue(out Int32)

    Gets the maximum table value, and the index at which it occurs.

    Declaration
    public double GetMaxValue(out int index)
    Parameters
    Type Name Description
    System.Int32 index

    The first index at which the maximum value occurs.

    Returns
    Type Description
    System.Double

    The maximum table value.

    GetSortedIndex(State[])

    Gets the index of the table element that corresponds to a particular combination of states.

    Declaration
    public int GetSortedIndex(params State[] states)
    Parameters
    Type Name Description
    State[] states

    A state for each variable.

    Returns
    Type Description
    System.Int32

    The index corresponding to the states.

    GetSortedIndex(StateContext[])

    Gets the index of the table element that corresponds to a particular combination of states and their times.

    Declaration
    public int GetSortedIndex(params StateContext[] stateContexts)
    Parameters
    Type Name Description
    StateContext[] stateContexts

    A state and time for each variable. Time can be null for non temporal variables.

    Returns
    Type Description
    System.Int32

    The index corresponding to the states.

    Instantiate(Nullable<Double>[])

    Creates a table with a subset of variables by setting hard evidence on one or more variables.

    Declaration
    public IDistribution Instantiate(double? [] values)
    Parameters
    Type Name Description
    System.Nullable<System.Double>[] values

    An array of nullable state indexes, one for each variable in this Table instance. Values are null for variables with no evidence.

    Returns
    Type Description
    IDistribution

    The Table of instantiated values. I.e. The table after some variables have been set.

    Remarks

    values should contain one entry for each VariableContext in the distribution, however entries can be null.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if values is null.

    System.ArgumentException

    Raised if the length of values does not equal the number of variables in the table.

    System.InvalidOperationException

    Raised if this instance is read only.

    Instantiate(Nullable<Int32>[])

    Creates a table with a subset of variables by setting hard evidence on one or more variables.

    Declaration
    public Table Instantiate(int? [] values)
    Parameters
    Type Name Description
    System.Nullable<System.Int32>[] values

    An array of nullable state indexes, one for each variable in this Table instance. Values are null for variables with no evidence.

    Returns
    Type Description
    Table

    The Table of instantiated values. I.e. The table after some variables have been set.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if values is null.

    System.ArgumentException

    Raised if the length of values does not equal the number of variables in the table.

    System.InvalidOperationException

    Raised if this instance is read only.

    IsReadOnly()

    Indicates whether the distribution is read only.

    Declaration
    public bool IsReadOnly()
    Returns
    Type Description
    System.Boolean

    true if read only; otherwise, false.

    Remarks

    A distribution is read only if it is locked or is assigned to a Node.

    Marginalize(IDistribution)

    Marginalizes (sums) the superset into this instance.

    Declaration
    public void Marginalize(IDistribution superset)
    Parameters
    Type Name Description
    IDistribution superset

    A Table whose variables form a superset of the variables in this instance.

    Remarks

    This method initializes all values to zero before performing the marginalization. If you know that all the values are zero (e.g. when a Table is first created), call an overloaded version of this method.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if superset is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if superset does not contain all the variables in this instance.

    Marginalize(IDistribution, PropagationMethod)

    Marginalizes (sums) the superset into this instance.

    Declaration
    public void Marginalize(IDistribution superset, PropagationMethod propagation)
    Parameters
    Type Name Description
    IDistribution superset

    A Table whose variables form a superset of the variables in this instance.

    PropagationMethod propagation

    The propagation method to use during marginalization.

    Remarks

    This method initializes all values to zero before performing the marginalization. If you know that all the values are zero (e.g. when a Table is first created), call an overloaded version of this method.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if superset is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if superset does not contain all the variables in this instance.

    Marginalize(Table)

    Marginalizes (sums) the superset into this instance.

    Declaration
    public void Marginalize(Table superset)
    Parameters
    Type Name Description
    Table superset

    A Table whose variables form a superset of the variables in this instance.

    Remarks

    This method initializes all values to zero before performing the marginalization. If you know that all the values are zero (e.g. when a Table is first created), call an overloaded version of this method.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if superset is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if superset does not contain all the variables in this instance.

    Marginalize(Table, PropagationMethod)

    Marginalizes (sums) the superset into this instance.

    Declaration
    public void Marginalize(Table superset, PropagationMethod propagation)
    Parameters
    Type Name Description
    Table superset

    A Table whose variables form a superset of the variables in this instance.

    PropagationMethod propagation

    The propagation method to use during marginalization.

    Remarks

    This method initializes all values to zero before performing the marginalization. If you know that all the values are zero (e.g. when a Table is first created), call an overloaded version of this method.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if superset is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if superset does not contain all the variables in this instance.

    Marginalize(Table, Boolean)

    Marginalizes (sums) the superset into this instance.

    Declaration
    public void Marginalize(Table superset, bool initialize)
    Parameters
    Type Name Description
    Table superset

    A Table whose variables form a superset of the variables in this instance.

    System.Boolean initialize

    Set to true if all values should be initialized to 0 before the marginalization.

    Remarks

    By default all table values are zero, however if the Table values are not zero the initialize parameter avoids the need to initialize all values in the distribution to 0 before performing the marginalization.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if superset is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if superset does not contain all the variables in this instance.

    Marginalize(Table, Boolean, PropagationMethod)

    Marginalizes (sums) the superset into this instance.

    Declaration
    public void Marginalize(Table superset, bool initialize, PropagationMethod propagation)
    Parameters
    Type Name Description
    Table superset

    A Table whose variables form a superset of the variables in this instance.

    System.Boolean initialize

    Set to true if all values should be initialized to 0 before the marginalization.

    PropagationMethod propagation

    The propagation method to use during marginalization.

    Remarks

    By default all table values are zero, however if the Table values are not zero the initialize parameter avoids the need to initialize all values in the distribution to 0 before performing the marginalization.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if superset is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if superset does not contain all the variables in this instance.

    MarginalizeLowMemory(Table[])

    Marginalizes (sums) the combined tables, without requiring the memory for the combined distribution.

    Declaration
    public void MarginalizeLowMemory(Table[] tables)
    Parameters
    Type Name Description
    Table[] tables

    The tables whose combined distribution you wish to marginalize.

    Remarks

    This method uses very little memory, however in general will perform worse than the standard Marginalize routines.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if tables is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    MarginalizeLowMemory(Table[], Table.MarginalizeLowMemoryOptions)

    Marginalizes (sums) the combined tables, without requiring the memory for the combined distribution.

    Declaration
    public void MarginalizeLowMemory(Table[] tables, Table.MarginalizeLowMemoryOptions options)
    Parameters
    Type Name Description
    Table[] tables

    The tables whose combined distribution you wish to marginalize.

    Table.MarginalizeLowMemoryOptions options

    Options governing the method, including cancellation.

    Remarks

    This method uses very little memory, however in general will perform worse than the standard Marginalize routines.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if tables is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    Multiply(IDistribution)

    Creates a new distribution by multiplying this instance by another distribution.

    Declaration
    public IDistribution Multiply(IDistribution distribution)
    Parameters
    Type Name Description
    IDistribution distribution

    A distribution to multiply by.

    Returns
    Type Description
    IDistribution

    A new combined distribution.

    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if distribution is null.

    System.ArgumentException

    Raised if the variables in distribution are not contained in this instance.

    MultiplyInPlace(Table)

    Multiplies the subset into this instance.

    Declaration
    public void MultiplyInPlace(Table subset)
    Parameters
    Type Name Description
    Table subset

    A Table whose variables form a subset of the variables in this instance.

    Remarks

    The term 'in place' means that this instance is modified, instead of creating a new distribution.

    By default all table values are zero, so if the Table needs to be initialized to 1 before multiplication use a different overload of this method.
    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if subset is null.

    System.InvalidOperationException

    Raised if this instance is currently read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if the variables in subset are not contained in this instance.

    MultiplyInPlace(Table, Boolean)

    Multiplies the subset into this instance.

    Declaration
    public void MultiplyInPlace(Table subset, bool initialize)
    Parameters
    Type Name Description
    Table subset

    A Table whose variables form a subset of the variables in this instance.

    System.Boolean initialize

    Set to true if all values should be initialized to 1 before the multiplication.

    Remarks

    The term 'in place' means that this instance is modified, instead of creating a new distribution.

    By default all table values are zero, so the initialize parameter avoids the need to initialize all values in the distribution to 1 before performing the multiplication.
    Exceptions
    Type Condition
    System.ArgumentNullException

    Raised if subset is null.

    System.InvalidOperationException

    Raised if this instance is read only, or if any variables are no longer sorted correctly due to modifications of the network.

    System.ArgumentException

    Raised if the variables in subset are not contained in this instance.

    MultiplyInPlace(Double)

    Multiplies all values in the distribution by the specified value.

    Declaration
    public void MultiplyInPlace(double value)
    Parameters
    Type Name Description
    System.Double value

    The value to multiply by.

    Exceptions
    Type Condition
    System.InvalidOperationException

    Raised if this instance is read only.

    NonZero()

    Returns any non zero table values, keyed by index.

    Declaration
    public IEnumerable<KeyValuePair<int, double>> NonZero()
    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Int32, System.Double>>

    All non zero table values, keyed by table index.

    Normalize()

    Normalizes the distribution such that each parent combination sums to 1.

    Declaration
    public bool Normalize()
    Returns
    Type Description
    System.Boolean

    false if a zero sum was found for any parent combination; true otherwise.

    Exceptions
    Type Condition
    System.InvalidOperationException

    Raised if this instance is read only.

    Normalize(Boolean)

    Normalizes the distribution such that each parent combination sums to 1.

    Declaration
    public bool Normalize(bool unifyZeroSum)
    Parameters
    Type Name Description
    System.Boolean unifyZeroSum

    If true, applies a uniform distribution to any parent combinations that sum to zero.

    Returns
    Type Description
    System.Boolean

    false if a zero sum was found for any parent combination; true otherwise

    Exceptions
    Type Condition
    System.InvalidOperationException

    Raised if this instance is read only.

    Randomize(IRandom)

    Randomizes the distribution such that each parent combination sums to 1.

    Declaration
    public void Randomize(IRandom random)
    Parameters
    Type Name Description
    IRandom random

    Random number generator.

    Exceptions
    Type Condition
    System.InvalidOperationException

    Raised if this instance is read only.

    SetAll(Double)

    Sets all values in the Table to a specified value.

    Declaration
    public void SetAll(double value)
    Parameters
    Type Name Description
    System.Double value

    The value to set all elements to.

    Exceptions
    Type Condition
    System.InvalidOperationException

    Raised if this instance is read only.

    StateCount(Int32)

    Gets the number of states of a variable at the time this instance was constructed.

    Declaration
    public int StateCount(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index into SortedVariables.

    Returns
    Type Description
    System.Int32

    The state count.

    StateRepeat(Int32)

    Gets the number of times each state is repeated for a Variable in the Table layout. See Table for details on layout.

    Declaration
    public int StateRepeat(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index into SortedVariables.

    Returns
    Type Description
    System.Int32

    The repeat count for each state.

    Sum()

    Calculates the sum of all values in the Table.

    Declaration
    public double Sum()
    Returns
    Type Description
    System.Double

    The sum of all table values.

    TimeShift(Int32)

    Shifts any times associated with the table variables by the specified number of units.

    Declaration
    public void TimeShift(int units)
    Parameters
    Type Name Description
    System.Int32 units

    The number of time units to shift. Can be negative if required.

    Exceptions
    Type Condition
    System.InvalidOperationException

    Raised if this instance is read only.

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()

    Explicit Interface Implementations

    IDistribution.Outer

    Declaration
    IDistribution IDistribution.Outer { get; }
    Returns
    Type Description
    IDistribution

    IDistribution.Table

    Declaration
    Table IDistribution.Table { get; }
    Returns
    Type Description
    Table

    Implements

    IDistribution

    See Also

    TableAccessor
    TableIterator
    In This Article
    Back to top Copyright Bayes Server Ltd. All rights Reserved.