<jupyter_start><jupyter_text>**Probability***Chance of an event occurring.*Probability shows how possible it is that an event occurs.It is a measure of the frequency of an event, that is, how much happens the event that satisfies a condition.*Number of ways of achieving a condition / the total number of possible outcomes*  **Ex.**<jupyter_code>#What is the probability for throwing a dice and getting even number?
3/6
#What is the probability of getting a head when flipping a coin?
1/2
#What is the probability for throwing a dice and getting a 7?
0/6
#What is the probability for throwing a dice and getting a 3  or 6?
2/6
#What is the probability for throwing a dice and getting a 3 and 6?
0/6<jupyter_output><empty_output><jupyter_text>Predictions**KAHOOT**![](https://)<jupyter_code>#What is the probability of getting an elephant?
#If I spin the wheel 1 time
4/7
#Predict the number of times I get an elephant if I spin the wheel 210 times
210 * (4/7)<jupyter_output><empty_output><jupyter_text>Which probability is greater?Throwing a dice and getting a number less or equal than 2 or a  number greater or equal than 3P( x=3 )<jupyter_code>#getting a number less than 2
2/6
#getting a number greater than 3
4/6<jupyter_output><empty_output><jupyter_text>**DOUBLE**  **Permutations & Combinations**There are two ways to sort or combine results of dependent events. - **Permutations** are groupings in which the order of objects matters. - **Combinations** are groupings in which the content matters but the order does not.*It helps a lot to use trees* **Permutations**<jupyter_code>#If I go to a florist that has 4 types of flowers (Roses, tulip, sunflower, lilies)
#and 3 colors of pots (brown, yellow, green). 
#How many combinations of flowers and pots can I go out with?

3 * 4
#If I have two engine options (4 cylinders and 6 cylinders) 
#and 4 color options (Red, Blue, Green, White) 
#What is the probability of having a white car with 6 cylinders?
#How many ways can I organize 5 people in 5 places?
#Orden is important
# A, B, C, D, E

#Places
#1 2 3 4 5
 5*4*3*2*1

#5!<jupyter_output><empty_output><jupyter_text>*Formula*P(n,k) = n! / (n-k)!- n = how many things I have- k = how many ways or places I have to sort or combine my things<jupyter_code>def facto(n):
  factorial = 1
  if int(n) >= 1:
    for i in range (1,int(n)+1):
      factorial = factorial * i
  return(int(factorial))
facto(5)
#What if I only have 3 places?
#How many ways can I organize 5 people in 3 places?
#Orden is important
facto(5)/facto((5-3))
#How many 3-letter words can I make? (The alphabet has 26 letters)
#How many codes with 4 colors can I do without repeating them?
#If I have a group of 9 people, 
#how many different ways can I choose the board of directors 
#(President - Vice President - Secretary)<jupyter_output><empty_output><jupyter_text>**Combinations***Formula*- C(n,k) = P(n,k) / k!- C(n,k) = (n! / (n-k)!) / k!- **C(n,k) = n! / k! * (n-k)!**- n = how many things I have- k = how many ways or places I have to sort or combine my things **Say Hello**<jupyter_code>#In how many combinations 4 people say hello to each others when order matters
# A, B, C, D

#Places
#1 2 
 4*3

#5!
#In how many combinations 4 people say hello to each others when order doesn't matter
# total permutations / ways to sort 3 people
facto(4)/(facto(2)*facto((4-2)))<jupyter_output><empty_output><jupyter_text>Python provide direct methods to find permutations and combinations of a sequence. These methods are present in itertools package.<jupyter_code>from itertools import permutations 
from itertools import combinations 

perm2 = permutations('ABCD', 2)
for i in list(perm2): 
  print(i)
comb = combinations('ABCD', 2)
for i in list(comb):
  print(i)
# I have 36 cards, 4 groups and 9 cards for group
# What is the probability to get the four 'ones' in one group?

# . 1.How many options do I have?

facto(36) / (facto(9)*facto((36-9)))

#Permutación
#Continue on the board<jupyter_output><empty_output><jupyter_text>**Independent events**They have no relationship between them -> Gambler's fallacy<jupyter_code>#If you flip a coin twice,
#what is the probability of having a face in both attempts.

#P(c c) = P(c)*P(c)
          0.5 * 0.5
#If you flip a coin three times, 
#what is the probability of having a seal, face and seal (in this order).

#P(s c s) = P(s) * P(c) * P(s)
             0.5 * 0.5 * 0.5
perm3 = permutations('CSC', 3)

for i in list(perm3): 
  print(i)

#Falta SSS
#If I have an test, 
#the first question has 4 options and the second 3, all only answer, 
#what is the probability of win the test if I answer randomly
#I win if I take 2 green balls out of the bag. 
#If I have 3 green and 2 red balls, 
#what is the probability of winning, if I do not put the one I get back in the bag<jupyter_output><empty_output><jupyter_text>**Dependent events**They have relationship between them<jupyter_code>#I have 8 coins, 3 trick and 5 normal coins
#The probability of get a face in a trick coin is 60%
#If I choose one and flip it twice
#What is the probability of get face in the two flips

# .1. P(cc|normal)
# 2.P(cc|trick)
# PT = P(cc|normal)+P(cc|trick)<jupyter_output><empty_output><jupyter_text>**Venn Diagram**on board<jupyter_code>#4 groups of cards and 13 cards for group
# 1 2 3 4 5 6 7 8 9 10 J Q K
# 52 cards in total

# P(J)
# P( J y corazón)
#Intersection
# P( J o corazón) = P (J) + P(corazón) - P (Jcorazón) // Se le resta para no contar dos veces
#out of intersection
# I Have 8 green cubes, 9 green balls, 5 yellow cubes and 7 yellow balls
# P(cube)
# P (cube yellow)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09845388306379954, 'fraction_numerical': 0.025590901012973163, 'mean_word_length': 4.334597156398104, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 43, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '103846', 'license': 'MIT', 'n_tokens_mistral': 2004, 'n_tokens_neox': 1860, 'n_words': 846, 'path': 'Taller 2 - Probabilidad/Probablidad.ipynb', 'repo_name': 'deiry/DataScienceFEM', 'size': '5627'}