<jupyter_start><jupyter_text>HistogramsAllows you to approximate the selectivity using a histogram for following selections:- $A = c$- $A > c$- $A_1 = A_2$ Example for $A=c$<jupyter_code>hist = Histogram()
hist.add_interval(0, 20, 1)\
    .add_interval(20, 40, 3)\
    .add_interval(40, 60, 4)\
    .add_interval(60, 80, 2)\
    .add_interval(80, 100, 0)

tex, _ = approx_equals_constant_verbose(hist, 50)
display(Math(tex))<jupyter_output><empty_output><jupyter_text>Exercise 12.2:<jupyter_code>hist = Histogram()
hist.add_interval(0, 20, 1)\
    .add_interval(20, 40, 3)\
    .add_interval(40, 60, 4)\
    .add_interval(60, 80, 2)\
    .add_interval(80, 100, 0)

tex, _ = approx_greater_constant_verbose(hist, 54)
display(Math(tex))<jupyter_output><empty_output><jupyter_text>so we get a selecitivy of approx. 0.32 having 10 elements this leads to $0.32 \cdot 10 = 3.2$ elements. Exercise 12.3<jupyter_code>hist_r = Histogram()
hist_r.add_interval(0, 20, 1)\
    .add_interval(20, 40, 3)\
    .add_interval(40, 60, 4)\
    .add_interval(60, 80, 2)\
    .add_interval(80, 100, 0)

hist_s = Histogram()
hist_s.add_interval(0, 10, 2)\
    .add_interval(10, 20, 4)\
    .add_interval(20, 40, 1)\
    .add_interval(40, 50, 6)\
    .add_interval(50, 100, 4)

tex, _ = approx_join_verbose(hist_r, hist_s)
display(Math(tex))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15504451038575667, 'fraction_numerical': 0.09198813056379822, 'mean_word_length': 4.439516129032258, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '112106', 'license': 'Apache-2.0', 'n_tokens_mistral': 645, 'n_tokens_neox': 547, 'n_words': 119, 'path': 'Query Optimization/algorithms/ikkbz_hist/histogram.ipynb', 'repo_name': 'dragikamov/TUM-1', 'size': '1348'}