rbnet.pcfg.DiscreteNonTermVar
- class rbnet.pcfg.DiscreteNonTermVar(cardinality, chart_type='TMap', *args, **kwargs)[source]
Bases:
NonTermVarA 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.
- 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
dimweights – [optional] weights of the mixture components; must be compatible (broadcastable) to
componentsdim – integer or tuple of integers indicating the dimensions of
componentsalong which to sum to compute the mixture
- Returns:
distribution corresponding to the mixture