亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hmc.m

?? 有關kalman濾波及其一些變形濾波算法
?? M
字號:
function [samples, energies, diagn] = hmc(f, x, options, gradf, varargin)
%HMC	Hybrid Monte Carlo sampling.
%
%	Description
%	SAMPLES = HMC(F, X, OPTIONS, GRADF) uses a  hybrid Monte Carlo
%	algorithm to sample from the distribution P ~ EXP(-F), where F is the
%	first argument to HMC. The Markov chain starts at the point X, and
%	the function GRADF is the gradient of the `energy' function F.
%
%	HMC(F, X, OPTIONS, GRADF, P1, P2, ...) allows additional arguments to
%	be passed to F() and GRADF().
%
%	[SAMPLES, ENERGIES, DIAGN] = HMC(F, X, OPTIONS, GRADF) also returns a
%	log of the energy values (i.e. negative log probabilities) for the
%	samples in ENERGIES and DIAGN, a structure containing diagnostic
%	information (position, momentum and acceptance threshold) for each
%	step of the chain in DIAGN.POS, DIAGN.MOM and DIAGN.ACC respectively.
%	All candidate states (including rejected ones) are stored in
%	DIAGN.POS.
%
%	[SAMPLES, ENERGIES, DIAGN] = HMC(F, X, OPTIONS, GRADF) also returns
%	the ENERGIES (i.e. negative log probabilities) corresponding to the
%	samples.  The DIAGN structure contains three fields:
%
%	POS the position vectors of the dynamic process.
%
%	MOM the momentum vectors of the dynamic process.
%
%	ACC the acceptance thresholds.
%
%	S = HMC('STATE') returns a state structure that contains the state of
%	the two random number generators RAND and RANDN and the momentum of
%	the dynamic process.  These are contained in fields  randstate,
%	randnstate and mom respectively.  The momentum state is only used for
%	a persistent momentum update.
%
%	HMC('STATE', S) resets the state to S.  If S is an integer, then it
%	is passed to RAND and RANDN and the momentum variable is randomised.
%	If S is a structure returned by HMC('STATE') then it resets the
%	generator to exactly the same state.
%
%	The optional parameters in the OPTIONS vector have the following
%	interpretations.
%
%	OPTIONS(1) is set to 1 to display the energy values and rejection
%	threshold at each step of the Markov chain. If the value is 2, then
%	the position vectors at each step are also displayed.
%
%	OPTIONS(5) is set to 1 if momentum persistence is used; default 0,
%	for complete replacement of momentum variables.
%
%	OPTIONS(7) defines the trajectory length (i.e. the number of leap-
%	frog steps at each iteration).  Minimum value 1.
%
%	OPTIONS(9) is set to 1 to check the user defined gradient function.
%
%	OPTIONS(14) is the number of samples retained from the Markov chain;
%	default 100.
%
%	OPTIONS(15) is the number of samples omitted from the start of the
%	chain; default 0.
%
%	OPTIONS(17) defines the momentum used when a persistent update of
%	(leap-frog) momentum is used.  This is bounded to the interval [0,
%	1).
%
%	OPTIONS(18) is the step size used in leap-frogs; default 1/trajectory
%	length.
%
%	See also
%	METROP
%

%	Copyright (c) Ian T Nabney (1996-2001)

% Global variable to store state of momentum variables: set by set_state
% Used to initialise variable if set
global HMC_MOM
if nargin <= 2
  if ~strcmp(f, 'state')
    error('Unknown argument to hmc');
  end
  switch nargin
    case 1
      samples = get_state(f);
      return;
    case 2
      set_state(f, x);
      return;
  end
end

display = options(1);
if (round(options(5) == 1))
  persistence = 1;
  % Set alpha to lie in [0, 1)
  alpha = max(0, options(17));
  alpha = min(1, alpha);
  salpha = sqrt(1-alpha*alpha);
else
  persistence = 0;
end
L = max(1, options(7)); % At least one step in leap-frogging
if options(14) > 0
  nsamples = options(14);
else
  nsamples = 100;	% Default
end
if options(15) >= 0
  nomit = options(15);
else
  nomit = 0;
end
if options(18) > 0
  step_size = options(18);	% Step size.
else
  step_size = 1/L;		% Default  
end
x = x(:)';		% Force x to be a row vector
nparams = length(x);

% Set up strings for evaluating potential function and its gradient.
f = fcnchk(f, length(varargin));
gradf = fcnchk(gradf, length(varargin));

% Check the gradient evaluation.
if (options(9))
  % Check gradients
  feval('gradchek', x, f, gradf, varargin{:});
end

samples = zeros(nsamples, nparams);	% Matrix of returned samples.
if nargout >= 2
  en_save = 1;
  energies = zeros(nsamples, 1);
else
  en_save = 0;
end
if nargout >= 3
  diagnostics = 1;
  diagn_pos = zeros(nsamples, nparams);
  diagn_mom = zeros(nsamples, nparams);
  diagn_acc = zeros(nsamples, 1);
else
  diagnostics = 0;
end

n = - nomit + 1;
Eold = feval(f, x, varargin{:});	% Evaluate starting energy.
nreject = 0;
if (~persistence | isempty(HMC_MOM))
  p = randn(1, nparams);		% Initialise momenta at random
else
  p = HMC_MOM;				% Initialise momenta from stored state
end
lambda = 1;

% Main loop.
while n <= nsamples

  xold = x;		    % Store starting position.
  pold = p;		    % Store starting momenta
  Hold = Eold + 0.5*(p*p'); % Recalculate Hamiltonian as momenta have changed

  if ~persistence
    % Choose a direction at random
    if (rand < 0.5)
      lambda = -1;
    else
      lambda = 1;
    end
  end
  % Perturb step length.
  epsilon = lambda*step_size*(1.0 + 0.1*randn(1));

  % First half-step of leapfrog.
  p = p - 0.5*epsilon*feval(gradf, x, varargin{:});
  x = x + epsilon*p;
  
  % Full leapfrog steps.
  for m = 1 : L - 1
    p = p - epsilon*feval(gradf, x, varargin{:});
    x = x + epsilon*p;
  end

  % Final half-step of leapfrog.
  p = p - 0.5*epsilon*feval(gradf, x, varargin{:});

  % Now apply Metropolis algorithm.
  Enew = feval(f, x, varargin{:});	% Evaluate new energy.
  p = -p;				% Negate momentum
  Hnew = Enew + 0.5*p*p';		% Evaluate new Hamiltonian.
  a = exp(Hold - Hnew);			% Acceptance threshold.
  if (diagnostics & n > 0)
    diagn_pos(n,:) = x;
    diagn_mom(n,:) = p;
    diagn_acc(n,:) = a;
  end
  if (display > 1)
    fprintf(1, 'New position is\n');
    disp(x);
  end

  if a > rand(1)			% Accept the new state.
    Eold = Enew;			% Update energy
    if (display > 0)
      fprintf(1, 'Finished step %4d  Threshold: %g\n', n, a);
    end
  else					% Reject the new state.
    if n > 0 
      nreject = nreject + 1;
    end
    x = xold;				% Reset position 
    p = pold;   			% Reset momenta
    if (display > 0)
      fprintf(1, '  Sample rejected %4d.  Threshold: %g\n', n, a);
    end
  end
  if n > 0
    samples(n,:) = x;			% Store sample.
    if en_save 
      energies(n) = Eold;		% Store energy.
    end
  end

  % Set momenta for next iteration
  if persistence
    p = -p;
    % Adjust momenta by a small random amount.
    p = alpha.*p + salpha.*randn(1, nparams);
  else
    p = randn(1, nparams);	% Replace all momenta.
  end

  n = n + 1;
end

if (display > 0)
  fprintf(1, '\nFraction of samples rejected:  %g\n', ...
    nreject/(nsamples));
end
if diagnostics
  diagn.pos = diagn_pos;
  diagn.mom = diagn_mom;
  diagn.acc = diagn_acc;
end
% Store final momentum value in global so that it can be retrieved later
HMC_MOM = p;
return

% Return complete state of sampler (including momentum)
function state = get_state(f)

global HMC_MOM
state.randstate = rand('state');
state.randnstate = randn('state');
state.mom = HMC_MOM;
return

% Set complete state of sampler (including momentum) or just set randn
% and rand with integer argument.
function set_state(f, x)

global HMC_MOM
if isnumeric(x)
  rand('state', x);
  randn('state', x);
  HMC_MOM = [];
else
  if ~isstruct(x)
    error('Second argument to hmc must be number or state structure');
  end
  if (~isfield(x, 'randstate') | ~isfield(x, 'randnstate') ...
      | ~isfield(x, 'mom'))
    error('Second argument to hmc must contain correct fields')
  end
  rand('state', x.randstate);
  randn('state', x.randnstate);
  HMC_MOM = x.mom;
end
return

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区av电影 | 男女男精品网站| 亚洲欧洲韩国日本视频| 2023国产精品| 国产欧美日韩在线观看| 久久精品人人做人人爽97| 国产三级精品三级| 国产欧美精品在线观看| 中文字幕av一区二区三区高 | 99久免费精品视频在线观看| 成熟亚洲日本毛茸茸凸凹| 粉嫩嫩av羞羞动漫久久久| 国产.精品.日韩.另类.中文.在线.播放| 美女爽到高潮91| 国产成人夜色高潮福利影视| 成人综合在线观看| 在线一区二区三区做爰视频网站| 色网综合在线观看| 欧美精品在欧美一区二区少妇| 欧美一二三在线| 久久久国产精华| 亚洲日本乱码在线观看| 亚洲成人精品在线观看| 美女一区二区在线观看| 国产风韵犹存在线视精品| 99这里都是精品| 制服丝袜激情欧洲亚洲| 久久久久久久久久久久电影| 亚洲欧美综合色| 婷婷综合在线观看| 国产成人av网站| 欧美三级日韩三级| 国产日韩欧美a| 亚洲大片免费看| 国产精品伊人色| 欧美亚洲愉拍一区二区| 久久这里只有精品6| 亚洲免费三区一区二区| 久久不见久久见免费视频7| 成人激情小说网站| 日韩视频永久免费| 亚洲色图欧美激情| 久久99久久久久久久久久久| 91片黄在线观看| 欧美精品一区二区三区视频| 依依成人综合视频| 国产成人啪免费观看软件| 欧美日韩国产影片| 18涩涩午夜精品.www| 毛片av一区二区| 欧美最新大片在线看| 久久精品在这里| 蜜桃久久av一区| 欧美图区在线视频| 亚洲图片激情小说| 国产精品中文字幕欧美| 日韩视频永久免费| 亚洲国产你懂的| 一本色道久久综合狠狠躁的推荐| 日韩欧美国产不卡| 日日夜夜免费精品| 欧美午夜精品一区| 亚洲欧美国产高清| 波多野结衣在线一区| 久久亚洲综合色| 精品一区二区三区在线播放 | 不卡av在线免费观看| 精品国产乱码久久久久久蜜臀| 午夜精品久久久久久久| 欧美吻胸吃奶大尺度电影 | 欧美日韩综合在线| 亚洲国产视频一区| 欧洲精品在线观看| 一区二区三区资源| 在线欧美一区二区| 亚洲激情综合网| 一本久久精品一区二区| 亚洲精品成人在线| 在线视频观看一区| 一区二区三区国产| 欧美综合在线视频| 午夜精品久久久久影视| 欧美男女性生活在线直播观看| 一区二区三区免费网站| 在线欧美小视频| 首页国产丝袜综合| 欧美一区二区网站| 精品综合免费视频观看| 久久免费美女视频| a4yy欧美一区二区三区| 一区二区三区不卡视频在线观看| 欧美中文字幕不卡| 日韩1区2区日韩1区2区| 精品sm捆绑视频| 成人午夜在线播放| 亚洲精品国产精华液| 欧美一区二区三区电影| 精品在线一区二区三区| 国产精品欧美经典| 欧美日韩国产区一| 精品一二三四区| 亚洲日本在线天堂| 精品日韩在线一区| av电影在线观看不卡| 亚洲午夜精品17c| 日韩欧美不卡在线观看视频| 国产一区二区h| 亚洲激情第一区| 精品免费视频.| 色婷婷综合久久久久中文一区二区| 午夜精品久久久久久| 久久精品男人天堂av| 欧美午夜一区二区三区免费大片| 蜜臂av日日欢夜夜爽一区| 国产精品美女久久久久久久网站| 欧美日韩精品一区二区三区四区 | 国产网站一区二区三区| 在线看一区二区| 国产在线一区二区综合免费视频| 国产精品美女一区二区三区| 欧美一个色资源| 91成人免费电影| 国产999精品久久久久久| 亚洲一区二区免费视频| 国产精品网曝门| 日韩欧美中文字幕制服| 欧美无乱码久久久免费午夜一区| 国产高清久久久久| 日韩电影一区二区三区四区| 亚洲三级久久久| 国产日韩精品一区二区浪潮av| 欧美日韩高清影院| 日本久久一区二区三区| 国v精品久久久网| 久久成人18免费观看| 日韩国产一二三区| 亚洲激情图片小说视频| 中文天堂在线一区| 精品99一区二区| 精品国产一区二区三区忘忧草 | 91蜜桃视频在线| 丁香婷婷综合激情五月色| 久久综合综合久久综合| 天天操天天干天天综合网| 一区二区高清视频在线观看| 日韩一区在线播放| 欧美国产激情二区三区| 国产天堂亚洲国产碰碰| 久久蜜桃av一区精品变态类天堂 | 久久99国产精品久久99果冻传媒| 亚洲午夜久久久久| 奇米精品一区二区三区四区| 亚洲色图.com| 亚洲自拍与偷拍| 亚洲一区二区三区中文字幕在线| 中文字幕一区二区三区色视频| 国产精品视频免费| 国产精品乱人伦中文| 国产情人综合久久777777| 欧美激情中文不卡| 国产精品乱码妇女bbbb| 国产精品欧美一区二区三区| 国产精品萝li| 亚洲日本在线天堂| 亚洲国产精品视频| 日韩精品亚洲一区二区三区免费| 日韩和的一区二区| 久久国产成人午夜av影院| 国产精品综合在线视频| 成人免费毛片app| 91国模大尺度私拍在线视频| 欧美午夜片在线观看| 日韩欧美色综合网站| 久久蜜桃av一区精品变态类天堂 | 99热精品一区二区| 欧美性感一类影片在线播放| 欧洲精品一区二区| 欧美电视剧在线看免费| 久久天堂av综合合色蜜桃网| 国产午夜精品久久| 亚洲女人****多毛耸耸8| 亚洲观看高清完整版在线观看| 日韩av不卡一区二区| 国产不卡一区视频| 欧美午夜宅男影院| 久久久久久97三级| 一区二区三区电影在线播| 麻豆成人av在线| 色综合久久中文字幕综合网| 欧美老人xxxx18| 国产精品区一区二区三区| 亚洲第一成人在线| 成人妖精视频yjsp地址| 欧美三片在线视频观看 | 99久久久免费精品国产一区二区 | 日韩一区二区视频| 亚洲三级久久久| 国产精品自拍三区| 欧美精品一卡二卡| 亚洲女厕所小便bbb|