Fixed a logical error in the neural correlation

This commit is contained in:
BlackLight 2011-02-17 01:47:32 +01:00
parent cddaa2b3a7
commit 50f287fbb5
1 changed files with 5 additions and 3 deletions

View File

@ -272,8 +272,10 @@ __AI_som_alert_distance ( const AI_som_alert_tuple alert1, const AI_som_alert_tu
/* Return the normalized euclidean distance in [0,1] (the normalization is made considering that the maximum distance /* Return the normalized euclidean distance in [0,1] (the normalization is made considering that the maximum distance
* between two points on the output neurons matrix is the distance between the upper-left and bottom-right points) */ * between two points on the output neurons matrix is the distance between the upper-left and bottom-right points) */
return sqrt ((double) ( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) )) / /* return sqrt ((double) ( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) )) / */
sqrt ((double) ( 2 * (config->outputNeuronsPerSide-1) * (config->outputNeuronsPerSide-1) )); /* sqrt ((double) ( 2 * (config->outputNeuronsPerSide-1) * (config->outputNeuronsPerSide-1) )); */
return sqrt ((double) ( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ));
} /* ----- end of function __AI_som_alert_distance ----- */ } /* ----- end of function __AI_som_alert_distance ----- */
/** /**
@ -308,7 +310,7 @@ AI_alert_neural_som_correlation ( const AI_snort_alert *a, const AI_snort_alert
t2.timestamp = b->timestamp; t2.timestamp = b->timestamp;
t2.desc = b->desc; t2.desc = b->desc;
return __AI_som_alert_distance ( t1, t2 ); return 1.0 / ( 1.0 + __AI_som_alert_distance ( t1, t2 ));
} /* ----- end of function AI_alert_neural_som_correlation ----- */ } /* ----- end of function AI_alert_neural_som_correlation ----- */
/** /**