Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Table

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

The variables in a {@link com.bayesserver.Table} are automatically sorted by time (if any) and {@link com.bayesserver.Variable}. This is for computational reasons.

The {@link com.bayesserver.Table} class stores it's values in a zero based 1-dimensional array, and the right most variable's states toggle fastest. For example if a {@link com.bayesserver.Table} contains 3 binary variables {A,B,C} all with states {T,F} the table layout would be as follows.

ABCIndex
TTT0
TTF1
TFT2
TFF3
FTT4
FTF5
FFT6
FFF7
If a different variable ordering is required see the {@link com.bayesserver.TableIterator} and {@link com.bayesserver.TableAccessor} classes.

see

com.bayesserver.TableAccessor

see

com.bayesserver.TableIterator

Hierarchy

  • Table

Implements

Index

Constructors

constructor

  • Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested.

    exception

    ReferenceError Raised if [table] is null.

    Parameters

    • table: Table

      The table to copy.

    • copyValues: boolean

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested, and optionally shifting any times.

    exception

    ReferenceError Raised if [table] is null.

    Parameters

    • table: Table

      The table to copy.

    • copyValues: boolean

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

    • timeShift: number | null

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable}. All values are initialized to zero.

    exception

    ReferenceError Raised when [variable] is null.

    Parameters

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class from a single {@link com.bayesserver.VariableContext}. All values are initialized to zero.

    exception

    ReferenceError Raised when [variableContext] is null.

    Parameters

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero.

    exception

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

    Parameters

    • variables: IList<Variable>

      The variables.

    • time: number | null

      The time for the variables. Can be null.

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero.

    exception

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

    Parameters

    • variables: IList<Variable>

      The variables.

    • time: number | null

      The time for the variables. Can be null.

    • headTail: HeadTail

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with the variables specified in [variableContexts]. All values are initialized to zero.

    exception

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

    Parameters

    • variableContexts: VariableContextCollection

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

    Returns Table

  • For internal use only.

    Parameters

    • variableContexts: VariableContext[]

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

    • copy: boolean

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested. Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested, and optionally shifting any times. Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable}. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class from a single {@link com.bayesserver.VariableContext}. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the variables specified in [variableContexts]. All values are initialized to zero. For internal use only. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variable at the specified time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable} and time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in. Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in, however adjusting any times by the [timeShift]. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variables. All values are initialized to zero.

    Parameters

    • variableContexts: VariableContext[]

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested. Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested, and optionally shifting any times. Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable}. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class from a single {@link com.bayesserver.VariableContext}. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the variables specified in [variableContexts]. All values are initialized to zero. For internal use only. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variable at the specified time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable} and time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in. Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in, however adjusting any times by the [timeShift]. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variables. All values are initialized to zero.

    Parameters

    • variableContexts: IList<VariableContext>

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested. Initializes a new instance of the {@link com.bayesserver.Table} class, with the same structure as an existing [table], copying the values if requested, and optionally shifting any times. Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable}. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class from a single {@link com.bayesserver.VariableContext}. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables, at an optional time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the variables specified in [variableContexts]. All values are initialized to zero. For internal use only. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variable at the specified time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable} and time. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero. Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in. Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in, however adjusting any times by the [timeShift]. Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variables. All values are initialized to zero.

    Parameters

    • variableContexts: IList<VariableContext>

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

    • headTail: HeadTail

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with the specified variables. All values are initialized to zero.

    exception

    ReferenceError Raised if [variables] is null.

    exception

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

    Parameters

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero.

    exception

    ReferenceError Raised if [buffer] is null.

    exception

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

    Parameters

    • buffer: VariableContext[]

      The buffer of {@link com.bayesserver.VariableContext} instances.

    • count: number

      The number of items to read from [buffer].

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with [count] variable contexts taken from [buffer]. All values are initialized to zero.

    exception

    ReferenceError Raised if [buffer] is null.

    exception

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

    Parameters

    • buffer: VariableContext[]

      The buffer of {@link com.bayesserver.VariableContext} instances.

    • count: number

      The number of items to read from [buffer].

    • headTail: HeadTail

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variable at the specified time. All values are initialized to zero.

    exception

    Error Raised if a node variable has zero states.

    Parameters

    • node: Node

      The node whose variable is used to construct the {@link com.bayesserver.Table}.

    • time: number | null

      The time for the variables. Can be null.

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with a single {@link com.bayesserver.Variable} and time. All values are initialized to zero.

    exception

    ReferenceError Raised when [variable] is null.

    Parameters

    • variable: Variable

      The variable.

    • time: number | null

      The time for the variables. Can be null.

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero.

    exception

    ReferenceError Raised if [nodes] is null.

    exception

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

    Parameters

    • nodes: IList<Node>

      The {@link com.bayesserver.Node} instances.

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero.

    exception

    ReferenceError Raised if [nodes] is null.

    exception

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

    Parameters

    • nodes: Node[]

      The {@link com.bayesserver.Node} instances.

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero.

    exception

    ReferenceError Raised if [nodes] is null.

    exception

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

    Parameters

    • nodes: IList<Node>

      The {@link com.bayesserver.Node} instances.

    • headTail: HeadTail

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with all the variables from the supplied nodes. All values are initialized to zero.

    exception

    ReferenceError Raised if [nodes] is null.

    exception

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

    Parameters

    • nodes: Node[]

      The {@link com.bayesserver.Node} instances.

    • headTail: HeadTail

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in.

    exception

    ReferenceError Raised if [table] is null.

    Parameters

    • table: Table

      The table to copy.

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class, copying the [table] passed in, however adjusting any times by the [timeShift].

    exception

    ReferenceError Raised if [table] is null.

    Parameters

    • table: Table

      The table to copy.

    • timeShift: number | null

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

    Returns Table

  • Initializes a new instance of the {@link com.bayesserver.Table} class with the specified node variables. All values are initialized to zero.

    exception

    Error Raised if a node variable has zero states.

    Parameters

    • node: Node

      The node whose variable is used to construct the {@link com.bayesserver.Table}.

    Returns Table

Properties

_39d9d5f7317c4bb79bd3c1e43b2b4a43

_39d9d5f7317c4bb79bd3c1e43b2b4a43: string | null = null
inheritdoc

Accessors

locked

  • get locked(): boolean
  • set locked(value: boolean): void
  • inheritdoc

    Returns boolean

  • inheritdoc

    Parameters

    • value: boolean

    Returns void

outer

owner

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

    Returns Node

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

size

  • get size(): number
  • The data count in the {@link com.bayesserver.Table}. Equals the product of states for each {@link com.bayesserver.Variable}.

    Returns number

    The data count.

sortedVariables

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

    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 {@link com.bayesserver.TableIterator} and {@link com.bayesserver.TableAccessor} classes.

    Returns VariableContextCollection

    Variables sorted by time and the order variables were created.

table

  • Returns Table

Methods

_setOwner

  • _setOwner(value: Node): void
  • Parameters

    Returns void

_vru_x_

  • Parameters

    Returns void

add

  • add(source: Table): void
  • Adds the values from another table into this instance. Only the

    see

    com.bayesserver.Table#size of each table need match.

    see

    com.bayesserver.Table#size matches this instance.

    exception

    ReferenceError Raised if the [source] is null.

    exception

    Error Raised if the table counts do not match

    exception

    Error Raised if this instance is read only.

    Parameters

    • source: Table

      A table whose

    Returns void

addAll

  • addAll(value: number): void
  • Adds the specified value onto all table elements.

    Parameters

    • value: number

      The value to add. Can be negative.

    Returns void

areAllValuesNonZero

  • areAllValuesNonZero(): boolean
  • Returns true if none of the values in the {@link com.bayesserver.Table} equal zero, or false otherwise.

    Returns 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.

    Returns IDistribution

    A copy of this instance.

  • 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.

    Parameters

    • timeShift: number | null

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

    Returns IDistribution

    A copy of this instance, with shifted times.

copyFrom

  • copyFrom(data: number[]): void
  • Copies values from the array into the table.

    exception

    ReferenceError Raised if [data] is null.

    exception

    Error Raised if this instance is read only.

    Parameters

    • data: number[]

      Values to copy. The array can be shorter or longer than the {@link com.bayesserver.Table#size}.

    Returns void

copyTo

  • copyTo(destination: Table): void
  • copyTo(destination: number[]): void
  • Copies all values from this instance to the destination {@link com.bayesserver.Table}.

    exception

    Error Raised if the destination table is read only.

    Parameters

    • destination: Table

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

    Returns void

  • Copies the table values to an array.

    exception

    ReferenceError Raised if [destination] is null.

    exception

    Error Raised if [destination] is too short.

    Parameters

    • destination: number[]

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

    Returns void

divide

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

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

    exception

    ReferenceError Raised if [subset] is null.

    Parameters

    Returns IDistribution

    The new distribution.

divideInPlace

  • divideInPlace(subset: Table): void
  • Divides this instance in place by the [subset]. Also known as the complement.

    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.

    exception

    ReferenceError Raised if [subset] is null.

    exception

    Error Raised if this instance is read only.

    Parameters

    • subset: Table

      The subset to divide by.

    Returns void

get

  • get(states: State[]): number
  • get(states: StateContext[]): number
  • get(index: number): number
  • Gets the table value corresponding to the given states.

    Parameters

    • states: State[]

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

      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.

    Returns number

    The table value.

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

    Parameters

    • states: StateContext[]

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

    Returns number

  • Gets the {@link com.bayesserver.Table} value at the specified index into the 1-dimensional array. See {@link com.bayesserver.Table} for information on how entries are stored.

    Parameters

    • index: number

      The index into the underlying 1-dimensional array.

    Returns number

    The value at the specified index.

getMaxValue

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

    Returns TableMaxValue

    The maximum table value and the zero based index at which it occurs.

getSortedIndex

  • getSortedIndex(states: State[]): number
  • getSortedIndex(stateContexts: StateContext[]): number
  • Gets the index of the table element that corresponds to a particular combination of states.

    Parameters

    • states: State[]

      A state for each variable.

    Returns number

    The index corresponding to the states.

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

    Parameters

    • stateContexts: StateContext[]

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

    Returns number

    The index corresponding to the states.

instantiate

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

    [values] should contain one entry for each

    see

    com.bayesserver.VariableContext in the distribution, however entries can be null.

    exception

    ReferenceError Raised if [values] is null.

    exception

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

    exception

    Error Raised if this instance is read only.

    Parameters

    • values: number[]

      An array of nullable state indexes, one for each variable in this {@link com.bayesserver.Table} instance. Values are null for variables with no evidence.

    Returns IDistribution

    The {@link com.bayesserver.Table} of instantiated values. I.e. The table after some variables have been set.

isReadOnly

  • isReadOnly(): boolean

marginalize

  • Marginalizes (sums) the [superset] into this instance.

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

    exception

    ReferenceError Raised if [superset] is null.

    exception

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

    exception

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

    Parameters

    • superset: IDistribution

      A {@link com.bayesserver.Table} whose variables form a superset of the variables in this instance.

    Returns void

  • Marginalizes (sums) the [superset] into this instance.

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

    exception

    ReferenceError Raised if [superset] is null.

    exception

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

    exception

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

    Parameters

    • superset: IDistribution

      A {@link com.bayesserver.Table} whose variables form a superset of the variables in this instance.

    • propagation: PropagationMethod

      The propagation method to use during marginalization.

    Returns void

  • Marginalizes (sums) the [superset] into this instance.

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

    exception

    ReferenceError Raised if [superset] is null.

    exception

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

    exception

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

    Parameters

    • superset: Table

      A {@link com.bayesserver.Table} whose variables form a superset of the variables in this instance.

    Returns void

  • Marginalizes (sums) the [superset] into this instance.

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

    exception

    ReferenceError Raised if [superset] is null.

    exception

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

    exception

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

    Parameters

    • superset: Table

      A {@link com.bayesserver.Table} whose variables form a superset of the variables in this instance.

    • propagation: PropagationMethod

      The propagation method to use during marginalization.

    Returns void

  • Marginalizes (sums) the [superset] into this instance.

    By default all table values are zero, however if the {@link com.bayesserver.Table} values are not zero the [initialize] parameter avoids the need to initialize all values in the distribution to 0 before performing the marginalization.

    exception

    ReferenceError Raised if [superset] is null.

    exception

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

    exception

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

    Parameters

    • superset: Table

      A {@link com.bayesserver.Table} whose variables form a superset of the variables in this instance.

    • initialize: boolean

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

    Returns void

  • Marginalizes (sums) the [superset] into this instance.

    By default all table values are zero, however if the {@link com.bayesserver.Table} values are not zero the [initialize] parameter avoids the need to initialize all values in the distribution to 0 before performing the marginalization.

    exception

    ReferenceError Raised if [superset] is null.

    exception

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

    exception

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

    Parameters

    • superset: Table

      A {@link com.bayesserver.Table} whose variables form a superset of the variables in this instance.

    • initialize: boolean

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

    • propagation: PropagationMethod

      The propagation method to use during marginalization.

    Returns void

marginalizeLowMemory

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

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

    exception

    ReferenceError Raised if [tables] is null.

    exception

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

    Parameters

    • tables: Table[]

      The tables whose combined distribution you wish to marginalize.

    Returns void

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

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

    exception

    ReferenceError Raised if [tables] is null.

    exception

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

    Parameters

    • tables: Table[]

      The tables whose combined distribution you wish to marginalize.

    • options: MarginalizeLowMemoryOptions

      Options governing the method, including cancellation.

    Returns void

multiply

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

    exception

    ReferenceError Raised if [distribution] is null.

    exception

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

    Parameters

    Returns IDistribution

    A new combined distribution.

multiplyInPlace

  • multiplyInPlace(value: number): void
  • multiplyInPlace(subset: Table): void
  • multiplyInPlace(subset: Table, initialize: boolean): void
  • Multiplies all values in the distribution by the specified value.

    exception

    Error Raised if this instance is read only.

    Parameters

    • value: number

      The value to multiply by.

    Returns void

  • Multiplies the [subset] into this instance.

    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 {@link com.bayesserver.Table} needs to be initialized to 1 before multiplication use a different overload of this method.

    exception

    ReferenceError Raised if [subset] is null.

    exception

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

    exception

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

    Parameters

    • subset: Table

      A {@link com.bayesserver.Table} whose variables form a subset of the variables in this instance.

    Returns void

  • Multiplies the [subset] into this instance.

    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.

    exception

    ReferenceError Raised if [subset] is null.

    exception

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

    exception

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

    Parameters

    • subset: Table

      A {@link com.bayesserver.Table} whose variables form a subset of the variables in this instance.

    • initialize: boolean

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

    Returns void

nonZero

  • Returns any non zero table values, keyed by index.

    Parameters

    Returns void

normalize

  • normalize(unifyZeroSum: boolean): boolean
  • normalize(): boolean
  • Normalizes the distribution such that each parent combination sums to 1.

    exception

    Error Raised if this instance is read only.

    Parameters

    • unifyZeroSum: boolean

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

    Returns boolean

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

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

    exception

    Error Raised if this instance is read only.

    Returns boolean

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

randomize

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

    exception

    Error Raised if this instance is read only.

    Parameters

    • random: IRandom

      Random number generator.

    Returns void

set

  • set(value: number, states: State[]): void
  • set(value: number, states: StateContext[]): void
  • set(index: number, value: number): void
  • Sets the table value corresponding to the given states.

    Parameters

    • value: number
    • states: State[]

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

      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.

    Returns void

  • Sets the table value corresponding to the given states and associated times.

    Parameters

    • value: number
    • states: StateContext[]

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

    Returns void

  • Sets the {@link com.bayesserver.Table} value at the specified index into the 1-dimensional array. See {@link com.bayesserver.Table} for information on how entries are stored.

    Parameters

    • index: number

      The index into the underlying 1-dimensional array.

    • value: number

    Returns void

setAll

  • setAll(value: number): void
  • Sets all values in the {@link com.bayesserver.Table} to a specified value.

    exception

    Error Raised if this instance is read only.

    Parameters

    • value: number

      The value to set all elements to.

    Returns void

stateCount

  • stateCount(index: number): number
  • Gets the number of states of a variable at the time this instance was constructed.

    Parameters

    • index: number

      The index into {@link com.bayesserver.Table#getSortedVariables}.

    Returns number

    The state count.

stateRepeat

  • stateRepeat(index: number): number
  • Gets the number of times each state is repeated for a {@link com.bayesserver.Variable} in the {@link com.bayesserver.Table} layout. See {@link com.bayesserver.Table} for details on layout.

    Parameters

    • index: number

      The index into {@link com.bayesserver.Table#getSortedVariables}.

    Returns number

    The repeat count for each state.

sum

  • sum(): number
  • Calculates the sum of all values in the {@link com.bayesserver.Table}.

    Returns number

    The sum of all table values.

timeShift

  • timeShift(units: number): void
  • Shifts any times associated with the table variables by the specified number of units.

    exception

    Error Raised if this instance is read only.

    Parameters

    • units: number

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

    Returns void

toString

  • toString(): string
  • inheritdoc

    Returns string

Static _vsr_x_

  • _vsr_x_(p_autogen71: Table, p_autogen72: Table, p_autogen73: number | null, p_autogen74: number | null): number[]
  • Parameters

    • p_autogen71: Table
    • p_autogen72: Table
    • p_autogen73: number | null
    • p_autogen74: number | null

    Returns number[]

Static _vss_x_

  • _vss_x_(p_autogen75: number[], p_autogen76: Table): number[]
  • Parameters

    • p_autogen75: number[]
    • p_autogen76: Table

    Returns number[]

Static _vuq_x_

  • _vuq_x_(p_autogen129: number, p_autogen130: Table, p_autogen131: Table, p_autogen132: number[]): number
  • Parameters

    • p_autogen129: number
    • p_autogen130: Table
    • p_autogen131: Table
    • p_autogen132: number[]

    Returns number

Static _vur_x_

  • _vur_x_(p_autogen133: number, p_autogen134: Table, p_autogen135: Table, p_autogen136: number[]): number
  • Parameters

    • p_autogen133: number
    • p_autogen134: Table
    • p_autogen135: Table
    • p_autogen136: number[]

    Returns number