Commit bf7793bf5a71a90a480187f5350f4f8bbb5b0837

Authored by Hacene SI HADJ MOHAND
1 parent 6a7820dc

correcting kendall

src/ExternLib/StatisticFunctions/CorrelationProcess.cc
... ... @@ -131,11 +131,11 @@ namespace AMDA {
131 131  
132 132 // Spearman
133 133 SpearmanProcess::SpearmanProcess(Parameter& parameter):CorrelationProcess(parameter){
134   - CorrelationProcess::_type = "spearman ";
  134 + CorrelationProcess::_type = "spearman";
135 135 }
136 136  
137 137 SpearmanProcess::SpearmanProcess(const CorrelationProcess& pProcess, Parameter& parameter):CorrelationProcess(pProcess, parameter){
138   - CorrelationProcess::_type = "spearman ";
  138 + CorrelationProcess::_type = "spearman";
139 139 }
140 140  
141 141 SpearmanProcess::~SpearmanProcess(){
... ...
src/ExternLib/StatisticFunctions/Toolbox.hh
... ... @@ -369,10 +369,16 @@ namespace AMDA {
369 369 return true;
370 370 std::vector<Type> rank_x = rankify(X);
371 371 std::vector<Type> rank_y = rankify(Y);
372   - Type sum = 0;
373   - for (int i = 0; i < n; i++)
374   - sum = (Type) (rank_x[i] - rank_y[i]);
375   - result = (Type) sum / (n * (n - 1));
  372 + Type nc = 0;
  373 + for (int i = 0; i < n; i++){
  374 + for (int j=i;j<n;j++){
  375 + if((i != j )&& ((rank_x[i] > rank_x[j] && rank_y[i] > rank_y[j]) ||
  376 + (rank_x[i] < rank_x[j] && rank_y[i] < rank_y[j])))
  377 + nc += 1;
  378 + }
  379 +
  380 + }
  381 + result = (Type) (4*nc - n*(n-1))/(Type) (n * (n - 1));
376 382  
377 383 return true;
378 384 }
... ...
test/data/functions.xml
... ... @@ -49,6 +49,34 @@
49 49 <info_brief>skewness() function</info_brief>
50 50 <new_kernel>#skew</new_kernel>
51 51 </function>
  52 + <function name="covariance_(,,)" args="2" kind="time" group="stat">
  53 + <prompts>
  54 + <prompt>input window time in secs</prompt>
  55 + </prompts>
  56 + <info_brief>covariance() function for two params</info_brief>
  57 + <new_kernel>#covariance</new_kernel>
  58 + </function>
  59 + <function name="pearson_(,,)" args="2" kind="time" group="stat">
  60 + <prompts>
  61 + <prompt>input window time in secs</prompt>
  62 + </prompts>
  63 + <info_brief>Pearson coefficient of two parameters</info_brief>
  64 + <new_kernel>#pearson</new_kernel>
  65 + </function>
  66 + <function name="kendall_(,,)" args="2" kind="time" group="stat">
  67 + <prompts>
  68 + <prompt>input window time in secs</prompt>
  69 + </prompts>
  70 + <info_brief>Kendall coefficient of two parameters</info_brief>
  71 + <new_kernel>#kendall</new_kernel>
  72 + </function>
  73 + <function name="spearman_(,,)" args="2" kind="time" group="stat">
  74 + <prompts>
  75 + <prompt>input window time in secs</prompt>
  76 + </prompts>
  77 + <info_brief>Spearman coefficient of two parameters</info_brief>
  78 + <new_kernel>#spearman</new_kernel>
  79 + </function>
52 80 <function name="mean_sm_(,)" args="1" kind="sliding" group="stat">
53 81 <prompts>
54 82 <prompt>input averaging time in secs</prompt>
... ... @@ -135,11 +163,6 @@
135 163 <new_kernel>newell2007</new_kernel>
136 164 </function>
137 165  
138   - <function name="newell2011()" args="1" kind="model" group="space">
139   - <info_brief>Newell et al 2011 auroral power</info_brief>
140   - <new_kernel>newell2011</new_kernel>
141   - </function>
142   -
143 166 <function name="fairfield70(,tilt_angle_60)" args="2" kind="model" group="space">
144 167 <prompt_param>xyz_sm (Re), dipole tilt angle (deg)</prompt_param>
145 168 <default_args>,tilt_angle_60</default_args>
... ... @@ -288,4 +311,5 @@
288 311 <info_brief>Square root</info_brief>
289 312 <new_kernel>sqrt</new_kernel>
290 313 </function>
  314 +
291 315 </functions>
... ...