treeProbability: The (path) probability of generating 'tree' by grammar 'G'.

View source: R/derivationTrees.R

treeProbabilityR Documentation

The (path) probability of generating tree by grammar G.

Description

treeProbability() returns the path probability of generating the derivation tree tree by the context-free grammar G. The probability is exact, if the grammar is not ambiguous and if the grammar does not contain redundant rules.

Usage

treeProbability(tree, G)

Arguments

tree

Derivation tree.

G

A context-free grammar.

Value

Real. The probability of generating tree by grammar G.

See Also

Other Measures of Tree Attributes: treeLeaves(), treeListDepth(), treeNodes(), treeSize()

Examples

g<-compileBNF(booleanGrammar())
a<-randomDerivationTree(g$Start, g)
decodeTree(a, g$ST) 
treeProbability(tree=a, G=g)


xegaDerivationTrees documentation built on April 16, 2025, 5:11 p.m.