EM Algorithm

00:28:39
https://www.youtube.com/watch?v=7e65vXZEv5Q

Sintesi

TLDRIl video esplora l'algoritmo di stima e massimizzazione (EM) attraverso esempi pratici, come campagne di marketing e trattamenti medici. Utilizza il lancio di monete per illustrare come determinare la probabilità di successo di due condizioni. L'algoritmo EM è un processo iterativo che stima le probabilità e aggiorna le medie fino a convergere ai valori reali. Viene mostrato come calcolare la probabilità di ottenere un certo numero di successi in base a distribuzioni binomiali e come normalizzare i risultati per ottenere probabilità relative. Alla fine, l'algoritmo permette di identificare quale condizione ha prodotto i risultati osservati e quali sono le probabilità di successo per ciascuna.

Punti di forza

  • 🔍 L'algoritmo EM è un metodo iterativo per stimare parametri.
  • 🎲 Utilizza esempi pratici come il lancio di monete per illustrare concetti.
  • 📊 Le distribuzioni binomiali aiutano a calcolare le probabilità di successo.
  • 🔄 La normalizzazione converte le probabilità in valori relativi.
  • 📈 L'algoritmo EM può essere applicato a dati reali in vari campi.

Linea temporale

  • 00:00:00 - 00:05:00

    Il video introduce l'algoritmo di stima e massimizzazione (EM) attraverso esempi pratici, come campagne di marketing e trattamenti medici, per illustrare come determinare l'origine di un risultato.

  • 00:05:00 - 00:10:00

    Viene presentato un esempio di lancio di monete, dove si hanno due monete con probabilità diverse di ottenere testa o croce. L'obiettivo è determinare quale moneta è stata lanciata basandosi sui risultati ottenuti.

  • 00:10:00 - 00:15:00

    Si descrive un processo iterativo in cui si assegnano probabilità iniziali alle monete e si calcolano le probabilità di ottenere i risultati osservati, utilizzando la distribuzione binomiale per stimare il numero atteso di teste.

  • 00:15:00 - 00:20:00

    Il video spiega come calcolare le probabilità normalizzate per ciascuna moneta, utilizzando i risultati dei lanci per aggiornare le stime delle probabilità di successo di ciascuna moneta.

  • 00:20:00 - 00:28:39

    Infine, si conclude che l'algoritmo EM permette di determinare le probabilità di successo per ciascuna condizione, stabilendo quale moneta ha generato i risultati osservati e fornendo una comprensione più profonda dei dati.

Mostra di più

Mappa mentale

Video Domande e Risposte

  • Cos'è l'algoritmo EM?

    L'algoritmo di stima e massimizzazione (EM) è un metodo iterativo per stimare parametri in modelli statistici, specialmente quando ci sono dati mancanti.

  • Come funziona l'algoritmo EM?

    L'algoritmo EM alterna tra la stima delle probabilità (E-step) e la massimizzazione delle medie (M-step) fino a convergere ai valori reali.

  • Qual è un esempio pratico dell'algoritmo EM?

    Un esempio pratico è determinare quale campagna di marketing ha avuto successo analizzando i dati di acquisto dei clienti.

  • Cosa sono le distribuzioni binomiali?

    Le distribuzioni binomiali descrivono il numero di successi in una serie di prove indipendenti, come il lancio di monete.

  • Come si calcolano le probabilità con l'algoritmo EM?

    Le probabilità si calcolano utilizzando la formula della distribuzione binomiale e normalizzando i risultati.

  • Qual è l'importanza della normalizzazione?

    La normalizzazione è importante per convertire le probabilità di verosimiglianza in probabilità relative che sommano a 1.

  • Cosa significa convergere in questo contesto?

    Convergere significa che i valori stimati delle probabilità e delle medie smettono di cambiare significativamente.

  • Quali sono i passaggi principali dell'algoritmo EM?

    I passaggi principali sono l'assegnazione iniziale delle medie, il calcolo delle probabilità, l'aggiornamento delle medie e la ripetizione del processo.

  • Come si applica l'algoritmo EM a dati reali?

    L'algoritmo EM può essere applicato a dati reali in vari campi, come il marketing, la medicina e l'analisi dei dati.

  • Qual è il risultato finale dell'algoritmo EM?

    Il risultato finale è una stima delle probabilità di successo per ciascuna condizione o campagna analizzata.

Visualizza altre sintesi video

Ottenete l'accesso immediato ai riassunti gratuiti dei video di YouTube grazie all'intelligenza artificiale!
Sottotitoli
en
Scorrimento automatico:
  • 00:00:00
    to talk about the estimation
  • 00:00:01
    maximization or em algorithm okay and
  • 00:00:05
    I'm going to illustrate this with an
  • 00:00:07
    example um most of the content in this
  • 00:00:10
    video was taken from the internet so you
  • 00:00:12
    can find the sources I think are are uh
  • 00:00:15
    sided whenever they were used and you
  • 00:00:18
    can go deeper into into this uh by
  • 00:00:22
    visiting those sources now I'm going to
  • 00:00:25
    illustrate this with an example let's
  • 00:00:28
    say you have two
  • 00:00:31
    cases and each of these cases or
  • 00:00:34
    conditions have a success or failure so
  • 00:00:37
    for example you have uh two marketing
  • 00:00:40
    campaigns in one city and you have uh
  • 00:00:45
    buyer outcome or something and then you
  • 00:00:47
    want to determine whether that outcome
  • 00:00:49
    came from campaign a or campaign B right
  • 00:00:52
    and the outcome is whether campaign a
  • 00:00:54
    succeeded campaign B uh did not succeed
  • 00:00:57
    let's say you have two treatments to
  • 00:01:00
    Medical Treatments right and you want to
  • 00:01:02
    see the rate of uh of recovery right so
  • 00:01:06
    in with treatment treatment a a number
  • 00:01:09
    of patients recovered with treatment b a
  • 00:01:11
    different number of patients recovered
  • 00:01:13
    but you don't know that you just see the
  • 00:01:15
    patients that have recovered in
  • 00:01:17
    different instances right so then you
  • 00:01:20
    can what you would like to see is well
  • 00:01:23
    which patients were given which of these
  • 00:01:27
    recoveries due to treatment a and which
  • 00:01:29
    which are due to treatment B which sets
  • 00:01:33
    um you want to see
  • 00:01:37
    um any other case where there's two
  • 00:01:40
    treatment two conditions and conditions
  • 00:01:44
    can be success or failure this is better
  • 00:01:47
    Illustrated with or traditionally
  • 00:01:49
    Illustrated with two coins say you have
  • 00:01:51
    two coins A and B okay one of these
  • 00:01:55
    coins say a for example is more likely
  • 00:01:57
    to get to give you um to to turn heads
  • 00:02:01
    when you toss the coin the other one's
  • 00:02:03
    more likely to um to fall
  • 00:02:08
    Tails okay so they're they're imbalanced
  • 00:02:11
    coins right and the thing is if I pick a
  • 00:02:15
    coin at random and I toss it which coin
  • 00:02:18
    was it can I know by say I toss coin I
  • 00:02:22
    toss one coin several times and it gives
  • 00:02:25
    me a certain percentage of heads and a
  • 00:02:26
    certain percent a certain percentage of
  • 00:02:28
    Tails can I know whether this was coin a
  • 00:02:32
    or coin B right so so this is similar
  • 00:02:37
    again to saying you know I have two
  • 00:02:39
    marketing campaigns and uh I pick one
  • 00:02:42
    buyer right and he buys the product
  • 00:02:46
    doesn't buy the product and then on 10
  • 00:02:48
    purchases there's so many of those 10
  • 00:02:50
    purchases in which the customer buys the
  • 00:02:52
    product and a few others in which the
  • 00:02:55
    custo customer doesn't it's very similar
  • 00:02:57
    to flipping a coin in some instances it
  • 00:03:02
    uh falls on heads in some instances it
  • 00:03:04
    falls on Tails so all these examples of
  • 00:03:07
    two conditions or several conditions
  • 00:03:10
    with success and failure outcomes are
  • 00:03:11
    traditionally Illustrated with coin
  • 00:03:14
    tosses so I'm going to do the same
  • 00:03:16
    here's the problem you have two coins
  • 00:03:19
    one's more likely than the other to turn
  • 00:03:21
    up heads I pick a coin I toss it several
  • 00:03:24
    times now which coin did I pick that's
  • 00:03:27
    that's what you don't know that's what
  • 00:03:28
    you're trying to determine
  • 00:03:32
    okay so we're going to do like I said
  • 00:03:34
    we're can do this five times we're going
  • 00:03:35
    to try and do this five times and this
  • 00:03:38
    uh most of material in this tutorial was
  • 00:03:40
    taken from uh Kong do and sarapin
  • 00:03:44
    bogu um they have a tutorial online
  • 00:03:49
    now let's do this five times we'll pick
  • 00:03:52
    a coin randomly we'll toss it 10 times
  • 00:03:54
    and we'll count how many heads and how
  • 00:03:57
    many
  • 00:03:58
    Tails um where in the in the 10
  • 00:04:02
    tosses then we'll get the average number
  • 00:04:04
    of heads for each coin
  • 00:04:07
    okay and we're going to do this five
  • 00:04:09
    times and that's going to be my evidence
  • 00:04:10
    this is the customer data that I see
  • 00:04:12
    this is the patient data that I
  • 00:04:15
    see so it goes like this right so I
  • 00:04:19
    picked coin a for example I picked coin
  • 00:04:22
    B for example and I toss it 10 times and
  • 00:04:25
    it fell head Tails Tails Tails heads
  • 00:04:27
    Heads Tails heads Tails heads right so
  • 00:04:30
    five heads and five tails I picked coin
  • 00:04:32
    a and I tossed it 10 times and G me it
  • 00:04:35
    gave me nine heads and one tail I picked
  • 00:04:38
    coin a again so randomly I was picking
  • 00:04:40
    these coins now I know which coins I
  • 00:04:43
    picked right so then what I do here is I
  • 00:04:47
    count for a right the um for a I just
  • 00:04:53
    count the number of heads divide by the
  • 00:04:57
    number of heads and tails and that gives
  • 00:04:59
    me me
  • 00:05:02
    0.8 for coin B I do the same thing and
  • 00:05:06
    it gives me
  • 00:05:08
    0.45 right so that is basically how I
  • 00:05:12
    obtain the average the average number of
  • 00:05:16
    heads that coin a and coin B uh can give
  • 00:05:20
    me right so again there 24 heads and six
  • 00:05:23
    tails so I to compute the the the rate
  • 00:05:27
    of heads that coin a gives me is 24 ID
  • 00:05:30
    24 + 6 so is the number of heads divided
  • 00:05:34
    by total number of heads and tails and
  • 00:05:36
    that gives me
  • 00:05:37
    80% of the tosses are going to are going
  • 00:05:40
    to have 80% of the tosses are going to
  • 00:05:42
    fall on the head side I did the same for
  • 00:05:45
    coin B and I can compute it this is very
  • 00:05:48
    easy I know which coins I picked so I
  • 00:05:50
    can compute the average for each of
  • 00:05:53
    these for each of these uh
  • 00:05:56
    cases
  • 00:05:57
    so what if we're giving giving only the
  • 00:06:00
    result of our coin tosses so we're only
  • 00:06:02
    giv say the patient data but we don't
  • 00:06:04
    know which treatment each patient was
  • 00:06:06
    exposed to what if they give us the
  • 00:06:09
    buyer Behavior but they did the say five
  • 00:06:13
    buyers with different behaviors but they
  • 00:06:16
    didn't tell us which marketing strategy
  • 00:06:18
    they were under
  • 00:06:20
    right what if they give us again only
  • 00:06:23
    the results of our toin causes can we
  • 00:06:26
    guess the percentage of heads that each
  • 00:06:28
    coin yields and moreover can we guess
  • 00:06:30
    which coin was picked for each of these
  • 00:06:33
    10 coin
  • 00:06:35
    tosses one way to think about this is to
  • 00:06:39
    let's do this iterative process let's
  • 00:06:41
    assign a random average to both both
  • 00:06:43
    coins so let's assume you know coin a
  • 00:06:45
    has 60% heads and coin B has 55% heads
  • 00:06:49
    and that is completely random I just
  • 00:06:51
    made up those
  • 00:06:52
    numbers um and then what we're going to
  • 00:06:55
    do iter iteratively is for each of the
  • 00:06:58
    five rounds of tank of 10 coin tosses
  • 00:07:01
    we're going to check the percentage of
  • 00:07:03
    heads we're going to find the
  • 00:07:06
    probability of it coming from each coin
  • 00:07:10
    so basically we're going to if we think
  • 00:07:12
    you know that the coin a has a 60%
  • 00:07:15
    probability of of falling of falling on
  • 00:07:18
    heads right then I can see well if if a
  • 00:07:23
    if if one round of the 10 coin
  • 00:07:26
    tosses uh turns up about % heads than I
  • 00:07:30
    would think it's from coin one right it
  • 00:07:33
    would make sense so with a technique
  • 00:07:35
    similar to that we're going to try to
  • 00:07:36
    find the probability of this round of 10
  • 00:07:39
    coin tosses we're going to find the
  • 00:07:40
    probability that it came from coin a or
  • 00:07:43
    coin B given the the random averages
  • 00:07:47
    that that I
  • 00:07:49
    assigned then we will compute the
  • 00:07:51
    expected number of heads using that
  • 00:07:54
    probability as a weight and we'll
  • 00:07:56
    multiply it by the number of heads this
  • 00:07:58
    might be a little cumbersome and not
  • 00:08:01
    understandable yet but uh I will explain
  • 00:08:04
    later but this is basically we're going
  • 00:08:05
    to try
  • 00:08:07
    to to say well if I think that coin a
  • 00:08:11
    turns up 60% of the times uh
  • 00:08:15
    heads and I have this coin 10 coin
  • 00:08:18
    tosses
  • 00:08:19
    well what if if it were coin a um what
  • 00:08:24
    would be the probability that it comes
  • 00:08:26
    from coin
  • 00:08:27
    a uh and what would be the the expected
  • 00:08:32
    number of heads that I would have
  • 00:08:33
    expected from this this
  • 00:08:35
    coin uh I will explain how to compute
  • 00:08:38
    that then we'll record those numbers and
  • 00:08:42
    with those numbers I will recompute new
  • 00:08:45
    means for coin a and coin B
  • 00:08:48
    so with that then I'll go back to step
  • 00:08:51
    number two Go revisit the five rounds of
  • 00:08:53
    10 coin tosses check the percentages of
  • 00:08:55
    heads and so on and so forth this seems
  • 00:08:57
    like I'm doing the same thing in circles
  • 00:09:00
    but really it will be
  • 00:09:02
    converging to the
  • 00:09:04
    actual means uh to the actual
  • 00:09:07
    proportions of heads for coin A and B
  • 00:09:10
    you will see that this numbers this is
  • 00:09:11
    not circular this thing is actually
  • 00:09:14
    changing a little bit and the key to the
  • 00:09:17
    change is in this middle step
  • 00:09:19
    here okay Computing the expected number
  • 00:09:22
    of heads okay this is the key to the
  • 00:09:24
    change to the convergence to the actual
  • 00:09:28
    real proportion of heads for coin a and
  • 00:09:31
    coin
  • 00:09:33
    B first we need to know a little bit
  • 00:09:36
    about coin tosses okay uh because for
  • 00:09:40
    that key step that I that I mentioned
  • 00:09:42
    we're going to use what's called a
  • 00:09:44
    probability distribution and this sounds
  • 00:09:47
    uh like a hard term to grasp but it is
  • 00:09:51
    not and I want to explain that very
  • 00:09:53
    quickly here
  • 00:09:55
    so let's see how do coin tosses behave
  • 00:09:59
    coin toss behave like this if I have one
  • 00:10:02
    coin let's focus on this on this example
  • 00:10:05
    over here okay if I have one
  • 00:10:08
    coin and I toss it
  • 00:10:11
    right one time is going to fall there's
  • 00:10:14
    the probability that it falls on Tails
  • 00:10:17
    which is zero heads these numbers at the
  • 00:10:19
    bottom indicates the number of heads
  • 00:10:21
    zero heads there's one case in which it
  • 00:10:24
    will do that and the number of heads
  • 00:10:27
    well I can toss it and it can fall on
  • 00:10:29
    heads right so there's also one one pro
  • 00:10:33
    possibility that one possibility that it
  • 00:10:35
    has one one head right that it falls on
  • 00:10:39
    heads this is basically as you see these
  • 00:10:41
    are two squares is 50% that it has no
  • 00:10:44
    heads 50% that it falls on heads if I
  • 00:10:48
    have one
  • 00:10:50
    toss now if I flip two coins right I can
  • 00:10:54
    get for example the first coin heads the
  • 00:10:57
    second coin heads or the first coin
  • 00:10:59
    heads the second coin Tails or the first
  • 00:11:02
    coin tails the second coils head or both
  • 00:11:06
    falling on Tails right so if we count if
  • 00:11:10
    those are my possibilities and if we
  • 00:11:12
    count how many how many coin of these
  • 00:11:15
    coin tosses that I can possibly do how
  • 00:11:17
    many coin tosses can fall can have
  • 00:11:20
    zero uh heads in them only one the case
  • 00:11:24
    in which I toss the two coins and they
  • 00:11:25
    both fail on
  • 00:11:27
    Tails how many cases of my coin tosses
  • 00:11:31
    can I have where there's two heads well
  • 00:11:34
    also one the case in which I toss the
  • 00:11:36
    first coin and its heads and the second
  • 00:11:37
    coin and its heads right so then I I saw
  • 00:11:41
    two heads in my two coin in my flipping
  • 00:11:43
    of two
  • 00:11:44
    coins now what's the case in which you I
  • 00:11:47
    can see one head in this flip well
  • 00:11:49
    there's two cases when head when the
  • 00:11:51
    first coin Falls in heads and the second
  • 00:11:53
    one on Tails or when the first one falls
  • 00:11:56
    on tails and the second one falls on
  • 00:11:58
    heads there's two cases in which I can
  • 00:12:01
    see uh um in which I can
  • 00:12:04
    see head one head right so to recap now
  • 00:12:10
    if we look at these probabilities
  • 00:12:11
    there's 25% chance that I will get no
  • 00:12:15
    heads 25% chance that I will get one
  • 00:12:18
    head and 50% chance that I will see one
  • 00:12:23
    head um two heads did I I mean the here
  • 00:12:27
    25% chance that I see two heads now if I
  • 00:12:30
    flip three
  • 00:12:32
    coins the combinations are a few more
  • 00:12:35
    right it can have the first one fall
  • 00:12:37
    heads the second one tails the third one
  • 00:12:40
    tails the first one fall heads the
  • 00:12:43
    second heads the third one tails and so
  • 00:12:45
    on and so forth all combinations right
  • 00:12:47
    if I analyze these combinations I can
  • 00:12:50
    see that there's one chance in W in
  • 00:12:52
    which I get no heads which is where the
  • 00:12:55
    three coins fall tails and there's one
  • 00:12:58
    chance in which I see three heads in
  • 00:13:01
    which all three coins fall heads and
  • 00:13:04
    there's equal number of chances that I
  • 00:13:06
    see one head or two heads and so on and
  • 00:13:10
    so forth if I do do this for uh five
  • 00:13:13
    coins this is what it's looking like
  • 00:13:15
    right this is what my counts are looking
  • 00:13:17
    like and you can see that this starts
  • 00:13:20
    forming a curve right like a a
  • 00:13:24
    bell-shaped curve
  • 00:13:26
    here
  • 00:13:27
    right
  • 00:13:31
    in the the the the N the the larger the
  • 00:13:35
    number of coins that I toss and
  • 00:13:38
    interestingly if I toss five coins for
  • 00:13:41
    example in this
  • 00:13:43
    five and I think that the coins are
  • 00:13:46
    balanced so there's 50% chance of
  • 00:13:48
    getting heads and tails right 50% chance
  • 00:13:51
    then if I TOS five coins well 50% of
  • 00:13:54
    five is you know between two and three
  • 00:13:56
    and the vast majorities of of heads the
  • 00:13:59
    vast majorities of Trials I will see two
  • 00:14:02
    or three heads this is what this graph
  • 00:14:04
    is
  • 00:14:05
    indicating this is how the coin toss
  • 00:14:08
    behaves
  • 00:14:11
    now this is called a binomial
  • 00:14:14
    distribution okay many cases with with
  • 00:14:17
    uh uh success or failure with a certain
  • 00:14:20
    probability of success will look like
  • 00:14:23
    this
  • 00:14:25
    okay so for example if I cost 15 coins
  • 00:14:30
    and the probability of heads is 0.5 so
  • 00:14:32
    basically it's a fair coin right I will
  • 00:14:35
    see 15 what's half of 15 is about around
  • 00:14:38
    seven and eight right so I see the bulk
  • 00:14:44
    of of the
  • 00:14:46
    heads between seven and eight heads
  • 00:14:49
    there are rare cases few cases in which
  • 00:14:51
    I see you know 12 13 or 14 heads or 15
  • 00:14:56
    they're rare cases in which I see
  • 00:14:59
    say between four 3 2 one or no heads at
  • 00:15:03
    all right so these are these are
  • 00:15:07
    the this is how the distribution behaves
  • 00:15:11
    now if the coin is not
  • 00:15:14
    fair excuse me for example the
  • 00:15:17
    probability of heads is only 20% so it
  • 00:15:19
    always falls on Tails this curve is
  • 00:15:24
    skewed okay it's not the Bell shape
  • 00:15:27
    curve that you saw earlier but it's CED
  • 00:15:30
    and it is likely that I will see in this
  • 00:15:32
    15 coin tosses somewhere in the vicinity
  • 00:15:35
    of two three or four heads only for the
  • 00:15:38
    most part it's going to be very rare
  • 00:15:41
    that I see seven or eight heads okay
  • 00:15:45
    because the probability of heads is
  • 00:15:48
    lower this is how coin tosses behave now
  • 00:15:52
    with this in
  • 00:15:54
    mind um with this in
  • 00:15:57
    mind we will see that there are formulas
  • 00:16:01
    to compute say for example well what's
  • 00:16:03
    the probability of heads if if the
  • 00:16:06
    probability of heads is 0.2 and um I
  • 00:16:10
    don't
  • 00:16:11
    know I have 15 uh coin tosses or 100
  • 00:16:15
    coin tosses well what's the probability
  • 00:16:18
    that I see for
  • 00:16:19
    example seven heads there are formulas
  • 00:16:23
    to compute that and we're going to use
  • 00:16:25
    them so let's go back to our example
  • 00:16:29
    so the five rounds of 10 coin tosses so
  • 00:16:32
    I
  • 00:16:33
    just uh did 10 coin I picked randomly a
  • 00:16:36
    coin without knowing this time without
  • 00:16:38
    knowing which coin it was and I tossed
  • 00:16:41
    it 10 times right and for example the
  • 00:16:44
    first time I picked a coin and and I
  • 00:16:46
    tossed it it
  • 00:16:48
    yielded this number of heads and and
  • 00:16:50
    Tails right the second time it yielded
  • 00:16:53
    the the rest and so on and so forth
  • 00:16:57
    so if that's
  • 00:17:00
    the let's say that's the case now and I
  • 00:17:04
    made up absolutely made up that coin a
  • 00:17:09
    will have 60% chance of heads and coin B
  • 00:17:11
    will have uh 55 55% chance of uh of
  • 00:17:17
    taals
  • 00:17:20
    so this is wrong this should be a little
  • 00:17:24
    uh a 55 not a
  • 00:17:26
    five now
  • 00:17:30
    these are the tosses right so for each
  • 00:17:32
    coin these are my 10 tosses for each
  • 00:17:34
    coin that I picked coin A and B I don't
  • 00:17:36
    know which one of these was coin a was
  • 00:17:38
    was coin B but I just saw the data
  • 00:17:41
    basically this is saying I have my
  • 00:17:44
    patient data I have my buyer data but I
  • 00:17:47
    don't know which marketing campaign I
  • 00:17:48
    don't know which treatment okay and I
  • 00:17:51
    and and and also I don't know what's the
  • 00:17:53
    mean ratio of success for the treatment
  • 00:17:56
    for the marketing campaign for the coin
  • 00:17:57
    toss so I just made up these
  • 00:18:00
    two now let's take the first round this
  • 00:18:03
    one the round number one there's five
  • 00:18:05
    heads and five tails so the proportion
  • 00:18:08
    is 5 over 10 heads and 5 over 10 Tails
  • 00:18:12
    now we'll compute the likelihood that it
  • 00:18:14
    was from coin a and coin B using the
  • 00:18:16
    binomial
  • 00:18:18
    distribution okay so to compute the
  • 00:18:21
    likelihood let me go back
  • 00:18:23
    to to
  • 00:18:26
    um to the this graph for example
  • 00:18:31
    okay in this
  • 00:18:34
    graph if I find for example let's say my
  • 00:18:38
    coin has um 50% chance if I find five
  • 00:18:42
    heads so
  • 00:18:45
    here five heads well what is the
  • 00:18:49
    probability well the question is what is
  • 00:18:50
    the probability that these five heads
  • 00:18:54
    came from a coin that behaves like
  • 00:18:57
    this as supposed to for example a coin
  • 00:18:59
    that behaves like
  • 00:19:01
    this right where most of the most of the
  • 00:19:06
    of the of the times it will produce five
  • 00:19:09
    heads right so what's the probability
  • 00:19:11
    that I found five heads in a coin in a
  • 00:19:13
    Fair coin for example in 10 tosses of a
  • 00:19:16
    fair coin that is what I need to ask
  • 00:19:18
    myself and then with the probability of
  • 00:19:21
    0.6 what's the probability that I found
  • 00:19:23
    five heads in a coin that behaves like a
  • 00:19:26
    coin that has a probability of 0.
  • 00:19:30
    six and for that there's um there's a
  • 00:19:35
    little formula here which is the
  • 00:19:36
    binomial distribution probability
  • 00:19:42
    okay and the idea here is that this
  • 00:19:44
    formula will give us if my coin has
  • 00:19:47
    probability Theta on N trails and in
  • 00:19:51
    this case 10 trails with K successes
  • 00:19:54
    that's the number of heads right five
  • 00:19:57
    this is the probability
  • 00:19:59
    that these K successes came from a coin
  • 00:20:06
    with with this probability okay and the
  • 00:20:10
    question is well what's the probability
  • 00:20:11
    that it came from coin a and what's the
  • 00:20:13
    probability that it came from coin B
  • 00:20:15
    right and the one that has the higher
  • 00:20:17
    probability so far is the most likely
  • 00:20:18
    coin to have been picked that's the
  • 00:20:21
    that's the
  • 00:20:22
    idea
  • 00:20:26
    so now we move down so we have let's
  • 00:20:29
    let's compute these
  • 00:20:30
    things so because oh by the way a little
  • 00:20:33
    math here because this thing this term
  • 00:20:36
    here is constant I'm going to ignore it
  • 00:20:38
    okay because it it won't affect the
  • 00:20:40
    computation it won't affect will affect
  • 00:20:42
    the computation it won't affect which
  • 00:20:43
    one's bigger which one's lower and it
  • 00:20:45
    won't affect the the step that I want to
  • 00:20:47
    do
  • 00:20:49
    next so we have recapping my mean
  • 00:20:52
    invented mean of 0.6 and my invented
  • 00:20:54
    mean of 0.5 for the other
  • 00:20:56
    coin I was plus 0.5 not 0.55
  • 00:21:01
    so uh we take the first round with uh 5
  • 00:21:04
    over 10 heads and 5 over 10 Tails we
  • 00:21:06
    will see we'll compute the likelihood of
  • 00:21:09
    coming from coin a using this formula
  • 00:21:13
    okay and H now stands for
  • 00:21:16
    heads and that gives us
  • 00:21:20
    0.0079 okay or eight and the likelihood
  • 00:21:23
    of coin B is
  • 00:21:27
    0.0000 976 so
  • 00:21:30
    0.1 mostly right now right now we can
  • 00:21:34
    say that it's more likely to have come
  • 00:21:36
    from coin B which is correct right uh
  • 00:21:39
    than from coin a but the thing is that
  • 00:21:42
    we now because we only have two coins we
  • 00:21:44
    need to convert this into probabilities
  • 00:21:47
    these likelihoods we need to convert
  • 00:21:49
    them into probabilities so what we do is
  • 00:21:52
    we
  • 00:21:54
    add these two numbers right and and then
  • 00:21:59
    we divide this guy by the sum and then
  • 00:22:02
    we divide this guy by the sum and we get
  • 00:22:06
    0.45 for a and 0.55 for B this procedure
  • 00:22:11
    is called
  • 00:22:12
    normalization okay again take the sum of
  • 00:22:16
    these two that's going to give you a
  • 00:22:17
    number and then divide this first number
  • 00:22:21
    by that sum and this second number by
  • 00:22:23
    that sum if you divide the first number
  • 00:22:24
    by that sum you're going to get 0.45 if
  • 00:22:27
    you divide the second number by the sum
  • 00:22:28
    you're going to get
  • 00:22:29
    0.55 okay and this is the probability
  • 00:22:33
    that the first 10 coins came from
  • 00:22:37
    a and the first 10 coins came from B
  • 00:22:40
    given this means that I that I gave
  • 00:22:43
    right and it makes sense if it had five
  • 00:22:45
    taals and B has 50% of success well it
  • 00:22:49
    looks like it hit the mark for B right
  • 00:22:52
    and not quite for a this is what these
  • 00:22:54
    probabilities are
  • 00:22:56
    saying so we're going to do this
  • 00:22:58
    this
  • 00:23:00
    um for all coin tosses okay we're going
  • 00:23:03
    to do this for all of our trials for all
  • 00:23:05
    of our five
  • 00:23:07
    trials
  • 00:23:09
    now let's recap the probability that the
  • 00:23:12
    first round came from coin a was 0.45
  • 00:23:16
    the probability they came from coin B
  • 00:23:17
    was 0.55 now let's estimate the likely
  • 00:23:21
    number of heads and tails from those
  • 00:23:23
    different coins so from coin a the
  • 00:23:27
    likely number of heads or the estimated
  • 00:23:29
    number of heads is 0.45 which is you
  • 00:23:32
    know the the likelihood that it came
  • 00:23:34
    from coin a times the actual number of
  • 00:23:37
    heads right that gives you 2.2 heads so
  • 00:23:40
    if this had came from coin a then then I
  • 00:23:45
    I should have seen 2.2
  • 00:23:47
    heads now and Tails is 2.2 Tails because
  • 00:23:52
    it's the same basically it's the same
  • 00:23:54
    computation now if it came from coin B
  • 00:23:58
    then I multiply this proportion by five
  • 00:24:00
    heads which is what I saw and that gives
  • 00:24:02
    me
  • 00:24:04
    2.8 and 2.8 Tails I will tally these
  • 00:24:08
    numbers and I will do this for all five
  • 00:24:11
    runs and I will end up with something
  • 00:24:13
    like
  • 00:24:14
    this these are my
  • 00:24:17
    cases then for the first case I got
  • 00:24:21
    0.45 times the likelihood that times my
  • 00:24:24
    belief that it's from coin a and 0.55
  • 00:24:28
    times my belief that it was from coin B
  • 00:24:30
    I got from coin a 2.2 heads and 2.2
  • 00:24:34
    tails and I got from coin B 2.8 heads
  • 00:24:37
    and 2.8 Tails okay I did this for all
  • 00:24:42
    five tosses and I got these numbers here
  • 00:24:44
    then I add I add these numbers the
  • 00:24:46
    numbers of heads I add the number of
  • 00:24:48
    tails for each coin and I get for coin 8
  • 00:24:52
    21.3 heads and 8.6 tails and here here I
  • 00:24:58
    get 11.7 heads and 8.4 tails and what I
  • 00:25:02
    will do is with these
  • 00:25:04
    numbers I will compute the new Theta the
  • 00:25:08
    new means for these coins so for example
  • 00:25:11
    for the first
  • 00:25:12
    coin and I'm going to use this formula
  • 00:25:14
    the number of heads divided by the
  • 00:25:16
    number of heads plus Tails so for
  • 00:25:19
    example for the first number there for
  • 00:25:22
    the first coin for coin a I will add uh
  • 00:25:26
    21 3 plus 8.6 and that's going to go in
  • 00:25:31
    the lower bottom of the fraction right
  • 00:25:33
    so and that um
  • 00:25:37
    21.3 and
  • 00:25:39
    8.6 that is basically
  • 00:25:42
    29.9 and the number of heads here which
  • 00:25:45
    is 21.3 I'm going to divide the number
  • 00:25:48
    of
  • 00:25:49
    heads by
  • 00:25:51
    [Music]
  • 00:25:52
    um by the number of tail by the by the
  • 00:25:55
    sum of heads and tails I will do the
  • 00:25:57
    same for coin B and this will give me
  • 00:25:59
    the new thetas for the
  • 00:26:04
    coins see 21.3 divided by the sum 21.3 +
  • 00:26:08
    8.6 so this these
  • 00:26:11
    numbers here come from these numbers
  • 00:26:15
    here
  • 00:26:17
    okay I just want to point out but I'm
  • 00:26:20
    covering them okay and that gives you 71
  • 00:26:23
    if you do the same for coin B you get
  • 00:26:25
    the new Theta of 0.58
  • 00:26:28
    now with these new
  • 00:26:30
    thetas this new thetas this will go will
  • 00:26:35
    be put in place of
  • 00:26:37
    this right and this number will go in
  • 00:26:41
    place of this
  • 00:26:43
    one you see how the thetas now are
  • 00:26:45
    changing
  • 00:26:46
    slightly and then I'll go over the whole
  • 00:26:49
    thing again I will again compute the
  • 00:26:52
    probability using the binomial formula
  • 00:26:54
    the probability that it came from these
  • 00:26:57
    that that uh each of these each of these
  • 00:26:59
    runs came from coin a and coin B I will
  • 00:27:02
    compute the weights in absolute
  • 00:27:05
    probability terms I will register the
  • 00:27:07
    number of heads the expected number of
  • 00:27:08
    heads and the expected number of tails
  • 00:27:10
    for coin A and B and I will compute a
  • 00:27:12
    new mean and so on and so forth I will
  • 00:27:14
    do this cycle many many times until the
  • 00:27:17
    the computation of means don't change at
  • 00:27:19
    some point they settle okay or they
  • 00:27:22
    start changing you know in the fifth
  • 00:27:24
    decimal which you don't really care too
  • 00:27:26
    much right well uh long story short
  • 00:27:32
    these coins
  • 00:27:34
    settle
  • 00:27:35
    um these coins will settle with these
  • 00:27:39
    means 0 52 for coin B and 80 for coin a
  • 00:27:44
    so coin a is going to be pretty
  • 00:27:47
    um pretty uh um pretty skewed okay so
  • 00:27:54
    once you have the means right once you
  • 00:27:57
    have the means
  • 00:27:58
    then
  • 00:27:59
    again Computing the the Computing doing
  • 00:28:03
    this step right the the estimation step
  • 00:28:05
    okay you will see whether this first run
  • 00:28:08
    is more likely to have come from coin A
  • 00:28:10
    or B and so on and so forth okay and you
  • 00:28:13
    can determine using expectation
  • 00:28:16
    maximization you can determine whether
  • 00:28:19
    the data that you see came from coin a
  • 00:28:22
    or coin B and what is the mean uh
  • 00:28:28
    probability of um of success for the
  • 00:28:32
    first condition and the second condition
  • 00:28:34
    or the first coin and the second coin
  • 00:28:36
    and that is basically estimation
  • 00:28:38
    maximization
Tag
  • algoritmo EM
  • stima
  • massimizzazione
  • distribuzione binomiale
  • probabilità
  • normalizzazione
  • coin toss
  • marketing
  • trattamenti medici
  • analisi dei dati