使用Github上Eigen库计算自适应信号处理中维纳滤波算法

2023-05-16

LMS算法是自适应信号处理中最常见的算法之一,Least Mean Square最小均方算法是自适应系统最常见的算法,利用Eigen库的线性代数便利计算,得到最小均方误差MSE,程序如下

/*The example of LMS algorithm for Adaptive Filtering
 *Least mean squares (LMS) algorithms are a class of adaptive filter 
 *used to mimic a desired filter by finding the filter coefficients 
 *that relate to producing the least mean square of the error signal 
 *(difference between the desired and the actual signal). It is a 
 *stochastic gradient descent method in that the filter is only 
 *adapted based on the error at the current time.
 *The basic idea behind LMS filter is to approach the optimum filter 
 *weights {\displaystyle (R^{-1}P)} (R^{-1}P), by updating the filter 
 *weights in a manner to converge to the optimum filter weight. This 
 *is based on the gradient descent algorithm. The algorithm starts by 
 *assuming small weights (zero in most cases) and, at each step, by 
 *finding the gradient of the mean square error, the weights are updated. 
 *That is, if the MSE-gradient is positive, it implies, the error would 
 *keep increasing positively, if the same weight is used for further 
 *iterations, which means we need to reduce the weights. In the same way, 
 *if the gradient is negative, we need to increase the weights.
 */

#include <iostream>
#include <Eigen/Dense>
#include <algorithm>
#include <cmath>
using namespace std;
using namespace Eigen;
const int L=8;         //system parameter
const double mu=0.14;  //step size mu

/*Use FIR One-calss filtering system get the answer signal d*/
VectorXd filter(VectorXd f,int avg,VectorXd x,int sampleN){
	VectorXd d=VectorXd::Zero(sampleN);
	d[0]=f[0]*x[0];
	for(int i=1;i<sampleN;++i){
		for(int j=0;j<=i;++j){
			int fj=(j>=8?7:j);
			d[i]=d[i]+f[fj]*x[i-j];
		}
		d[i]-=d[i-1];
		d[i]/=avg;
	}
	return d;
}

/*Get the input signal from the random signal U*/
VectorXd getFromInput(VectorXd u,int j){
	VectorXd x=VectorXd::Zero(L);
	for(int i=0;i<L;++i){
		x[i]=u[j-i];
	}
	return x;
}

int main()
{
	int i=0,j=0,k=0; //For loop
	int K = 10;      //independent run circle
	int N = 1000;    //sample node
	long int sum=0;
	VectorXd MSE=VectorXd::Zero(N); //mean least square
	VectorXd unw=VectorXd::Random(L);
	VectorXd n=VectorXd::Zero(L); 
	
	for(k=0;k<K;++k){
		VectorXd w=VectorXd::Zero(L);
		VectorXd u=VectorXd::Random(N);
		VectorXd d=filter(unw,1,u,N);
		for(i=L;i<N;++i){
			VectorXd x=getFromInput(u,i);
			double e=d[i]-x.transpose()*w;
			MSE[i]=MSE[i]+pow(e,2.0);
		}
	}
	for(k=0;k<N;++k){
		MSE[k]=MSE[k]/K;
	}
	for(int i=0;i<N;++i){
		sum=sum+MSE[i]/N;
	}
}

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用Github上Eigen库计算自适应信号处理中维纳滤波算法 的相关文章

  • 正则验证匹配中文姓名全部源字符串

    这个是验证匹配中文姓名的全部源串 xff0c 在网上找了很久 xff0c 大都是验证匹配含有中文 xff0c 就在网上某人提供的正则的基础上修改成了验证所填姓名的每个字符 xff0c 只有都匹配才能验证通过 该正则为 xff1a u4e00
  • 域名,网站名和URL区别

    要写一个正则表达式来验证输入域名是否有正确 xff0c 一直以为例如http www baidu com类似于这种才是网站域名 xff0c 经过百度才发现自己的认知是错误的 以下转载于百度经验 xff1a http jingyan baid
  • 23种设计模式(1)-Facade设计模式

    前记 曾经我遇见的一个需求是这样的 xff0c 接口A有个方法void methodA xff0c 类B需要实现接口A的methodA 方法 xff0c 并且在类B中需要把methodA 方法内部处理逻辑获得的结果利用C类实例的某个方法进行
  • Linux CentOS 7安装GNOME图形界面并设置默认启动方式

    为hadoop集群做准备 xff0c 没有多台电脑 xff0c 也只能委屈我这渣渣电脑了 在我的物理机上安装虚拟机 xff0c 再在虚拟机里面虚拟出两台电脑 xff0c 安装两个linux操作系统 1 xff0c 电脑太渣 xff0c 安装
  • dubbo学习资源

    简介 xff1a 项目有使用dubbo xff0c 以此需要学习一下 xff0c 搜集学习资源 一 xff0c 博客资源 1 xff0c dubbo学习 2 xff0c dubbo配置
  • 使用CSS3的box-sizing属性解决div宽高被内边距撑开的问题

    有时我们会给页面的元素 xff08 比如div xff09 设置个固定的高度或宽度 但如果给这个div又设置了内边距或者边框的话 xff0c 那么这个div就会被撑大 也就是其实际的尺寸变成了 xff1a 设置的宽高尺寸 43 内边距 43
  • 博客搬家:https://blog.csdn.net/u012995888

    本博客文章有些乱 xff0c 多有转载 xff0c 现在主要在另一CSDN账号更新原创文章 xff0c 点击查看博客主页 另外 xff0c 本博客后续可能会重新整理栏目 xff0c 更新高质量文章 xff0c 谢谢关注 xff01
  • C++ 常用设计模式(学习笔记)

    1 工厂模式 工厂模式 xff1a 简单工厂模式 工厂方法模式 抽象工厂模式 1 简单工厂模式 xff1a 主要特点是需要在工厂类中做判断 xff0c 从而创造相应的产品 xff0c 当增加新产品时 xff0c 需要修改工厂类 typede
  • 通过更新显卡驱动和内核,解决linux启动时在starting atd: [ok]停止的问题

    说得有些复杂 xff0c 你可以不用理会这些 xff0c 直接执行我罗列的那几个命令就行了 方法一 xff1a 网上有说In some cases the new install Gforce Drivers do not supporte
  • Streamedian/html5_rtsp_player接海康视频遇到的坑

    Streamedian是一套能够让浏览器免插件播放RTSP的项目 安装了其官方的server端后有一个demo 如图 xff0c 在输入处输入红框格式的RTSP地址 xff0c 如官方的demo地址 xff1a rtsp 184 72 23
  • 文档与笔记利器 reStructuredText 和 Sphinx

    原文http qixinglu com archives note tools restructuredtext sphinx 文档与笔记利器 reStructuredText 和 Sphinx 28六 2011 作者 投稿 转载 本文采用
  • 关于递归的问题:无限递归

    当你在写递归的时候 xff0c 可能会出现运行不出结果来 xff0c 此时你应该试着看看会不会出现无限递归的问题 xff0c 如果有的话 xff0c 你可以在前面增加一个判断语句 xff0c 满足条件进入执行相关操作与递归 xff0c 但在
  • 无人机路径规划1:orbslam2+VIO

    无人机路径规划1 xff1a orbslam2 43 VIO 安装XTDRONE平台 https www yuque com xtdrone manual cn basic config ros基本操作 ros中文版教程 http wiki
  • 无人机路径规划2 vins_fusion + rtab_map学习

    导航过程中的tf Map gt odom gt base footprint gt base link odom里程计 odom tf base footprint gt base link xff1a robot state publis
  • 无人机路径规划3:ego-planner三维运动规划实现

    XTDrone实现ego planner三维运动规划 编译ego palnner span class token function cp span r XTDrone motion planning 3d ego planner catk
  • XTDRONE:ego_planner三维运动规划

    ros常用消息类型 xff1a https blog csdn net xhtchina article details 119707553 iris 0 ego transfer话题在 XTDrone motion planning 3d
  • 无人机运动规划4:ego-swarm无人机群运动规划

    配置 启动python脚本生成多机launch文件 span class token builtin class name cd span XTDrone coordination launch generator python3 gene
  • Promethues: swarm_control解读

    标签可以对节点分组 xff0c 具有 ns 属性 xff0c 可以让节点归属某个命名空间 lt group ns 61 34 iris 0 34 gt lt group ns 61 span class token string 34 ir
  • 从零开始的嵌入式系统开发学习Day9(数据结构)

    目录 一 单链表 1 1 概念 1 2 单链表的操作 1 2 1 定义结点结构体 1 2 2 创建一个空的单链表 1 2 3 头插法插入数据 1 2 4 遍历单链表 1 2 5 尾插法插入数据 1 2 6 判断单链表是否为空 1 2 7 头
  • ubuntu ‘filesystem root‘空间不足解决办法

    1 查看磁盘空间占用情况 span class token function df span h 显示如下 xff0c 根目录已经占用98 的空间 2 空间扩容 安装gparted span class token function sud

随机推荐