|
ClassWork / LearningBitByBitMathCheatSheet
Math Cheat Sheet Helpful links for deciphering equations: Sets ∈ set membership - is a member of. ∉ set membership - is not a member of. a ∈ S Element a belongs to set S Example: a = 1 and S = {1,2,3} Inverse: a ∉ S A ⊆ B A is a subset of B Example: A = {1,2,3} and B= {1,2,3,4,5,6} Inverse: A ⊄ B A ⊂ B A is a proper set of B. A is a set of B but A ≠ B Example: A = {1,2,3} and B= {1,2,3,4,5,6} ∅ Null, an empty set Ω Universal set, the universe of a specific context, the sample space Example: The universal set of English vowels {a,e,i,o,u} does not contain the letter z ℜ The set of real numbers A = {x1, x2,…,xn} Finite set A = {x1, x2,…} Infinite set Sc A set’s complement Example: If Ω = {a,e,i,o,u} and S = {a,e,i} Sc ={o,u} A\B Difference between sets A and B Example: A = {1,2,3} and B= {1,2,3,4,5,6} the difference is {4,5,6} A ∪ B The union of A and B; all elements occurring in A OR B Example: A = {1,2,3} and B= {1,2,3,4,5,6} the union is {1,2,3,4,5,6} A ∩ B The intersection of A and B ; all elements occurring in A AND B Example: A = {1,2,3} and B= {1,2,3,4,5,6} the intersection is {1,2,3} {x | K} x such that x satisfies property K Example: The set of all even integers {k | k/2 is an integer} Probability P(W ∩ O) P(W U O) Conditional Probability - Reasoning based on partial information Example: A six-sided die is rolled and you are told the outcome is even. What is the probability that a 6 was rolled? P(A | B) = number of elements of A ∩ B / The union of sets A and B (the elements in common between sets A and B) The number of elements in set A ∩ B = 1 So given our equation above, the conditional probability of A given B = 1/3 Chains of Probability P(w1, w2,…wn) This is calculated as The probability of word 1 * the conditional probability of word 2 given word 1 * the conditional probability of word 3 given the sequence word 1, word 2 Bigram N-Gram Given a set of words W Maximum Likelihood Estimation
used to normalize n-gram counts Similarity Metrics ![]() translates to This is easily extended into n-dimensional space as such: Pearson Correlation ρ (rho or just r): Given two vectors X and Y in n-dimensional space, find how linear a relationship exists between them You can always double check your answers using the correl(X, Y) function in a spreadsheet application like Excel Deconstructed: - The mean (average value) of X - SumFor i = 1, while i<= n Sum xyz then increment i Given vector X and vector Y Find python translation of this Pearson Correlation formula in utilities.py Jaccard Index ![]() Given 2 sets A and B the Jaccard index is the size of the union of the sets divided by the size of the intersection of the sets. |