HAVOK Analysis for Chaotic Time Series Simulation
function simulated_time_series = HAVOK_analysis(x, r, L, S)\n% HAVOK analysis for chaotic time series\n% Inputs:\n% x: The 1-dimensional chaotic time series\n% r: Number of components (eigen time series) to consider\n% L: Segment length for forming Hankel matrix\n% S: Step size for forming Hankel matrix\n% Outputs:\n% simulated_time_series: The simulated time series using HAVOK\nsigma = 10; % Lorenz's parameters (chaotic)\nbeta = 8/3;\nrho = 28;\nn = 3;\nx0=[-8; 8; 27]; % Initial condition\n% Integrate\ndt = 0.001;\ntspan=[dt:dt:200];\noptions = odeset('RelTol',1e-12,'AbsTol',1e-12ones(1,n));\n[t,xdat]=ode45(@(t,x) lorenz(t,x,sigma,beta,rho),tspan,x0,options);\nN = length(x)\n% Step 1: Create Hankel Matrix H\n%numSegments = floor((N-L)/S)+1\n%H = zeros(L, numSegments);\n% for i = 1:numSegments\n% H(:, i) = x(i:i+L-1)\n%end\nnumSegments = size(xdat,1)-L;\nH = zeros(L,size(xdat,1)-L);\nfor k=1:L\nH(k,:) = xdat(k:end-L-1+k,1);\nend\n% Step 2: Perform SVD on H\n[U, ~, ~] = svd(H, 'econ');\n% Step 3: Choose the first 'r-1' components\nv = U(:, 1:r-1);\n% Step 4: Form Delay Coordinates and Linear Regression\nV_shifted = v(2:end, :);\nV_fit = [ones(size(V_shifted, 1), 1), v(1:end-1, :)];\ncoeffs = V_fit \ V_shifted;\n% Step 5: Stochastic Input for the Last Coordinate \nvr = randn(N-r+1, r-1); % Assuming a Gaussian white noise input\n% Step 6: Simulate the Model\nsimulated_time_series = zeros(N, r-1); % Note that now it is an N(r-1) matrix\nsimulated_time_series(1:r-1, :) = v(1:r-1, :); % Initial conditions\nfor i = r:N\nfor j = 1:(r-1)\nsimulated_time_series(i, j) = [1, simulated_time_series(i-r+1:i-1, j)'] * coeffs(:, j) + vr(i-r+1, j);\nend\nend\n% Step 7: Plot the simulated time series\nfigure;\nplot(1:N, simulated_time_series(:, 1));\nhold on\nplot(1:N,xdat(:,1))\ntitle(['Simulated Time Series for Component ', num2str('1')]);\nxlabel('Time');\nylabel('Value');\nend
原文地址: https://www.cveoy.top/t/topic/p3GN 著作权归作者所有。请勿转载和采集!