全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
matlab中二元正态分布函数 function data1, data2 = twogaussian(n1,mu1,cov1,n2,mu2,cov2);% data1, data2 = twogaussian(n1,mu1,sigma1,n2,mu2,sigma2);% Function to simulate data from 2 Gaussian densities in d dimensions% and to plot the data in the first 2 dimensions% INPUTS:% n1, n2: two integers, size of data set 1 and 2 respectively% mu1, mu2: two vectors of dimension 1 x d, means% for data set 1 and 2% cov1, cov2: two matrices of dimension d x d, covariance% matrices for data set 1 and 2 respectively% OUTPUTS:% data1: n1 x d matrix of data for data set 1% data2: n2 x d matrix of data for data set 2% check that the dimensionality of the mus and sigmas are consistentd1 = length(mu1); d2 = length(mu2); if (d1=d2) error(means are of different lengths); end;d = length(mu1); % d is the dimensionality of the datad1 d2 = size(cov1); if (d1=d2) error(cov1 is a non-square covariance matrix); end; if (d1=d) error(cov1 is of different dimensionality to mu1); end; d1 d2 = size(cov2); if (d1=d2) error(cov2 is a non-square covariance matrix); end; if (d1=d) error(cov2 is of different dimensionality to mu2); end;% Call the function mvnrnd.m to generate the two data setsdata1 = mvnrnd(mu1,cov1,n1);data2 = mvnrnd(mu2,cov2,n2); % Now plot the two data sets as a two-dimensional scatter plot% if d = 2: plot dimension1 on the xaxis and dimension 2 on the% yaxis. Plot the points from data1 as green circles o, and the% points from data2 as red crosses x.if . figure % open a figure window plot(data1(:,1),data1(:,2),b.);. % now plot data1 axis(-6 6 -6 6); % fix the lengths of the axes hold % hold the figure to overlay a 2nd plot plot(data2(:,1),data2(:,2),rx);% now plot data 2 xlabel(Dimension 1); ylabel(Dimension 2); title(Simulation of two-class Gaussian data in two dimensions);endfunction r = mvnrnd(mu,sigma,cases);%MVNRND Random matrices from the multivariate normal distribution.% R = MVNRND(MU,SIGMA,CASES) returns a matrix of random numbers% chosen from the multivariate normal distribution with mean vector,% MU, and covariance matrix, SIGMA. CASES is the number of rows in R.% SIGMA is a square positive definite matrix with size equal to% the length of MU% Adapted from Mathworks functionm1 n1 = size(mu);c = max(m1 n1);if m1 .* n1 = c error(Mu must be a vector.);endm n = size(sigma);if m = n error(Sigma must be square);endif m = c error(The length of mu must equal the number of rows in sigma.);endT p = chol(sigma);if p = 0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年河南初中数学题库及答案
- 2025年上海电工复审试题及答案
- 2025年考验母女测试题目及答案
- 磁悬浮管道在医疗领域的应用及安全性能分析
- 2025年高炉炉前工职业技能培训考试题(附答案)
- 2025年高考胰岛素试题及答案
- 新材料在家居装修改造中的运用与成本研究
- 2026年建筑工程公司工程招投标管理管理制度
- 2026年建筑工程公司仓储货架安全管理制度
- 2025年6月口腔颌面外科学练习题及答案
- 回转窑球团焙烧工三级安全教育(班组级)考核试卷及答案
- 创新创业计划书(33篇)
- 医疗器械软件注册申报解析
- DB6110T 025-2023 苍术质量控制技术规范
- 2025年上半年民族宗教事务局安全生产工作总结
- 黄金抵押合同范本(2025版)
- 《无人机基础概论》无人机专业全套教学课件
- 物业咨询知识培训课件
- 卡西欧 fx-991CN X 科学计算器使用说明书
- 2025年5月24日福建省税务遴选笔试真题及解析
- 资料管理供应商管理办法
评论
0/150
提交评论