


全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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江西数字文化产业有限公司诚聘数字技术部智能化工程师1人考前自测高频考点模拟试题及答案详解(新)
- 高铁建设2025年对中部地区新型城镇化推动作用研究报告
- 2025年杭州淳安县第二人民医院公开招聘合同制工作人员2人考前自测高频考点模拟试题完整答案详解
- 2025年网络安全解决方案行业上市公司技术突破与市场应用报告
- 2025杭州高新区(滨江)教育局所属事业单位直接考核招聘幼儿园聘用制教师13人考前自测高频考点模拟试题附答案详解(典型题)
- 2025广东中山大学附属第一医院惠亚医院院内合同人员(财务科收费处收费员)招聘1人考前自测高频考点模拟试题及一套答案详解
- 2025年潍坊市寒亭区人民检察院公开招聘工作人员模拟试卷及答案详解(各地真题)
- 2025广东云浮市郁南县林业局招聘生态管护人员2人模拟试卷附答案详解(模拟题)
- 劳务装修包清工劳务合同
- 《计算机视觉-基于OpenCV的图像处理》全套教学课件
- GB/T 18029.1-2024轮椅车第1部分:静态稳定性的测定
- 高考生物选择性必修2生物与环境基础知识填空默写(每天打卡)
- FZT 34002-2016 亚麻印染布行业标准
- 2023年高考物理(山东卷)真题评析及2024备考策略
- 全国身份证号地区对应表
- 主要机械设备表(汇总200种)
- GB/T 18386-2017电动汽车能量消耗率和续驶里程试验方法
- GB/T 17282-1998根据运动粘度确定石油分子量(相对分子质量)的方法
- GB/T 13912-2020金属覆盖层钢铁制件热浸镀锌层技术要求及试验方法
评论
0/150
提交评论