Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9279963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:45:25+00:00 2026-06-18T17:45:25+00:00

Could anyone provide a simple numeric example of the EM algorithm as I am

  • 0

Could anyone provide a simple numeric example of the EM algorithm as I am not sure about the formulas given? A really simple one with 4 or 5 Cartesian coordinates would perfectly do.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:45:26+00:00Added an answer on June 18, 2026 at 5:45 pm

    what about this:
    http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Clustering/Expectation_Maximization_(EM)#A_simple_example

    I had also written a simple example in (edit)R a year ago, unfortunately I am unable to locate it. I’ll try again to find it later.

    EDIT: Here it is –

    EM <- function() 
    {
        ### Read file, get necessary cols 
        dataFile <- read.csv("wine.csv", head = FALSE, sep = ",")
        sl <- dataFile[, 2]
        #sw <- dataFile[, 3]
        #pl <- dataFile[, 3]
        #pw <- dataFile[, 4]
        class <- dataFile[, 5]
        N <- length(sl)
        pi1 <- 0.5
            ### Init ### 
        rand1 <- floor(runif(1) * N) 
        rand2 <- floor(runif(1) * N) 
        mu1 <- sl[rand1]
        mu2 <- sl[rand2] 
        mean1 <- sum(sl)/N
        sigma1 <- sum(  (sl - mean1) ** 2)   / N 
        sigma2 <- sigma1
        print(mu1)
        print(mu2)
        print(sigma1)
        print(sigma2)
        COUNTLIM <- 10
        count <- 1 
        prevmu1 <- 0.0; 
        prevmu2 <- 0.0; 
        prevsigma1 <- 0.0; 
        prevsigma2 <- 0.0; 
        gamma <- array(0, length(sl)) 
        while (count <= COUNTLIM) 
        { 
            gamma <- pi1 * dnorm(sl, mu2, sigma2)/ ( (1 - pi1) * dnorm(sl, mu1, sigma1) + pi1 * dnorm(sl, mu2, sigma2))
            mu1 <- sum((1 - gamma) * sl) / sum(1 - gamma)
    mu2 <- sum((gamma) * sl) / sum(gamma)
    sigma1 <- sum((1 - gamma) * (sl - mu1) ** 2)/sum(1 - gamma) sigma2 <- sum((gamma) * (sl - mu2) ** 2)/sum(gamma) pi1 <- sum(gamma)/N print(c(mu1, mu2, sigma1, sigma2, pi1)) if (count == 1) { prevmu1 <- mu1; prevmu2 <- mu2; prevsigma1 <- sigma1; prevsigma2 <- sigma2; } else { val <- ((prevmu1 - mu1)*2 + (prevmu2 - mu2)*2 + (prevsigma1 - sigma1)*2 + (prevsigma2 - sigma2)*2) ** 0.5; print(c("val: " , val)) if (val <= 1) { break; } } count <- count + 1 } print(mu1) print(mu2) print(sigma1) print(sigma2) }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could really use an example of this. Can anyone provide me with a
Could anyone provide working example in C++ with event handling for Skype4COM, i.e. incoming
Apologies for the lack of a code example but I'm not sure I could
Could anyone provide me with the pointers to source code for linux commands such
http://docs.oracle.com/javase/1.5.0/docs/guide/jpda/trace.html Could anyone please provide me couple of examples of how to use Java
Could anyone guide me in created a simple app in JS? What the app
I'm sure I'm overlooking something very basic. If anyone could offer some help, or
This is a really simple question I am sure, so please bear with me.
Getting: Could not load file or assembly 'Interop.Shell32' or one of its dependencies after
Could anyone please let me know if there is a way to programatically determine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.