{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Ransaka Ravihara",
  "title_listed": "Gaussian Mixture Model Clearly Explained",
  "keywords": "GMM,高斯混合模型,聚类",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "部分免费/会员墙",
  "url": "https://towardsdatascience.com/gaussian-mixture-model-clearly-explained-115010f7d4cf/",
  "publish_date": "2023-01",
  "corpus_stage": "预训练/SFT",
  "notes": "",
  "id": "4add68272f5f",
  "collected_at": "2026-10-01T23:28:28",
  "title": "Gaussian Mixture Model Clearly Explained | Towards Data Science",
  "body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# Gaussian Mixture Model Clearly Explained\nThe only guide you need to learn everything about GMM\n[Ransaka Ravihara](https://towardsdatascience.com/author/ransakaravihara/)\nJanuary 10, 20239 min read\n![Photo by Planet Volumes on Unsplash](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/0ucj9wkyb_Q6kZ2xn-scaled.jpg)\nPhoto by [Planet Volumes](https://unsplash.com/@planetvolumes?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\nWhen we talk about Gaussian Mixture Model (later, this will be denoted as GMM in this article), it's essential to know how the KMeans algorithm works. Because GMM is quite similar to the KMeans, more likely it's a probabilistic version of KMeans. This probabilistic feature allows GMM to be applied to many complex problems that KMeans can't fit into.\nIn summary, KMeans have below limitations,\n  1. It assumed that the clusters were spherical and equally sized, which is not valid in most real-world scenarios.\n  2. It's a hard clustering method. Meaning each data point is assigned to a single cluster.\n\n\nDue to these limitations, we should know alternatives for KMeans when working on our machine learning projects. In this article, we will explore one of the best alternatives for KMeans clustering, called the Gaussian Mixture Model.\nThroughout this article, we will be covering the below points.\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\n  1. How Gaussian Mixture Model (GMM) algorithm works - in plain English.\n  2. Mathematics behind GMM.\n  3. Implement GMM using Python from scratch.\n\n\n### How Gaussian Mixture Model (GMM) algorithm works - in plain English\nAs I have mentioned earlier, we can call GMM probabilistic KMeans because the starting point and training process of the KMeans and GMM are the same. However, KMeans uses a distance-based approach, and GMM uses a probabilistic approach. There is one primary assumption in GMM: the dataset consists of multiple Gaussians, in other words, a mixture of the gaussian.\n![Mixtures of Gaussians | Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1Uk8-tUCNnheugt362g35Hw.png)\nMixtures of Gaussians | Image by Author\nThe above kind of distribution is often called [multi-model distribution](https://en.wikipedia.org/wiki/Multimodal_distribution). Each peak represents the different gaussian distribution or the cluster in our dataset. But the question is,\n> how do we estimate these distributions?\nBefore answering this question, let's create some gaussian distribution first. Please note here I am generating [multivariate normal distribution](https://en.wikipedia.org/wiki/Multivariate_normal_distribution); it's a higher dimensional extension of the [univariate normal distribution](https://en.wikipedia.org/wiki/Normal_distribution).\nLet's define the mean and [covariance](https://en.wikipedia.org/wiki/Covariance) of our data points. Using mean and covariance, we can generate the distribution as follows.\npython\n\n```\n# Set the mean and covariance\nmean1 = [0, 0]\nmean2 = [2, 0]\ncov1 = [[1, .7], [.7, 1]]\ncov2 = [[.5, .4], [.4, .5]]\n\n# Generate data from the mean and covariance\ndata1 = np.random.multivariate_normal(mean1, cov1, size=1000)\ndata2 = np.random.multivariate_normal(mean2, cov2, size=1000)\n```\n\nLet's plot the data.\npython\n\n```\nplt.figure(figsize=(10,6))\n\nplt.scatter(data1[:,0],data1[:,1])\nplt.scatter(data2[:,0],data2[:,1])\n\nsns.kdeplot(data1[:, 0], data1[:, 1], levels=20, linewidth=10, color='k', alpha=0.2)\nsns.kdeplot(data2[:, 0], data2[:, 1], levels=20, linewidth=10, color='k', alpha=0.2)\n\nplt.grid(False)\nplt.show()\n```\n\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1oprWf1G7RMCy47ZgLfRWRA.png)\nAs you can see here, we generated random gaussian distribution using mean and covariance matrices. What about reversing this process? That's what exactly GMM is doing. But how?\n> Because, in the beginning, we didn't have any insights about clusters nor their associated mean and covariance matrices.\nWell, It happens according to the below steps,\n  1. Decide the number of clusters (to decide this, we can use domain knowledge or other methods such as [BIC/AIC](https://stats.stackexchange.com/questions/368560/elbow-test-using-aic-bic-for-identifying-number-of-clusters-using-gmm)) for the given dataset. Assume that we have 1000 data points, and we set the number of groups as 2.\n  2. Initiate mean, covariance, and weight parameter per cluster. (we will explore more about this in a later section)\n  3. Use the [Expectation Maximization](https://en.wikipedia.org/wiki/Expectation%E2%80%93maximization_algorithm) algorithm to do the following,\n\n\n  * Expectation Step (E step): Calculate the probability of each data point belonging to each distribution, then evaluate the likelihood function using the current estimate for the parameters\n  * Maximization step (M step): Update the previous mean, covariance, and weight parameters to maximize the expected likelihood found in the E step\n  * Repeat these steps until the model converges.\n\n\nWith this information, I am concluding the no-math explanation of the GMM algorithm.\n* * *\n## Mathematics behind GMM\nThe core of GMM lies within Expectation Maximization (EM) algorithm described in the previous section.\nLet's demonstrate how the EM algorithm is applied in the GMM.\n_**Step 01: Initialize mean, covariance, and weight parameters**_\n  1. mean (μ): initialize randomly.\n  2. covariance (Σ): initialize randomly\n  3. weight (mixing coefficients) (π): fraction per class refers to the likelihood that a particular data point belongs to each class. In the beginning, this will be equal for all clusters. Assume that we fit a GMM with three components. In this case weight parameter might be set to 1/3 for each component, resulting in a probability distribution of (1/3, 1/3, 1/3).\n\n\n**Step 02: Expectation Step (E step)**\n  * For each data point 𝑥𝑖:\n  * Calculate the probability that the data point belongs to cluster (𝑐) using the below equation. k _i_s the number of distributions we are supposed to find.\n\n\n![Equation 01 | Image by Autor](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1IECDhlSkn7sbXNhIdsYCGg.png)\nEquation 01 | Image by Autor\nWhere 𝜋_𝑐 is the mixing coefficient (sometimes called weight) for the Gaussian distribution c, which was initialized in the previous stage, and 𝑁(**𝒙** | 𝝁,𝚺) describes the probability density function (PDF) of a Gaussian distribution with mean 𝜇 and covariance Σ with respect to data point x; We c _an_ denote it as below.\n![Equation 02 | Image by Autor](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1PnKPkjBo9pobgySy4RjFXA.png)\nEquation 02 | Image by Autor\nThe E-step computes these probabilities using the current estimates of the model's parameters. These probabilities are typically referred to as the \"responsibilities\" of the Gaussian distributions. They are represented by the variables _r _ic_ _**,**_ where _**i**_ is the index of the data point, and _**c**_ is the index of the Gaussian distribution. The responsibility measures how much the _**c**_ -th Gaussian distribution is responsible for generating the _**i**_ -th data point. Conditional probability is used here, more specifically, _Bayes theorem._\nLet's take a simple example. Assume we have 100 data points and need to cluster them into two groups. We can write _r _ic(i=20,c=1)_ as follows. Where _**i**_ represents the data point's index, and _**c**_ represents the index of the cluster we are considering _**.**_\nPlease note at the beginning, 𝜋_𝑐 i**n** itialized to equal for each cluster c = 1,2,3,..,k. In our case, 𝜋_1 = 𝜋_2 = 1**/2.******\n![Equation 03 | Image by Autor](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/13C47_frRpVBVaGv_-1ugNw.png)\nEquation 03 | Image by Autor\nThe result of the E-step is a set of responsibilities for each data point and each Gaussian distribution in the mixture model. These responsibilities are used in the M-step to update the estimates of the model's parameters.\n**Step 03: Maximization Step (M step)**\nIn this step, the algorithm uses the responsibilities of the Gaussian distributions (computed in the E-step) to update the estimates of the model's parameters.\nThe M-step updates the estimates of the parameters as follows:\n![Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1E4oZd7tgePp2Zg8ET1BwGw.png)\nImage by Author\n  1. Update the _πc (_mixing coefficients) using equation 4 above.\n  2. Update the _μc_ using equation number 5 above.\n  3. Then update the _Σc_ using the 6th equation.\n\n\nThis updated estimate is used in the next E-step to compute new responsibilities for the data points.\nSo on and so forth, this process will repeat until algorithm convergence, typically achieved when the model parameters do not change significantly from one iteration to the next.\n_Lots of ugly and complex equations, right? :)_\n> Let's summarize the above facts into one simple diagram,\n![Summary of EM steps of GMM | Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/11qJLr2nUDX2LczayrnthUw.png)\nSummary of EM steps of GMM | Image by Author\nDon't worry; when it comes to coding, it will be one line per each equation. Let's start to implement GMM from scratch using Python.\n* * *\n## Implement GMM using Python from scratch.\n![Animated GMM | Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1GWkzcCKBqQV7GgwTaa4l4g.gif)\nAnimated GMM | Image by Author\nFirst thing first, let's create a fake dataset. In this section, I will implement GMM for the 1-D dataset.\npython\n\n```\nimport numpy as np\n\nn_samples = 100\nmu1, sigma1 = -5, 1.2 \nmu2, sigma2 = 5, 1.8 \nmu3, sigma3 = 0, 1.6 \n\nx1 = np.random.normal(loc = mu1, scale = np.sqrt(sigma1), size = n_samples)\nx2 = np.random.normal(loc = mu2, scale = np.sqrt(sigma2), size = n_samples)\nx3 = np.random.normal(loc = mu3, scale = np.sqrt(sigma3), size = n_samples)\n\nX = np.concatenate((x1,x2,x3))\n```\n\nLet's create a helper function to plot our data.\npython\n\n```\nfrom scipy.stats import norm\n\ndef plot_pdf(mu,sigma,label,alpha=0.5,linestyle='k--',density=True):\n    \"\"\"\n    Plot 1-D data and its PDF curve.\n\n    \"\"\"\n    # Compute the mean and standard deviation of the data\n\n    # Plot the data\n\n    X = norm.rvs(mu, sigma, size=1000)\n\n    plt.hist(X, bins=50, density=density, alpha=alpha,label=label)\n\n    # Plot the PDF\n    x = np.linspace(X.min(), X.max(), 1000)\n    y = norm.pdf(x, mu, sigma)\n    plt.plot(x, y, linestyle)\n```\n\nAnd plot the generated data as follows. Please note that instead of plotting the data itself, I have plotted the probability density of each sample.\npython\n\n```\nplot_pdf(mu1,sigma1,label=r\"$mu={}  ;  sigma={}$\".format(mu1,sigma1))\nplot_pdf(mu2,sigma2,label=r\"$mu={}  ;  sigma={}$\".format(mu2,sigma2))\nplot_pdf(mu3,sigma3,label=r\"$mu={}  ;  sigma={}$\".format(mu3,sigma3))\nplt.legend()\nplt.show()\n```\n\n![Original Distribution | Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1kufy6ra6ygdGt3M4Zduk8g.png)\nOriginal Distribution | Image by Author\nLet's build each step described in the previous section,\n_Step 01: Initialize mean, covariance, and weights_\npython\n\n```\ndef random_init(n_compenents):\n\n    \"\"\"Initialize means, weights and variance randomly \n      and plot the initialization\n    \"\"\"\n\n    pi = np.ones((n_compenents)) / n_compenents\n    means = np.random.choice(X, n_compenents)\n    variances = np.random.random_sample(size=n_compenents)\n\n    plot_pdf(means[0],variances[0],'Random Init 01')\n    plot_pdf(means[1],variances[1],'Random Init 02')\n    plot_pdf(means[2],variances[2],'Random Init 03')\n\n    plt.legend()\n    plt.show()\n\n    return means,variances,pi\n```\n\n_Step 02: Expectation Step (E step)_\npython\n\n```\ndef step_expectation(X,n_components,means,variances):\n    \"\"\"E Step\n\n    Parameters\n    ----------\n    X : array-like, shape (n_samples,)\n        The data.\n    n_components : int\n        The number of clusters\n    means : array-like, shape (n_components,)\n        The means of each mixture component.\n    variances : array-like, shape (n_components,)\n        The variances of each mixture component.\n\n    Returns\n    -------\n    weights : array-like, shape (n_components,n_samples)\n    \"\"\"\n    weights = np.zeros((n_components,len(X)))\n    for j in range(n_components):\n        weights[j,:] = norm(loc=means[j],scale=np.sqrt(variances[j])).pdf(X)\n    return weights\n```\n\nAfter this function, we covered the first two equations we discussed in _E Step._ Here we have generated the gaussian distribution for the current model parameter _means_ and _variances._ We accomplished that by using the scipy's stat module. After, we used the pdf method to calculate the likelihood of belonging to each data point for each cluster.\n_Step 03: Maximization Step (M step)_\npython\n\n```\ndef step_maximization(X,weights,means,variances,n_compenents,pi):\n    \"\"\"M Step\n\n    Parameters\n    ----------\n    X : array-like, shape (n_samples,)\n        The data.\n    weights : array-like, shape (n_components,n_samples)\n        initilized weights array\n    means : array-like, shape (n_components,)\n        The means of each mixture component.\n    variances : array-like, shape (n_components,)\n        The variances of each mixture component.\n    n_components : int\n        The number of clusters\n    pi: array-like (n_components,)\n        mixture component weights\n\n    Returns\n    -------\n    means : array-like, shape (n_components,)\n        The means of each mixture component.\n    variances : array-like, shape (n_components,)\n        The variances of each mixture component.\n    \"\"\"\n    r = []\n    for j in range(n_compenents):  \n\n        r.append((weights[j] * pi[j]) / (np.sum([weights[i] * pi[i] for i in range(n_compenents)], axis=0)))\n\n        #5th equation above\n        means[j] = np.sum(r[j] * X) / (np.sum(r[j]))\n\n        #6th equation above\n        variances[j] = np.sum(r[j] * np.square(X - means[j])) / (np.sum(r[j]))\n\n        #4th equation above\n        pi[j] = np.mean(r[j])\n\n    return variances,means,pi\n```\n\nLet's implement the training loop.\npython\n\n```\ndef train_gmm(data,n_compenents=3,n_steps=50, plot_intermediate_steps_flag=True):\n    \"\"\" Training step of the GMM model\n\n    Parameters\n    ----------\n    data : array-like, shape (n_samples,)\n        The data.\n    n_components : int\n        The number of clusters\n    n_steps: int\n        number of iterations to run\n    \"\"\"\n\n    #intilize model parameters at the start\n    means,variances,pi = random_init(n_compenents)\n\n    for step in range(n_steps):\n        #perform E step\n        weights = step_expectation(data,n_compenents,means,variances)\n        #perform M step\n        variances,means,pi = step_maximization(X, weights, means, variances, n_compenents, pi)\n\n    plot_pdf(means,variances)\n```\n\nWhen we start the model training, we will do E and M steps according to the _n _steps_ parameter we set.\nBut in the actual use cases, you will use the scikit-learn version of the GMM more often. There you can find additional parameters, such as\n> _**tol** : d_efining the model's stop criteria. EM iterations will stop when the lower bound average gain is below the _tol_ parameter.\n> **init_params:** The method used to initialize the weights\nYou may refer to the documentation [here](https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html).\nAlright, let's see how our handcrafted GMM performs.\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1OAYZcNEne5qoi1-_YtxzSg.png)\nIn the above diagrams, red dashed lines represent the original distribution, while other graphs represent the learned distributions. After the 30th iteration, we can see that our model performed well on this toy dataset.\nYou can find the codes in this [GitHub repo](https://github.com/Ransaka/GMM-from-scratch) if you want to follow along with this article.\n### _Conclusion_\nThis article aims to give a comprehensive guide to Gaussian Mixture Model; however, readers are encouraged to experiment with different machine learning algorithms because _**no one best**_ _**algorithm**_ will work well for every problem. Also, the complexity of the machine learning algorithms we choose is worth noting. One common issue with GMM is it doesn't scale well to large datasets.\nThank you for reading! Connect with me on [LinkedIn](https://www.linkedin.com/in/ransaka/).\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657265628_qm714e.jpeg)\nWritten By\n## [Ransaka Ravihara](https://towardsdatascience.com/author/ransakaravihara/)\n[See all from Ransaka Ravihara](https://towardsdatascience.com/author/ransakaravihara/)\n[Data Science](https://towardsdatascience.com/tag/data-science/)[Gaussian Mixture Model](https://towardsdatascience.com/tag/gaussian-mixture-model/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fgaussian-mixture-model-clearly-explained-115010f7d4cf%2F&title=Gaussian%20Mixture%20Model%20Clearly%20Explained)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fgaussian-mixture-model-clearly-explained-115010f7d4cf%2F&title=Gaussian%20Mixture%20Model%20Clearly%20Explained)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fgaussian-mixture-model-clearly-explained-115010f7d4cf%2F&text=Gaussian%20Mixture%20Model%20Clearly%20Explained)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/1dwVL-apx5IpEtuHyz9vLCw-scaled.jpeg)](https://towardsdatascience.com/deep-learning-for-nlp-word-embeddings-4f5c90bcdab5/)\n## [Deep Learning for NLP: Word Embeddings](https://towardsdatascience.com/deep-learning-for-nlp-word-embeddings-4f5c90bcdab5/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nSimple and intuitive Word Embeddings\n[James Thorn](https://towardsdatascience.com/author/james-thorn/)\nJune 13, 20208 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/10/1NsiqOmebng-XVk_NaYWjiQ.png)](https://towardsdatascience.com/the-prerequisites-for-data-disruption-801ed5541c43/)\n## [The Prerequisites for Data Disruption](https://towardsdatascience.com/the-prerequisites-for-data-disruption-801ed5541c43/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nHow you build the strongest of data chapters\n[Rufus Lidman](https://towardsdatascience.com/author/datadisruptor/)\nOctober 26, 202119 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/02/0lD3TSviU-U5hPGiJ-scaled.jpg)](https://towardsdatascience.com/model-selection-with-imbalance-data-only-auc-may-not-save-you-5aed73c5efed/)\n## [Model Selection with Imbalance Data: Only AUC may Not Save you](https://towardsdatascience.com/model-selection-with-imbalance-data-only-auc-may-not-save-you-5aed73c5efed/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nAre you Searching Parameters Efficiently?\n[Marco Cerliani](https://towardsdatascience.com/author/cerlymarco/)\nFebruary 22, 20236 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/0ccqVBn_9X0Wkqao8-scaled.jpg)](https://towardsdatascience.com/forecasting-of-periodic-events-with-ml-5081db493c46/)\n## [Forecasting of periodic events with ML](https://towardsdatascience.com/forecasting-of-periodic-events-with-ml-5081db493c46/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nForecasting of events that occur periodically based on dates of previous events.\n[Anna Pastushko](https://towardsdatascience.com/author/annpastushko/)\nFebruary 13, 20217 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/0JGfltYm9_6YMqQaZ-scaled.jpg)](https://towardsdatascience.com/reducing-model-training-cost-with-active-learning-255b40a2aa98/)\n## [Reducing Model Training Cost With Active Learning](https://towardsdatascience.com/reducing-model-training-cost-with-active-learning-255b40a2aa98/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA complete case study with a Gaussian Process model.\n[Shuai Guo](https://towardsdatascience.com/author/shuaiguo/)\nJanuary 6, 202111 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/02/1e3hMInQ8cZ7Spw0PzSld5A.png)](https://towardsdatascience.com/bootstrapping-a-data-science-program-c90acab0a6ac/)\n## [Bootstrapping a data science program](https://towardsdatascience.com/bootstrapping-a-data-science-program-c90acab0a6ac/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nA strategy for building valuable data science products within high-growth startups\n[Avi Chad-Friedman](https://towardsdatascience.com/author/achad/)\nFebruary 17, 20222 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/0yPmtGvxpqVLztqCH-scaled.jpg)](https://towardsdatascience.com/big-data-in-financial-services-f3d4fd7a30cd/)\n## [Big Data in Financial Services](https://towardsdatascience.com/big-data-in-financial-services-f3d4fd7a30cd/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nFinancial Services industry to examine Big Data and the technologies employed\n[Saurav Singla](https://towardsdatascience.com/author/sauravsingla08/)\nOctober 15, 202014 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/10/1Y8grKHsaHyrtPSvVvyeYVQ.png)](https://towardsdatascience.com/how-and-why-to-use-llms-for-chunk-based-information-retrieval-5242f0133b55/)\n## [How and Why to use LLMs for Chunk-Based Information Retrieval](https://towardsdatascience.com/how-and-why-to-use-llms-for-chunk-based-information-retrieval-5242f0133b55/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nIn this article, I aim to explain how and why it's beneficial to use a Large Language Model (LLM) for chunk-based information retrieval.\n[Carlo Peron](https://towardsdatascience.com/author/peronc79/)\nOctober 28, 202410 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2019/05/1TafxL9dzcIu4fEP7TBXE7Q.png)](https://towardsdatascience.com/how-to-troubleshoot-your-azure-data-science-project-in-production-5382b66cbaf9/)\n## [How to keep an audit trail of your Azure Data Science project](https://towardsdatascience.com/how-to-troubleshoot-your-azure-data-science-project-in-production-5382b66cbaf9/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUsing Azure Machine Learning service and Azure DevOps\n[René Bremer](https://towardsdatascience.com/author/rebremer/)\nMay 26, 20197 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607631/image?etag=1781543525510&width=500&height=500) Critical Mistakes Companies Make When Integrating AI/ML into Their Processes ](https://towardsdatascience.com/critical-mistakes-companies-make-when-integrating-ai-ml-into-their-processes/ \"Critical Mistakes Companies Make When Integrating AI/ML into Their Processes\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n\n\n",
  "metadata": {
    "title": "Gaussian Mixture Model Clearly Explained | Towards Data Science",
    "description": "The only guide you need to learn everything about GMM",
    "keywords": null,
    "author": "Ransaka Ravihara",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Gaussian Mixture Model Clearly Explained",
    "og:description": "The only guide you need to learn everything about GMM",
    "og:url": "https://towardsdatascience.com/gaussian-mixture-model-clearly-explained-115010f7d4cf/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/11qJLr2nUDX2LczayrnthUw.png",
    "og:image:width": "722",
    "og:image:height": "522",
    "og:image:type": "image/png",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Ransaka Ravihara",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "9 min read",
    "article:published_time": "2023-01-10T18:46:35.000Z",
    "article:modified_time": "2023-01-10T18:46:35.000Z",
    "article:author": "https://towardsdatascience.com/author/ransakaravihara/"
  },
  "paywall": {
    "listed_paid": true,
    "detected": false,
    "marker": "",
    "public_only": true,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_000.txt",
      "chars": 284
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_001.txt",
      "chars": 297
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_002.txt",
      "chars": 364
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_003.txt",
      "chars": 465
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_004.txt",
      "chars": 234
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_005.txt",
      "chars": 508
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_006.txt",
      "chars": 666
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_007.txt",
      "chars": 1231
    },
    {
      "language": "txt",
      "file": "attachments/4add68272f5f/code/block_008.txt",
      "chars": 700
    }
  ],
  "images": [
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/0ucj9wkyb_Q6kZ2xn-scaled.jpg",
      "alt": "Photo by Planet Volumes on Unsplash",
      "local_path": "attachments/4add68272f5f/images/000.jpg",
      "bytes": 227648,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1Uk8-tUCNnheugt362g35Hw.png",
      "alt": "Mixtures of Gaussians | Image by Author",
      "local_path": "attachments/4add68272f5f/images/001.png",
      "bytes": 10880,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1IECDhlSkn7sbXNhIdsYCGg.png",
      "alt": "Equation 01 | Image by Autor",
      "local_path": "attachments/4add68272f5f/images/002.png",
      "bytes": 5285,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1PnKPkjBo9pobgySy4RjFXA.png",
      "alt": "Equation 02 | Image by Autor",
      "local_path": "attachments/4add68272f5f/images/003.png",
      "bytes": 7006,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/13C47_frRpVBVaGv_-1ugNw.png",
      "alt": "Equation 03 | Image by Autor",
      "local_path": "attachments/4add68272f5f/images/004.png",
      "bytes": 6806,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1E4oZd7tgePp2Zg8ET1BwGw.png",
      "alt": "Image by Author",
      "local_path": "attachments/4add68272f5f/images/005.png",
      "bytes": 9555,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/11qJLr2nUDX2LczayrnthUw.png",
      "alt": "Summary of EM steps of GMM | Image by Author",
      "local_path": "attachments/4add68272f5f/images/006.png",
      "bytes": 25084,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1GWkzcCKBqQV7GgwTaa4l4g.gif",
      "alt": "Animated GMM | Image by Author",
      "local_path": "attachments/4add68272f5f/images/007.gif",
      "bytes": 558474,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/01/1kufy6ra6ygdGt3M4Zduk8g.png",
      "alt": "Original Distribution | Image by Author",
      "local_path": "attachments/4add68272f5f/images/008.png",
      "bytes": 26818,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/1dwVL-apx5IpEtuHyz9vLCw-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/009.jpeg",
      "bytes": 248413,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/10/1NsiqOmebng-XVk_NaYWjiQ.png",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/010.png",
      "bytes": 8646,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/02/0lD3TSviU-U5hPGiJ-scaled.jpg",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/011.jpg",
      "bytes": 275170,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/0ccqVBn_9X0Wkqao8-scaled.jpg",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/012.jpg",
      "bytes": 365907,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/01/0JGfltYm9_6YMqQaZ-scaled.jpg",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/013.jpg",
      "bytes": 294890,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/02/1e3hMInQ8cZ7Spw0PzSld5A.png",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/014.png",
      "bytes": 23881,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/10/0yPmtGvxpqVLztqCH-scaled.jpg",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/015.jpg",
      "bytes": 1222512,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/10/1Y8grKHsaHyrtPSvVvyeYVQ.png",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/016.png",
      "bytes": 102855,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2019/05/1TafxL9dzcIu4fEP7TBXE7Q.png",
      "alt": "",
      "local_path": "attachments/4add68272f5f/images/017.png",
      "bytes": 70375,
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [
    {
      "src": "https://www.youtube.com/c/TowardsDataScience",
      "quality": "unavailable",
      "local_path": "",
      "note": "无1080p且无720p，未交付更低清晰度"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/ransakaravihara/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/gaussian-mixture-model/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/deep-learning-for-nlp-word-embeddings-4f5c90bcdab5/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/james-thorn/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/the-prerequisites-for-data-disruption-801ed5541c43/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/datadisruptor/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/model-selection-with-imbalance-data-only-auc-may-not-save-you-5aed73c5efed/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/cerlymarco/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/forecasting-of-periodic-events-with-ml-5081db493c46/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/machine-learning/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/@planetvolumes"
    },
    {
      "type": "external",
      "href": "https://unsplash.com"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Multimodal_distribution"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Multivariate_normal_distribution"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Normal_distribution"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Covariance"
    },
    {
      "type": "external",
      "href": "https://stats.stackexchange.com/questions/368560/elbow-test-using-aic-bic-for-identifying-number-of-clusters-using-gmm"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Expectation%E2%80%93maximization_algorithm"
    },
    {
      "type": "external",
      "href": "https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html"
    },
    {
      "type": "external",
      "href": "https://github.com/Ransaka/GMM-from-scratch"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/in/ransaka/"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=Gaussian+Mixture+Model+Clearly+Explained&u=https%3A%2F%2Ftowardsdatascience.com%2Fgaussian-mixture-model-clearly-explained-115010f7d4cf%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=Gaussian+Mixture+Model+Clearly+Explained&url=https%3A%2F%2Ftowardsdatascience.com%2Fgaussian-mixture-model-clearly-explained-115010f7d4cf%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=Gaussian+Mixture+Model+Clearly+Explained&url=https%3A%2F%2Ftowardsdatascience.com%2Fgaussian-mixture-model-clearly-explained-115010f7d4cf%2F"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/TowardsDataScience"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:11:49Z",
  "source_url": "https://towardsdatascience.com/gaussian-mixture-model-clearly-explained-115010f7d4cf/",
  "delivery_status": "excluded_paid",
  "discovery_status": "excluded_paid",
  "missing_reason": "按原约定排除付费/会员全文"
}