rbnet.pcfg.DiscreteNonTermVar

class rbnet.pcfg.DiscreteNonTermVar(cardinality, chart_type='TMap', *args, **kwargs)[source]

Bases: NonTermVar

A discrete non-terminal variable with cardinality cardinality.

Parameters:
  • cardinality – cardinality

  • chart_type – type of chart to use (“dict” or “TMap”)

Public Methods:

__init__(cardinality[, chart_type])

A discrete non-terminal variable with cardinality cardinality.

get_chart(n, *args, **kwargs)

Initialise a chart for sequence of length n.

mixture(components[, weights, dim])

Compute a mixture distribution over a discrete variable.

Inherited from NonTermVar

__init__(*args, **kwargs)

get_chart(*args, **kwargs)

Return a parse chart to store this variable type in.

mixture(*args, **kwargs)

Compute a mixture over this variable type.

Private Data Attributes:

_abc_impl

Inherited from NonTermVar

_abc_impl

Inherited from ABC

_abc_impl


get_chart(n, *args, **kwargs)[source]

Initialise a chart for sequence of length n. :type n: :param n: length of the sequence :return: chart

mixture(components, weights=None, dim=0)[source]

Compute a mixture distribution over a discrete variable.

Parameters:
  • components – array-like with mixture components along dim

  • weights – [optional] weights of the mixture components; must be compatible (broadcastable) to components

  • dim – integer or tuple of integers indicating the dimensions of components along which to sum to compute the mixture

Returns:

distribution corresponding to the mixture