% This program is used to explain how PCA works and the idea behind the
% method. This example is given in the ISA book (Chapter 8, simple example)
% The process is composed of a valve a thermometer and a fermenter. The
% valve is used to control the flow rate of cooling water. The thermometer
% is used to measure the temperature of the fermenter.
% The steady state of the system is: valve=10% max. Temperature T=25 D.
% YANG ZHANG Email: yz@che.utexas.edu
% 2006-April, UTexas-Austin
clear all
% Give valve set points and fermenter temperature.
% Valve=10+rand(1,10)-0.5; % ten value of Valve around mean.
% Temp=25-(Valve-10)+(rand(1,10)-0.5)*0.5; % 10 value of Temp: T=2.5*valve + noise
Temp = [2.5000e+001 2.5000e+001 2.5000e+001 2.5300e+001 2.5200e+001 2.5200e+001 2.4800e+001 2.4700e+001 2.5100e+001 2.4700e+001];
Valve = [1.0100e+001 9.9000e+000 1.0000e+001 9.8000e+000 9.9000e+000 9.8000e+000 1.0100e+001 1.0300e+001 1.0000e+001 1.0100e+001];
% Define database
x=[Valve;Temp]';
figure(1)
plot(x(:,1),x(:,2),'ko')
xlabel('Valve Position (%)')
ylabel('Fermenter Temperature (C)')
% Calculate the covariance of dataset x (relationship between Valve and
% Temperature)
covariance=cov(x);
% Singular Value Decomposition x=T*E*P
% E is the eignvalue of x; U is orthnormal; V=U'.
%[U E V]=svd(covariance);
%U=U'; V=V';
[U E] = eig(covariance);
E = diag([E(2,2),E(1,1)]); % arrange the Eignvalue in a decending order
U = [U(:,2),U(:,1)]; % arrange the Eignvector to make it compatable with Eignvalue.
% Mean center the raw data
Valvebar=x(:,1)-mean(x(:,1));
Tempbar=x(:,2)-mean(x(:,2));
xbar=[Valvebar,Tempbar];
% Principal axis rotation of the covariance matrix.
z=U'*xbar';
z=z';
%covz is the covariance matrix of principal components which is equal to E
%matrix. The variance of transformed variable (z1 & z2) will have variance
%0.2283 and 0.0123 respectively.
covz=U'*covariance*U;
% The first column of U factor is - and + with nearly equal value which
% means the first principal component is related to variability which both
% measurements have difference. The second column is both positive which
% means the 2nd PC is concentrate on the varaiability of the common between
% the two.
% scaling of PCS.
for i=1:2
Vs(:,i)=sqrt(E(i,i))*U(:,i);
Ws(:,i)=U(:,i)/sqrt(E(i,i));
end
% after rescale: Vs'*Vs=E; V'*COV*Vs=E^2; Ws'*Ws=inv(E); Ws'*COV*Ws=I
y=Ws'*xbar';
%define T2
T2=diag(y'*y);
% find the control limit of T2
p=2; %PC number
n=10; % sample number
T2Upper=p*(n-1)/(n-p)*finv(0.95,p,n-p);
% draw the T2 control charts
figure(2)
plot(T2,'ko')
hold on
plot(T2Upper*ones(1,13),'k')
xlabel('Sample Number')
ylabel('T2 Score')
hold off
% Draw the control ellipse
% s1^2*s2^2/(s1^2*s2^2-s12^2)*[(x1-x1mean)^2/s1^2+(x2-x2mean)^2/s2^2-2*s12(
% x1-x1mean)(x2-x2mean)/s1^2/s2^2]=T2^2(upper control limit)
% S=covariance;
% a=S(1)*S(4)/(S(1)*S(4)-S(2)^2);
% b=xbar(:,1).^2/S(1)+xbar(:,2).^2/S(4)-2*S(2)*xbar(:,1).*xbar(:,2)./S(1)/S(4);
% error detection
% two new points is added to be detected which are [10.1,25.2];[9.9;24];
% plot two values with the original 10.
Valve2=[10.2,9.9];Temp2=[25.1,25.5];
figure(1)
hold on
plot(Valve2,Temp2,'k*')
hold off
% plot the control charts for valve and temperature separately.
figure(3)
hold on
plot(1:10,Valve,'ko')
plot(11:12,Valve2,'k*')
plot(0:13, mean(Valve)*ones(1,14),'k')
plot(0:13, (mean(Valve)-std(Valve)*2)*ones(1,14),'k')
plot(0:13, (mean(Valve)+std(Valve)*2)*ones(1,14),'k')
xlabel('Sample Number')
ylabel('Valve Position (%)')
hold off
figure(4)
hold on
plot(1:10,Temp,'ko')
plot(11:12,Temp2,'k*')
plot(0:13, mean(Temp)*ones(1,14),'k')
plot(0:13, (mean(Temp)+std(Temp)*2)*ones(1,14),'k')
plot(0:13, (mean(Temp)-std(Temp)*2)*ones(1,14),'k')
xlabel('Sample Number')
ylabel('Temperature (C)')
hold off
% transform new observations to PC axis
y2=Ws'*([Valve2-mean(Valve);Temp2-mean(Temp)]);
% plot the control charts for principal components
figure(5)
hold on
plot(1:10,y(1,:),'ko')
plot(11:12,y2(1,:),'k*')
plot(0:13, mean(y(1,:))*ones(1,14),'k')
plot(0:13, -2*ones(1,14),'k')
plot(0:13, 2*ones(1,14),'k')
xlabel ('Sample Number')
ylabel ('Principal Component 1')
hold off
figure(6)
hold on
plot(1:10,y(2,:),'ko')
plot(11:12,y2(2,:),'k*')
plot(0:13,mean(y(2,:))*ones(1,14),'k')
plot(0:13, -2*ones(1,14),'k')
plot(0:13, 2*ones(1,14),'k')
xlabel ('Sample Number')
ylabel ('Principal Component 2')
hold off
% plot the T2 chart for the two new points
figure(2)
T22=diag(y2'*y2);
hold on
plot([11,12],T22,'k*')
hold off
% draw the control ellipse
ra = sqrt(T2Upper*E(1,1));
rb = sqrt(T2Upper*E(2,2));
V=[sqrt(E(1,1))*U(:,1),sqrt(E(2,2))*-U(:,2)];
k1 = V(2,1)/V(1,1);
k2 = V(2,2)/V(1,2);
ang = atan(k1); %atan(k1);
x0 = mean(x(:,1));
y0 = mean(x(:,2));
% i = 9.5:0.01:10.5;
% s = 9.72:0.01:10.3;
% j = k1*i + 42.6303;
% l = k2*s + 19.3279;
figure (7)
h=ellipse(ra,rb,ang,x0,y0,'k',1000);
hold on
plot(x(:,1),x(:,2),'ko')
plot(Valve2, Temp2,'k*')
% plot(i,j)
% plot(s,l)
xlabel ('Valve Position')
ylabel ('Temperature')
hold off
相关推荐
主成分分析(PCA)及其可视化——matlab
X= csvread('文件路径',1,0); %读取数据文件,第一行不读取 T = readtable('文件路径');%读取文件中的所有数据 举例: data = [1,-0.2,0.3,0.8,-0.5 -0.2,1,0.6,-0.7,0.2 0.3,0.6,1,0.5,-0.3 0.8,-0.7,0.5,1,0.7 -0.5,0.2,-0.3,0.7,1] 运行结果: mapping.mean = mean(data, 1) %..
This program is used to explain how PCA works and the idea behind the method.
% This program is used to explain how PCA works and the idea behind the% method. This example is given in the ISA book (Chapter 8, simple example)% The process is composed of a valve a thermomete
主成分分析(PCA)——matlab程序及函数详解
参考来源: http://www.cnblogs.com/Hand-Head/articles/5156435.html http://www.matlabsky.com/thread-11751-1-1.html matlab帮助文档 例子: 它使用了衡量美国329个城市生活质量的9个指标:气候、住房、健康、犯罪率、交通、教育、艺术、娱乐和经济。 对于各指标,越高表示越好,如
第一个racket程序:获得字符串中的数字
#! /usr/bin/env racket #lang racket #| NAME: getModelNumber.rkt This program is used to get model number based on the input model file name. USAGE: ./getModelNumber.rkt modelfi
PCA:matlab主成份分析
通常对于高维数据需要进行降维,matlab中有pca进行数据分析,进行主成份分析:principal component analysis。
主成分分析(PCA)(matlab版本)
一、基础知识 假设两个样本X、Y,它们的均值分别为X‾\overline{X}X、Y‾\overline{Y}Y,样本X和样本Y的协方差为: Cov(X,Y)=∑i=1n(Xi−X‾)(Yi−Y‾)n−1 Cov(X,Y) = \frac{\sum_{i=1}^{n}(X_i-\overline{X})(Y_i-\overline{Y})}{n-1} Cov(X,Y)=n−1∑i=1n(Xi...
Linux下C 文件读写程序
直接上程序: //ddim.c #include /* *This program is used to read some data from the data file *and then to process. */ int main(void) { int scores[5][3];//score array float average; flo
基于Matlab实现PCA算法(附上多个案例源码)
基于Matlab实现PCA算法(附上多个案例源码)
The file is absent or does not have execute permission This file is needed to run this program
需要将另一个服务器上的tomcat复制到本服务器上。执行启动命令时报这个错误。意思就是:该文件不存在或没有执行权限运行该程序需要该文件。显然不可能是不存在的。那就是没有执行权限了。
Matlab中PCA主成分分析的实现步骤详解
在数学中,对于一个(m \times m)的方阵(A),如果存在非零向量(v)和标量(\lambda),满足以下等式:那么,(v)被称为(A)的特征向量,(\lambda)被称为相应的特征值。特征值的大小指示了特征向量所代表的方向在变换矩阵(A)作用下伸缩的倍数。在PCA的上下文中,特征向量指示了数据变异性最大的方向,而特征值的大小则表明了数据在这个方向上的方差大小。在机器学习领域,PCA经常被用作数据预处理的手段之一。
comfyui从入门到精通二:提示词规则详解
《AI绘画提示词使用全指南》摘要: 本文系统解析AI绘画提示词的核心规则与实用技巧。关键点包括:1) 空格与下划线的本质差异,webui会自动转换但comfyui保留原格式;2) 数字与单词表达(如1girl/one girl)会导致风格变化;3) 三种权重控制方式(数值标注、括号嵌套、位置效应),其中数值标注最直观有效;4) 位置衰减公式揭示提示词排序对效果的影响权重。同时指出当前AI绘画仍存在角色一致性等更复杂的技术瓶颈。全文通过多组对比实验,为创作者提供从基础语法到高阶控制的完整解决方案。
主成分分析法(PCA)及MATLAB实现
主成分分析法(PCA)及MATLAB程序实现
安装破解IAR EWARM 8.2,提供注册机
IAR Embedded Workbench for ARM(IAR for ARM)是一款微处理器的集成开发环境软件,该集成开发环境中包含了IAR的C/C++编译器、 汇编工具、链接器、库管理器、文本编辑器、工程管理器和C-SPY调试器,支持ARM,AVR,MSP430等芯片。 一、安装 双击运行安装程序,点击Install IAR Embedded Workbench for ARM...
主成分分析(PCA)算法模型实现及分析(MATLAB实现)PCA降维
主成分分析(PCA)是一种能够极大提升无监督特征学习速度的数据降维算法。主成分分析(Principal Component Analysis,PCA)的方法,可以将具有多个观测变量的高维数据集降维,使人们可以从事物之间错综复杂的关系中找出一些主要的方面,从而能更加有效地利用大量统计数据进行定量分析,并可以更好地 由于得到协方差矩阵的特征值特征向量有两种方法:特征值分解协方差矩阵、奇异值分解协方差矩阵,所以PCA算法有两种实现方法:基于特征值分解协方差矩阵实现PCA算法、基于SVD分解协方差矩阵实现PCA算法
wps js宏获取工作簿、工作表、单元格的值、链接转图片、单元格区域数据转二维数组、保存工作簿的常用Excel操作
wps js宏入门看这里,我写了常用的js操作Excel的方法:获取工作簿对象、获取工作表对象、获取单元格的值、链接转图片、生成条形码图片、单元格区域数据转二维数组方法、保存工作簿、弹出输入框、YesNo选择框,助你从VBA转战JS。
TensorFlow GPU版本安装步骤-Windows系统
本文由在Windows下安装TensorFlow GPU版本教程-优快云等整理得到。 目录 1、确认显卡是否支持CUDA 1.1 查看显卡信息 打开“设备管理器”,查看显卡信息,如下图所示: 由上图知,本电脑的显卡为NVIDIA Quadro P400. 1.2 查看支持CUDA的显卡 网址:https://developer.nvidia.com/cuda-gpus 经查询可知,该显卡支持CUDA,如下图所示: 2、安装CUDA 2.1 下载CUDA 网址:https://developer.nvi
PCA的Matlab实现与分析
PCA(Principal Component Analysis)在机器学习领域中,是很常见的一种降维的方法。 PCA的主要思想:将原始高维数据集中的点,映射到低维的超平面中,。
第一讲:halcon模板匹配捆绑测量矩形检测芯片针脚
使用halcon模板匹配捆绑测量矩形,检测位置发生变换的芯片针脚缺陷。
PCA原理分析和Matlab实现方法(三)
PCA主成分分析原理分析和Matlab实现方法(三) PCA算法主要用于降维,就是将样本数据从高维空间投影到低维空间中,并尽可能的在低维空间中表示原始数据。PCA的几何意义可简单解释为: 0维-PCA:将所有样本信息都投影到一个点,因此无法反应样本之间的差异;要想用一个点来尽可能的表示所有样本数据,则这个点必定是样本的均值。 1维-PCA:相当于将所有样本信息向样本均值的直线投影; 2维-PCA:将样本的平面分布看作椭圆形分布,求出椭圆形的长短轴方向,然后将样本信息投
汽车ECU诊断刷写和OTA升级中的验签和校验
汽车ECU诊断刷写和OTA升级中的验签和校验
1、基于改进3D卷积神经网络的阿尔茨海默病分类
本文提出了一种基于改进3D卷积神经网络的阿尔茨海默病(AD)分类方法,利用3D CNN对预处理后的T1加权MRI数据进行空间特征提取,并在VGG网络结构中引入类似ResNet的跳跃连接以缓解模型退化和过拟合问题。实验基于ADNI数据集,包含AD、MCI和NC三类样本,结果表明改进后的3D VGG模型在AD/NC、MCI/NC及多分类任务中均取得了优异性能,尤其在AD/MCI/NC分类中准确率达到98.50%,优于现有典型3D深度学习方法。研究验证了3D CNN在脑部疾病诊断中的有效性,并为AD的早期识别提供
matlab 数据pca应用,Matlab – 多维数据的PCA分析与重构
这是一个快速的演练。 首先,我们创build一个隐藏variables(或“因素”)的matrix。 它有100个观测值,有两个独立的因素。>> factors = randn(100, 2);现在创build一个加载matrix。 这将把隐藏的variables映射到你观察到的variables上。 说你观察到的variables有四个特征。 那么你的加载matrix需要是4 x 2...
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
MATLAB实现主成分分析(PCA)
MATLAB实现主成分分析(PCA) 去发现同类优质开源项目:https://gitcode.com/ 资源描述 本资源文件提供了一个基于MATLAB实现的主成分分析(PCA)降维算法。PCA是一种常用的数据降维技术,通过将高维数据投影到低维空间,可以在最小化信息损失的前提下实现数据的压缩。本资源内附完整的MATLAB代码,方便用户直接使用或进行进一步的修改和优化。 功能特点 数据降维:通过PC...
ET2012新版免狗免安装绿色软件
ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,
华为的C语言编程规范.pdf
华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。
PCA主成分分析的MATLAB和Eigen实现以及应用
PCA实现和应用 PCA理论 计算协方差矩阵 PCA过程 MATLAB实现 求协方差矩阵 PCA过程 Eigen实现 实现效果图 目前在项目中需要对模型的位置进行矫正,想到了使用主成分分析,提取主方向,将模型方向进行变换得到正确的方向。以下对PCA过程首先在matlab中进行实现,然后在C++矩阵库Eigen中实现,总体较为简单。 PCA实现和应用 PCA理论...
怀旧版电脑GBC模拟器
再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。
MATLAB实例:PCA(主成成分分析)详解
发现一篇非常好的pca学习文章, 作者:凯鲁嘎吉 - 博客园 MATLAB实例:PCA(主成成分分析)详解 - 凯鲁嘎吉 - 博客园 (cnblogs.com) 1. 主成成分分析 2. MATLAB解释 详细信息请看:Principal component analysis of raw data - mathworks [coeff,score,latent,tsquared,explained,mu] =pca(X) coeff=pca(X)returns the princip...
3万+



被折叠的 条评论
为什么被折叠?



