<jupyter_start><jupyter_text>Opgave 1.4<jupyter_code>class Dice(object):
     
    def __init__():
        pass
    
    @staticmethod
    def outcome_space():
        
        return [i + 1 for i in range(6)]

  
t1, t2, t3 = Dice.outcome_space(), Dice.outcome_space(), Dice.outcome_space() 
outcomes = list()

for i in t1:
    for j in t2:
        for k in t2:
            outcomes.append(i+j+k)<jupyter_output><empty_output><jupyter_text>Distribution of outcomes<jupyter_code>bins = [i*0.5 + 3 for i in range(16*2)]
plt.hist(outcomes, bins=bins)
def number_of_tens(x):
    if x == 10:
        return 1
    else:
        return 0
gunstige_udfald = np.sum([number_of_tens(outcome) for outcome in outcomes ])
print('antal gunstige udfald er:',gunstige_udfald)<jupyter_output>antal gunstige udfald er: 27<jupyter_text>Opgave 1.24 Vi laver en nem kodning: (1,1) = 11, (2,1) = 21 osv.<jupyter_code>def gen_set(t1,t2):
    return int(str(t1) + str(t2))

def read_set(s):
    t1, t2 = int(str(s)[0]),int(str(s)[1])
    return t1, t2
A = set(['41','42','43','44','45','46'])
B = set(['11','21','31','41','51','61'])
C = set(['41','42','43','44','14','24','34'])
D = set(['14','23','32','41'])
F = set(['16','61','25','52','34','43'])
def get_intersection(set1, set2):
    
    return set1.intersection(set2)

def elements_in_intersection(set1, set2):
    
    intersection = get_intersection(set1, set2)
    return len(intersection)

def get_intersection_probability(set1, set2):
    
    intersection = get_intersection(set1, set2)
    return len(intersection)/36

def get_probability(set1, set2):
    
    nr_elements1 = len(set1)
    nr_elements2 = len(set2)
    
    return nr_elements1*nr_elements2/(36*36)
all_sets = [A, B, C, D, F]
set_names =  ['A', 'B', 'C', 'D', 'F']

results = {'set':set_names}
for i in range(len(all_sets)):
    results[set_names[i]] = [elements_in_intersection(all_sets[i],j) for j in all_sets]
    
# puts everything to dataframe for printing
df = pd.DataFrame(results)
df<jupyter_output><empty_output><jupyter_text>Til Latex output:<jupyter_code>print(df.to_latex(index=False))<jupyter_output>\begin{tabular}{rrrrrl}
\toprule
 A &  B &  C &  D &  F & set \\
\midrule
 6 &  1 &  4 &  1 &  1 &   A \\
 1 &  6 &  1 &  1 &  1 &   B \\
 4 &  1 &  7 &  2 &  2 &   C \\
 1 &  1 &  2 &  4 &  0 &   D \\
 1 &  1 &  2 &  0 &  6 &   F \\
\bottomrule
\end{tabular}<jupyter_text>Calculating intersections probabilities<jupyter_code>results = {'set':set_names}
for i in range(len(all_sets)):
    results[set_names[i]] = [get_intersection_probability(all_sets[i],j) for j in all_sets]
df = pd.DataFrame(results)
df.round(3)<jupyter_output><empty_output><jupyter_text>Til Latex output:<jupyter_code>print(df.round(3).to_latex(index=False))<jupyter_output>\begin{tabular}{rrrrrl}
\toprule
     A &      B &      C &      D &      F & set \\
\midrule
 0.167 &  0.028 &  0.111 &  0.028 &  0.028 &   A \\
 0.028 &  0.167 &  0.028 &  0.028 &  0.028 &   B \\
 0.111 &  0.028 &  0.194 &  0.056 &  0.056 &   C \\
 0.028 &  0.028 &  0.056 &  0.111 &  0.000 &   D \\
 0.028 &  0.028 &  0.056 &  0.000 &  0.167 &   F \\
\bottomrule
\end{tabular}<jupyter_text>Calculating P(A)P(B)<jupyter_code>results = {'set':set_names}
for i in range(len(all_sets)):
    results[set_names[i]] = [get_probability(all_sets[i],j) for j in all_sets]
# puts everything to dataframe for printing
df = pd.DataFrame(results)
df.round(3)<jupyter_output><empty_output><jupyter_text>Til Latex output:<jupyter_code>print(df.round(3).to_latex(index=False))<jupyter_output>\begin{tabular}{rrrrrl}
\toprule
     A &      B &      C &      D &      F & set \\
\midrule
 0.028 &  0.028 &  0.032 &  0.019 &  0.028 &   A \\
 0.028 &  0.028 &  0.032 &  0.019 &  0.028 &   B \\
 0.032 &  0.032 &  0.038 &  0.022 &  0.032 &   C \\
 0.019 &  0.019 &  0.022 &  0.012 &  0.019 &   D \\
 0.028 &  0.028 &  0.032 &  0.019 &  0.028 &   F \\
\bottomrule
\end{tabular}<jupyter_text>Opgave 1.9<jupyter_code>def prob_func(x):
    
    return (52-x-16)/(52-x)
prob = 1
for i in range(13):
    #print(i, prob_func(i))
    prob = prob * prob_func(i)
prob<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17271407837445574, 'fraction_numerical': 0.0887760038703435, 'mean_word_length': 3.17255297679112, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '549735', 'license': 'MIT', 'n_tokens_mistral': 1947, 'n_tokens_neox': 1769, 'n_words': 346, 'path': 'Ugeseddel 1.ipynb', 'repo_name': 'JakartaLaw/statistik2018', 'size': '4134'}