A Noob’s perspective — Learning Data Science, ML and AI from scratch. Pt 6

Rick
3 min readApr 5, 2023

--

Finite Sample spaces

Suppose S is finite, and S = {s1,s2,s4,s4, …, sn-1,sn}. Finite sample spaces allow us to calculate the probabilities of certain events in an efficient manner.

Now let’s say that A is a subset of S, then the probability P(A) is the sum of all the probabilities given that they belong in A

Example:

say that you are presented 4 toy balls, 2 red 1 green, 1 blue. What are the odds that you grab either a blue or red one.

P(red) = 1/2

P(blue) = P(green) = 1/4

P(A) = P(red) + P(blue) = 1/2 + 1/4 = 3/4

Addition rule

Say that we have a choice A that we could do in n-th ways, we’ll call it na ways, and We have another choice B with nb ways too. In the end we have (na + nb) ways of doing things.

For example.

imagine we could choose between having a burger or pizza; and we have the option between bacon and no bacon for the burger, and vegetarian, pineapple, or sausage pizza. We have in total 5 options. 2 for the burger and 3 for the pizza.

Replacement and order

imagine we pick 2 cards from a deck, without replacement, how many ways can we do this.

We care about order meaning (6♣, Q♦) not equal to (Q♦,6♣)

Answer

There’s 52 cards, pick one we are left with 51 cards. 52 . 51 = 2652. If that isn’t clear try to experiment with a smaller deck of cards on your own.

Counting techniques

Permutations.- An arrangement of n elements in a definite order is a permutation of the n elements.

Example

  • how many ways can you arrange 246
  • 6 ways. 246, 264, 426, 462, 624, 642

The general form can be proven with an example.

how many ways can i arrange 1,2,3 …, n-1, n.

look at it like the previous card example where we pick two. Now let’s imagine if we keep picking cards.

52 x 51 x 50 x 49 x … = 52!

Formal definition. The number of r-arrays we can make from a bigger set of n elements, where we use each element at most once, is called the number of permutations of n things taken r-at-a-time.

Example: how many ways can you take two vowels from a,e,i,o,u.

(5!)/(5–2)! = 5!/3! = 20

ae, ai, ao, au, ea, ei, eo, eu, ia, ie, io, iu, oa, oe, oi, ou, ua, ue, ui, uo

Combinations

Here we are interested in making only subsets of length r out n without any order.

Example:

  • how many subsets can me make out of {1,2,3}
  • {1,2},{,1,3}.{2,3}

Equation

--

--

Rick
Rick

Written by Rick

I blog about everything I learn, Digital Image Processing, Data Science, IoT, Videogame design and much more :)

No responses yet