Guest User

Untitled

a guest
Jan 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.61 KB | None | 0 0
  1. double* Kalman(double mu, double sigma_x, double sigma_y, double lambda_x){
  2.  
  3. double S[2];
  4. double delta = 1/365;
  5.  
  6.  
  7. //initialisation
  8. double p_0 = delta*(sigma_y)*sigma_y;
  9. double yo_barre = 1.571; //voir calculs Excel
  10. double X[365] = {1.6179096263,1.542938223,1.4539898804,1.4727705571,1.5176913998,1.475822167,1.3609025196,1.2654100739,1.319509466,1.5019760064,1.6699901559,1.7632895347,1.974214987,1.7308775594,1.8334211604,1.7508954533,1.7308530824,1.3495817469,1.3905155155,1.4753798367,1.515658972,1.6685786578,1.7808149967,1.7886819973,1.7063093851,1.706311553,1.6443711108,1.6533144512,1.4568217879,1.4269196835,1.4627509167,1.4215940461,1.4764022826,1.4996397289,1.4766664979,1.565700432,1.5037046153,1.5011584889,1.5040625656,1.52008167,1.5449047289,1.5792996679,1.4905732488,1.4953164977,1.501523661,1.4629836075,1.4711424445,1.4147109564,1.3609086442,1.3943143137,1.3837701856,3.985511138,4.07566812,4.611713792,4.584383672,4.482412981,4.343421408,4.54294152,5.15839808,5.228016528,6.2152992,5.870018448,4.91317764,4.153741504,4.24814472,4.1564131,4.0225774,4.0109766,4.174351008,4.38666612,4.385005158,4.76821882,4.488909088,4.41601512,4.470347808,4.907964104,4.810005584,4.954206087,5.04830137,4.541597192,4.548441664,4.9416849,5.207558176,4.79252932,4.70542369,4.8880312,5.40535864,5.4736157,5.56665241,5.202119448,5.192907048,5.15327155,4.925448045,4.698405888,4.592105028,4.454014223,5.08631958,4.364052066,5.162810649,4.93329138,4.952436112,5.0299704,4.88362119,4.752916,5.11011828,5.108031842,5.327838,5.26145754,5.1568968,5.70995641,5.510912272,5.201080494,5.538556296,4.811711584,5.08472447,5.262505024,4.866520246,4.33267702,4.478004336,5.0509542,4.858965225,5.096739828,4.735059298,4.813345932,4.845522798,4.70630808,4.67385996,4.543770636,4.485578976,4.5179145,4.542450192,4.454482008,4.27578192,4.34423517,4.54309506,4.9793022,4.301968167,4.211702001,4.40595825,4.26672306,4.211765976,3.685834325,3.683477486,3.351387526,3.616883776,3.36408699,3.65389374,3.623247156,3.648185464,3.262331767,3.284780168,3.81106752,3.317830506,3.6373626,4.03966299,3.77516475,3.859098244,3.92257168,4.166369316,4.052050256,4.30034832,4.72227624,4.695928776,5.0521484,4.934284272,5.40291906,5.358333603,5.54578803,5.845926998,5.406057418,5.306591135,4.87080913,4.945400568,5.325190288,5.329500838,4.640101632,5.247243148,5.55963222,5.76778128,5.91620328,6.654592494,5.119883424,5.608754784,5.113618992,5.317915904,5.3118016,5.1093847,5.45251248,5.2056884,4.94685408,4.865925193,4.760022343,5.004118017,5.597106813,5.98621752,6.035070621,6.502970038,6.213792973,6.49522241,6.376400192,6.67169105,7.434334807,8.086946682,7.86376998,6.957817872,7.198673426,7.564738376,6.814234856,6.400416407,6.387682141,6.65694848,5.309508736,6.314931306,6.2976137,6.327350133,6.614922876,5.9748385,5.461888656,5.983648284,5.983648284,6.506738592,7.01374132,7.548858075,7.405826182,7.180472112,7.35181934,7.085318256,6.643276596,6.835382432,6.96308165,7.87748059,7.92536801,7.6619872,7.37428736,6.745919792,7.502906112,7.509825648,7.455513432,7.270600092,6.886734738,7.46488449,6.195700672,5.72981425,5.836075872,5.839883664,6.766552156,7.645411704,6.866936608,5.684504596,6.768555,5.64044544,4.93753932,5.663947296,5.586517074,5.765089212,5.3405477,4.893616644,5.47963788,5.527890384,5.11861416,5.483981356,5.547560564,5.5411733,5.59950144,9.3325024,6.06612656,6.70669544,7.240304944,5.501962596,4.929903264,4.737753072,4.514864172,4.3791314,4.717676864,5.334962256,5.192105569,4.6406612,4.67449118,4.73367232,4.877152038,4.881023293,4.963668416,5.024166588,5.079449518,5.1865812,4.98247536,5.033488172,5.35049368,5.56183296,5.87812536,5.813707653,5.41174761,5.059421931,4.94542104,5.175608208,5.58727795,5.759531064,6.216670824,6.09781551,4.805387442,4.60573938,4.444527498,4.596332496,4.558930152,4.730236436,4.5045224,4.527045012,4.608028832,4.608533808,4.42167904,4.640981928,4.456228952,4.521509895,4.662392228,5.016888792,5.610971731,5.54771581,5.469698724,5.16220246,5.004689186,4.82719524,4.698324,4.614979076,5.323588354,5.190412876,4.860148336,4.693779216,4.57426368,4.5700328,4.34542084,4.529713196,4.846281968,4.657246932,4.789869666,5.51351904,5.54709312,4.754299566,4.5597968,4.683939008,4.932571448,5.191166928,5.39814226,4.963685476,4.5946845,4.541372,4.767943301,4.71099958,5.062889376,4.909386908,5.21551496,4.926847818,4.86877046,4.964956446,4.735982244,4.627980076,4.543345842,4.409059758,4.68972576,4.549989006,4.524921042,4.685344752,4.639855968,4.514198832,4.657298965,4.675649554};
  11.  
  12. double R[365];
  13. double G[365];
  14. G[0] = (p_0 + delta*(sigma_y)*sigma_y)*(delta)*delta*(lambda_x)*lambda_x + delta*(sigma_x)*sigma_x;
  15.  
  16. double K_increment = 0;
  17. double p_increment = p_0;
  18. double p_barre_increment = 0;
  19. double y_increment = 0;
  20. double y_barre_increment = 0;
  21. double x_increment = 0;
  22.  
  23.  
  24. int t = 1; for (; t < 366; t++)
  25. {
  26.  
  27. p_barre_increment = p_increment + delta*(sigma_y)*sigma_y;
  28. y_barre_increment = y_increment + mu*delta;
  29.  
  30. G[t] = (lambda_x)*lambda_x*(delta)*delta*p_barre_increment+delta*(sigma_x)*sigma_x;
  31. K_increment = (lambda_x*delta*p_barre_increment)/G[t];
  32.  
  33. p_increment = p_barre_increment*(1-lambda_x*delta*K_increment);
  34. x_increment = lambda_x*delta*y_barre_increment + X[t-1]*(1-delta*lambda_x);
  35.  
  36. R[t] = X[t] - x_increment;
  37.  
  38. y_increment = y_barre_increment + K_increment*R[t];
  39.  
  40. }
  41.  
  42.  
  43. return R;
  44. }
  45.  
  46. int main()
  47. {
  48.  
  49. double Resultat[365] = Kalman(0.33,4.70,0.63,164.6);
  50.  
  51. int i = 0; for (; i<365; i++){
  52. cout<<Resultat[i]<<",";
  53. }
  54.  
  55.  
  56. }
Add Comment
Please, Sign In to add comment