tag 标签: filter经管大学堂:名校名师名课

相关帖子

版块 作者 回复/查看 最后发表
Boosting:为什么可以使用HP过滤器 外文文献专区 nandehutu2022 2022-3-8 0 509 nandehutu2022 2022-3-8 12:38:00
hp filter 多谢 Stata专版 freelinsdu 2009-8-12 5 4411 数学与经济学 2020-12-11 11:23:33
R语言rugarch包内含的filter函数有何作用? R语言论坛 datousang 2013-2-2 17 14383 中国梦丶 2017-12-5 13:11:37
The Kalman Filter and the Hamilton Model attachment 金融学(理论版) scutrick 2009-7-25 1 1874 yuan122600 2016-5-25 16:04:54
[求书]forecasting,structure time series models and kalman filter 计量经济学与统计软件 iiistony 2009-7-21 3 5234 JMing121314 2015-2-4 21:22:07
非常有用的滤波算法:kalman filter 的几篇入门文章 attachment 计量经济学与统计软件 sphinx_xzw 2008-5-22 8 7723 gengyingtao 2013-10-15 10:38:25
关于时间序列卡尔曼滤波的图书求助 文献求助专区 polonking 2013-5-29 0 1440 polonking 2013-5-29 11:23:38
悬赏 A new dynamic hedging model with futures: Kalman filter error correction model - [!reward_solved!] attachment 求助成功区 迷途mitu 2013-2-26 1 1429 jigesi 2013-2-26 10:54:35
Signal Analysis - Wavelets, Filter Banks, Time-Frequency Transforms and Applicat attachment 计量经济学与统计软件 samurai023 2007-10-10 2 3960 fwushi815 2013-1-9 14:15:32
紧急求助:关于kalman filter 中初值问题 EViews专版 ayru 2008-1-9 1 2416 ermutuxia 2012-12-13 09:18:16
[下载]Gauss kalman filter attachment Gauss专版 hanszhu 2005-1-14 24 21241 sunyiboghgl 2012-3-6 23:14:29
hamilton filter (gauss program) (data attached) attach_img Gauss专版 liguo_lin 2005-2-9 8 6975 zhaomn200145 2011-10-2 12:30:02
H-P filter attachment 计量经济学与统计软件 maomaoren 2004-12-19 3 4066 patriciaco 2011-10-1 13:15:02
matlab中的kalman filter MATLAB等数学软件专版 垃圾树 2007-11-29 2 5465 xiaolei001 2010-4-16 15:56:50
hp filter 多谢 统计软件培训班VIP答疑区 freelinsdu 2009-8-12 1 2040 arlionn 2009-8-12 19:36:22
哪位熟悉kalman filter技术 计量经济学与统计软件 sakyu 2005-10-16 9 7325 dengtsy 2009-4-20 21:15:00
[求助]The Kalman Filter in Finance 计量经济学与统计软件 lanzai 2009-4-16 0 2302 lanzai 2009-4-16 21:47:00
[求助]为什么我的STATA用不了H-P FILTER Stata专版 sunnyls 2008-11-11 3 7433 brwei2007 2008-12-20 11:53:00
[原创]filter技术 计量经济学与统计软件 tianjfang 2008-9-2 0 1635 tianjfang 2008-9-2 21:50:00
关于“对kalman filter得到的对数似然函数进行估计“的问题 attachment MATLAB等数学软件专版 juliangong 2008-4-7 1 3849 wenpan9933 2008-4-30 20:41:00

相关日志

分享 python 特殊语法:filter、map 、reduce、lambda
xulimei1986 2015-6-25 17:38
Python特殊语法:filter、map、reduce、lambda Python内置了一些非常有趣但非常有用的函数,充分体现了Python的语言魅力! filter(function, sequence) :对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)返回: def f(x): return x % 2 != 0 and x % 3 != 0 filter(f, range(2, 25)) def f(x): return x != 'a' filter(f, "abcdef") 'bcdef' map(function, sequence) :对sequence中的item依次执行function(item),见执行结果组成一个List返回: def cube(x): return x*x*x map(cube, range(1, 11)) def cube(x) : return x + x ... map(cube , "abcde") 另外map也支持多个sequence,这就要求function也支持相应数量的参数输入: def add(x, y): return x+y map(add, range(8), range(8)) reduce(function, sequence, starting_value) :对sequence中的item顺序迭代调用function,如果有starting_value,还可以作为初始值调用,例如可以用来对List求和: def add(x,y): return x + y reduce(add, range(1, 11)) 55 (注:1+2+3+4+5+6+7+8+9+10) reduce(add, range(1, 11), 20) 75 (注:1+2+3+4+5+6+7+8+9+10+20) lambda :这是Python支持一种有趣的语法,它允许你快速定义单行的最小函数,类似与C语言中的宏,这些叫做lambda的函数,是从LISP借用来的,可以用在任何需要函数的地方: g = lambda x: x * 2 g(3) 6 (lambda x: x * 2)(3) 6 我们也可以 把filter map reduce 和lambda结合起来 用,函数就可以简单的写成一行。 例如 kmpathes = filter(lambda kmpath: kmpath, map(lambda kmpath: string.strip(kmpath), string.split(l, ':'))) 看起来麻烦,其实就像用语言来描述问题一样,非常优雅。 对 l 中的所有元素以':'做分割,得出一个列表。对这个列表的每一个元素做字符串strip,形成一个列表。对这个列表的每一个元素做直接返回操作(这个地方可以加上过滤条件限制),最终获得一个字符串被':'分割的列表,列表中的每一个字符串都做了strip,并可以对特殊字符串过滤。 http://hi.baidu.com/black/item/307001d18715fc322a35c747 --------------------------------------------------------------- lambda表达式 返回一个函数对象 例子: func = lambda x,y:x+y func相当于下面这个函数 def func(x,y): return x+y 注意def是语句而lambda是表达式 下面这种情况下就只能用lambda而不能用def map,reduce,filter中的function都可以用lambda表达式来生成! map(function,sequence) 把sequence中的值当参数逐个传给function,返回一个包含函数执行结果的list。 如果function有两个参数,即map(function,sequence1,sequence2)。 例子: 求1*1,2*2,3*3,4*4 map(lambda x:x*x,range(1,5)) 返回值是 reduce(function,sequence) function接收的参数个数只能为2 先把sequence中第一个值和第二个值当参数传给function,再把function的返回值和第三个值当参数传给 function,然后只返回一个结果。 例子: 求1到10的累加 reduce(lambda x,y:x+y,range(1,11)) 返回值是55。 filter(function,sequence) function的返回值只能是True或False 把sequence中的值逐个当参数传给function,如果function(x)的返回值是True,就把x加到filter的返回值里面。一般来说filter的返回值是list,特殊情况如sequence是string或tuple,则返回值按照sequence的类型。 例子: 找出1到10之间的奇数 filter(lambda x:x%2!=0,range(1,11)) 返回值 如果sequence是一个string filter(lambda x:len(x)!=0,'hello')返回'hello' filter(lambda x:len(x)==0,'hello')返回''
0 个评论
分享 转载:利用MATLAB对kalman filter的实现
oceanlover 2013-7-22 11:01
% KALMANF - updates a system state vector estimate based upon an xmlnamespace prefix ="o" ns ="urn:schemas-microsoft-com:office:office" / % observation, using a discrete Kalman filter. % % Version 1.0, June 30, 2004 % % This tutorial function was written by Michael C. Kleder % % INTRODUCTION % % Many people have heard of Kalman filtering, but regard the topic % as mysterious. While it's true that deriving the Kalman filter and % proving mathematically that it is "optimal" under a variety of % circumstances can be rather intense, applying the filter to % a basic linear system is actually very easy. This Matlab file is % intended to demonstrate that. % % An excellent paper on Kalman filtering at the introductory level, % without detailing the mathematical underpinnings, is: % "An Introduction to the Kalman Filter" % Greg Welch and Gary Bishop, University of North Carolina % http://www.cs.unc.edu/~welch/kalman/kalmanIntro.html % % PURPOSE: % % The purpose of each iteration of a Kalman filter is to update % the estimate of the state vector of a system (and the covariance % of that vector) based upon the information in a new observation. % The version of the Kalman filter in this function assumes that % observations occur at fixed discrete time intervals. Also, this % function assumes a linear system, meaning that the time evolution % of the state vector can be calculated by means of a state transition % matrix. % % USAGE: % % s = kalmanf(s) % % "s" is a "system" struct containing various fields used as input % and output. The state estimate "x" and its covariance "P" are % updated by the function. The other fields describe the mechanics % of the system and are left unchanged. A calling routine may change % these other fields as needed if state dynamics are time-dependent; % otherwise, they should be left alone after initial values are set. % The exceptions are the observation vectro "z" and the input control % (or forcing function) "u." If there is an input function, then % "u" should be set to some nonzero value by the calling routine. % % SYSTEM DYNAMICS: % % The system evolves according to the following difference equations, % where quantities are further defined below: % % x = Ax + Bu + w meaning the state vector x evolves during one time % step by premultiplying by the "state transition % matrix" A. There is optionally (if nonzero) an input % vector u which affects the state linearly, and this % linear effect on the state is represented by % premultiplying by the "input matrix" B. There is also % gaussian process noise w. % z = Hx + v meaning the observation vector z is a linear function % of the state vector, and this linear relationship is % represented by premultiplication by "observation % matrix" H. There is also gaussian measurement % noise v. % where w ~ N(0,Q) meaning w is gaussian noise with covariance Q % v ~ N(0,R) meaning v is gaussian noise with covariance R % % VECTOR VARIABLES: % % s.x = state vector estimate. In the input struct, this is the % "a priori" state estimate (prior to the addition of the % information from the new observation). In the output struct, % this is the "a posteriori" state estimate (after the new % measurement information is included). % s.z = observation vector % s.u = input control vector, optional (defaults to zero). % % MATRIX VARIABLES: % % s.A = state transition matrix (defaults to identity). % s.P = covariance of the state vector estimate. In the input struct, % this is "a priori," and in the output it is "a posteriori." % (required unless autoinitializing as described below). % s.B = input matrix, optional (defaults to zero). % s.Q = process noise covariance (defaults to zero). % s.R = measurement noise covariance (required). % s.H = observation matrix (defaults to identity). % % NORMAL OPERATION: % % (1) define all state definition fields: A,B,H,Q,R % (2) define intial state estimate: x,P % (3) obtain observation and control vectors: z,u % (4) call the filter to obtain updated state estimate: x,P % (5) return to step (3) and repeat % % INITIALIZATION: % % If an initial state estimate is unavailable, it can be obtained % from the first observation as follows, provided that there are the % same number of observable variables as state variables. This "auto- % intitialization" is done automatically if s.x is absent or NaN. % % x = inv(H)*z % P = inv(H)*R*inv(H') % % This is mathematically equivalent to setting the initial state estimate % covariance to infinity. % % SCALAR EXAMPLE (Automobile Voltimeter): % % % Define the system as a constant of 12 volts: % clear s % s.x = 12; % s.A = 1; % % Define a process noise (stdev) of 2 volts as the car operates: % s.Q = 2^2; % variance, hence stdev^2 % % Define the voltimeter to measure the voltage itself: % s.H = 1; % % Define a measurement error (stdev) of 2 volts: % s.R = 2^2; % variance, hence stdev^2 % % Do not define any system input (control) functions: % s.B = 0; % s.u = 0; % % Do not specify an initial state: % s.x = nan; % s.P = nan; % % Generate random voltages and watch the filter operate. % tru= ,'r.'); % % plot a-posteriori state estimates: % hk=plot( ,'b-'); % ht=plot(tru,'g-'); % legend( ,'observations','Kalman output','true voltage',0) % title('Automobile Voltimeter Example') % hold off function s = kalmanf(s) % set defaults for absent fields: if ~isfield(s,'x'); s.x=nan*z; end if ~isfield(s,'P'); s.P=nan; end if ~isfield(s,'z'); error('Observation vector missing'); end if ~isfield(s,'u'); s.u=0; end if ~isfield(s,'A'); s.A=eye(length(x)); end if ~isfield(s,'B'); s.B=0; end if ~isfield(s,'Q'); s.Q=zeros(length(x)); end if ~isfield(s,'R'); error('Observation covariance missing'); end if ~isfield(s,'H'); s.H=eye(length(x)); end if isnan(s.x) % initialize state estimate from first observation if diff(size(s.H)) error('Observation matrix must be square and invertible for state autointialization.'); end s.x = inv(s.H)*s.z; s.P = inv(s.H)*s.R*inv(s.H'); else % This is the code which implements the discrete Kalman filter: % Prediction for state vector and covariance: s.x = s.A*s.x + s.B*s.u; s.P = s.A * s.P * s.A' + s.Q; % Compute Kalman gain factor: K = s.P*s.H'*inv(s.H*s.P*s.H'+s.R); % Correction based on observation: s.x = s.x + K*(s.z-s.H*s.x); s.P = s.P - K*s.H*s.P; % Note that the desired result, which is an improved estimate % of the sytem state vector x and its covariance P, was obtained % in only five lines of code, once the system was defined. (That's % how simple the discrete Kalman filter is to use.) Later, % we'll discuss how to deal with nonlinear systems. end return
15 次阅读|0 个评论
GMT+8, 2025-12-5 16:02