⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timeseries2.m

📁 the matlab code of ginisvm - an svm implementation good at probability regression.
💻 M
字号:
%-------------------------------------% This script generates markovian data% based on the input data and gaussian % distribution attached to each state.%-------------------------------------% 2 states% 1 models% Model 1% Make sure that the sum of the probabilities = 1 #####model1 = [ 0.5 0.5 ; 0.5 0.5 ]';% One mixture per stateweights = [ 1;1];% Two dimensional data.dim = 2;% Parameters for each state% and for each dimension ( mean and variance )param1 = [ 0.75 .8 0.75 .3 ; 0.01 .8 0.01 .3 ];header = 10;maxdata = 100;global poption;global dynamics;global startstate;global finalstate;poption = 0;dynamics = 0;startstate = 1;finalstate = 3;% Now to generate real data% Each model can generate currtrain = 1;currtest = 1;[trainx,crossx,trainlabel,testlabel] = genmarkov(model1,weights,param1,dim,100,100);traindata = trainx;testdat = crossx;[currtrain, dummy ] = size(trainx);[currtest, dummy ] = size(crossx);% store the test and the training datafid = fopen('train.dat','w');   for i = 1:currtrain,      fprintf(fid,'%d\n',trainlabel(i)-1);      for d = 1:dim,         fprintf(fid,'%f\n',traindata(i,d));      end;      %fprintf(fid,'%f\n',traintime(i));   end;   fclose(fid);% store the test and the training datafid = fopen('test.dat','w');   for i = 1:currtest,      fprintf(fid,'%d\n',testlabel(i)-1);      for d = 1:dim,         fprintf(fid,'%f\n',testdat(i,d));      end;      %fprintf(fid,'%f\n',testtime(i));   end;   fclose(fid);figure;subplot(2,2,1);hold on;for i = 1:currtrain,   if trainlabel(i) == 1,      plot(traindata(i,1),traindata(i,2),'bo');      Ytrain(i,:) = [ 1 0 ];   else      if trainlabel(i) == 2,         plot(traindata(i,1),traindata(i,2),'r+');         Ytrain(i,:) = [ 0 1 ];      end;   end;end;hold off;xlabel('x1');ylabel('x2');subplot(2,2,2);plot(trainlabel);axis([0,100,0.7,2.3]);xlabel('time index n');ylabel('label');subplot(2,2,3);hold on;for i = 1:currtest,   if testlabel(i) == 1,      plot(testdat(i,1),testdat(i,2),'bo');      Ycross(i,:) = [ 1 0 ];   else      if testlabel(i) == 2,         plot(testdat(i,1),testdat(i,2),'r+');         Ycross(i,:) = [ 0 1 ];      end;   end;end;hold off;xlabel('x1');ylabel('x2');subplot(2,2,4);plot(testlabel);axis([0,100,0.7,2.3])xlabel('time index n');ylabel('label');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -