Analysing Distributions¶
The equation tree can be used to extract information from existing distributions of equations (e.g., for example by scraping priors: https://autoresearch.github.io/equation-scraper/tutorials/equation_scraper_tutorial/)
Installation¶
In [ ]:
Copied!
!pip install equation-tree
!pip install equation-tree
Equation Database¶
Here, we use a list of sympy equation to demonstrate the functionality
In [ ]:
Copied!
# import functionality from sympy
from sympy import sympify
eq_1 = sympify('x_1 + x_2')
eq_2 = sympify('exp(x_1) * 2.5')
eq_3 = sympify('sin(x_1) + 2 * cos(x_2)')
equation_list = [eq_1, eq_2, eq_3]
# import functionality from sympy
from sympy import sympify
eq_1 = sympify('x_1 + x_2')
eq_2 = sympify('exp(x_1) * 2.5')
eq_3 = sympify('sin(x_1) + 2 * cos(x_2)')
equation_list = [eq_1, eq_2, eq_3]
Analyse the List¶
We can obtain informations about equations and lists of equations:
In [ ]:
Copied!
from equation_tree import get_frequencies
# Show the frequencies of
frequencies = get_frequencies(equation_list)
frequencies
from equation_tree import get_frequencies
# Show the frequencies of
frequencies = get_frequencies(equation_list)
frequencies
Instead of frequencies, we can also obtain absolute values:
In [ ]:
Copied!
from src.equation_tree import get_counts
counts = get_counts(equation_list)
counts
from src.equation_tree import get_counts
counts = get_counts(equation_list)
counts
Note: We can directly use the obtained frequencies to sample new functions:
In [ ]:
Copied!
from equation_tree import sample
# sample equations
equations = sample(10, frequencies)
print(equations)
from equation_tree import sample
# sample equations
equations = sample(10, frequencies)
print(equations)
In [ ]:
Copied!
# check the frequencies
print(get_frequencies(equations))
# check the frequencies
print(get_frequencies(equations))