Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Variable

Represents a discrete or continuous random variable.

Note that variable names must be unique per network, and are case sensitive.

A {@link com.bayesserver.Node Node} in a Bayesian network can contain one or more variables.

Although a discrete variable can contain a different number of {@link com.bayesserver.State states}, a continuous variable always contains a single state.

Hierarchy

  • Variable

Index

Constructors

constructor

  • Initializes a new instance of the {@link com.bayesserver.Variable} class, with {@link com.bayesserver.VariableValueType} discrete and zero states.

    Returns Variable

  • Initializes a new instance of the {@link com.bayesserver.Variable} class, with {@link com.bayesserver.VariableValueType} discrete, zero states, and the specified name.

    Parameters

    • name: string

      The name of the variable. Can be null.

    Returns Variable

  • Initializes a new instance of the {@link com.bayesserver.Variable} class with the specified name, kind and value type. If discrete, no states are added.

    Parameters

    • name: string

      The name of the variable. Can be null.

    • valueType: VariableValueType

      The value type, e.g. continuous or discrete.

    • kind: VariableKind

      The kind of Variable, e.g. Probability, Decision or Utility.

    Returns Variable

  • Initializes a new instance of the {@link com.bayesserver.Variable} class with the specified name and value type. If discrete, no states are added.

    Parameters

    • name: string

      The name of the variable. Can be null.

    • valueType: VariableValueType

      The value type, e.g. continuous or discrete.

    Returns Variable

  • Initializes a new instance of the {@link com.bayesserver.Variable} class, with {@link com.bayesserver.VariableValueType} discrete and the specified [name] and adds the number of states specified in [states].

    exception

    RangeError Raised when the [states] parameter is less than zero.

    Parameters

    • name: string

      The name of the variable. Can be null.

    • states: number

      The number of states to add to the Variable. States will be given default names.

    Returns Variable

  • Initializes a new instance of the {@link com.bayesserver.Variable} class, with {@link com.bayesserver.VariableValueType} discrete and the specified name and adds the states specified in [states].

    exception

    ReferenceError Raised when [states] is null.

    exception

    Error Raised when the names in [states] are not unique, or are null or empty.

    Parameters

    • name: string

      The name of the variable. Can be null.

    • states: string[]

      The number of states to add to the Variable. States will be given default names.

    Returns Variable

  • Initializes a new instance of the {@link com.bayesserver.Variable} class, with {@link com.bayesserver.VariableValueType} discrete and the specified name and adds the states specified in [states].

    exception

    ReferenceError Raised when [states] is null.

    exception

    Error Raised when the names in [states] are not unique, or are null or empty.

    Parameters

    • name: string

      The name of the variable. Can be null.

    • states: State[]

      The number of states to add to the Variable. States will be given default names.

    Returns Variable

Accessors

customProperties

  • Gets custom properties associated with this instance.

    Custom properties allow storage of custom information, which will be saved with the network.

    Returns CustomPropertyCollection

description

  • get description(): string
  • set description(value: string): void
  • An optional description for the variable.

    Returns string

  • An optional description for the variable.

    Parameters

    • value: string

    Returns void

index

  • get index(): number
  • The Index of this instance in the collection of variables belonging to a network, or -1 if the variable does not belong to a node and hence a network.

    Returns number

kind

  • Gets the kind of variable, such as Probability, Decision or Utility.

    Returns VariableKind

name

  • get name(): string
  • set name(value: string): void
  • Gets the name of the variable.

    When a variable is added to a network, its name must be unique. Comparisons are case sensitive.

    Returns string

  • Sets the name of the variable.

    When a variable is added to a network, its name must be unique. Comparisons are case sensitive.

    Parameters

    • value: string

    Returns void

node

  • Gets the {@link com.bayesserver.Node} this instance belongs to, if any.

    Returns Node

    The node the instance belongs to, if any.

stateValueType

  • Gets the type of value that states belonging to this variable can represent. For example an interval.

    Returns StateValueType

  • Sets the type of value that states belonging to this variable can represent. For example an interval.

    Parameters

    Returns void

states

  • Returns the collection of states belonging to the variable.

    Continuous variables always have a single state.

    see

    com.bayesserver.State

    Returns StateCollection

valueType

  • Gets the variable's value type, e.g. continuous or discrete.

    Returns VariableValueType

    The variable's value type.

Methods

_get_O_x_

_rqqq_x_

  • _rqqq_x_(): void
  • Returns void

_rqqu_x_

  • _rqqu_x_(): void
  • Returns void

_rqrr_x_

  • _rqrr_x_(p_autogen24: string): void
  • Parameters

    • p_autogen24: string

    Returns void

_rqrs_x_

  • _rqrs_x_(p_autogen25: State): void
  • Parameters

    Returns void

_rqrt_x_

  • _rqrt_x_(p_autogen26: string): void
  • Parameters

    • p_autogen26: string

    Returns void

_rqru_x_

  • _rqru_x_(p_autogen27: State, p_autogen28: string, p_autogen29: string): void
  • Parameters

    • p_autogen27: State
    • p_autogen28: string
    • p_autogen29: string

    Returns void

_setIndex

  • _setIndex(value: number): void
  • Parameters

    • value: number

    Returns void

_setNode

  • _setNode(value: Node): void
  • Parameters

    Returns void

_set_O_x_

  • Parameters

    Returns void

compareTo

  • inheritdoc

    Parameters

    Returns number

copy

  • Copies this instance.

    Returns Variable

    A new {@link com.bayesserver.Variable} instance.

findStateByValue

  • findStateByValue(value: any): State
  • Finds a state based on a state value. E.g. finds the state who's interval contains the supplied value, or who's integer state value matches the supplied integer.

    Parameters

    • value: any

      The value to test against state values. Type will depend on StateValueType. e.g. pass a double if the state value type is a double interval.

    Returns State

    The matching state or null.

toString

  • toString(): string
  • Returns the name of the variable, or an empty string if the name is null.

    Returns string

    A {@link String} containing the name of the variable which is empty if the name is null.