微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

高斯混合模型 - 获得给定概率值的轮廓:Matlab

如何解决高斯混合模型 - 获得给定概率值的轮廓:Matlab

我需要确定拟合数据的 GMM 的 99% 概率轮廓。按照这个示例,我希望能够指定要绘制哪些等高线,以及它们的 x、y。

mu1 = [1 2]; Sigma1 = [2 0; 0 0.5];
mu2 = [-3 -5]; Sigma2 = [1 0;0 1];
X = [mvnrnd(mu1,Sigma1,1000); mvnrnd(mu2,Sigma2,1000)];
GMModel = fitgmdist(X,2);
figure
y = [zeros(1000,1);ones(1000,1)];
h = gscatter(X(:,1),X(:,2),y);
hold on
gmPDF = @(x,y) arrayfun(@(x0,y0) pdf(GMModel,[x0 y0]),x,y);
g = gca;
fcontour(gmPDF,[g.XLim g.YLim])
title('{\bf Scatter Plot and Fitted Gaussian Mixture Contours}')
legend(h,'Model 0','Model1')
hold off

因此,在下图中,我希望能够用黑色虚线“k”绘制 99%。知道如何做到这一点吗?

enter image description here

解决方法

指定Enter your WRDS username [root]:......... Enter your password:........ WRDS recommends setting up a .pgpass file. You can find more info here: https://www.postgresql.org/docs/9.5/static/libpq-pgpass.html. There was an error with your password. --------------------------------------------------------------------------- OperationalError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/sqlalchemy/engine/base.py in _wrap_pool_connect(self,fn,connection) 3210 try: -> 3211 return fn() 3212 except dialect.dbapi.Error as e: 83 frames OperationalError: fe_sendauth: no password supplied The above exception was the direct cause of the following exception: OperationalError Traceback (most recent call last) OperationalError: (psycopg2.OperationalError) fe_sendauth: no password supplied (Background on this error at: http://sqlalche.me/e/14/e3q8) During handling of the above exception,another exception occurred: OperationalError Traceback (most recent call last) OperationalError: could not translate host name "12GO@wrds-pgdata.wharton.upenn.edu" to address: Name or service not known The above exception was the direct cause of the following exception: OperationalError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py in connect(dsn,connection_factory,cursor_factory,**kwargs) 120 121 dsn = _ext.make_dsn(dsn,**kwargs) --> 122 conn = _connect(dsn,connection_factory=connection_factory,**kwasync) 123 if cursor_factory is not None: 124 conn.cursor_factory = cursor_factory OperationalError: (psycopg2.OperationalError) could not translate host name "12GO@wrds-pgdata.wharton.upenn.edu" to address: Name or service not known (Background on this error at: http://sqlalche.me/e/14/e3q8) 的LevelList属性可以显示并获取给定轮廓线的坐标,然后读取轮廓句柄的ContourMatrix属性:

fcontour

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。