From fcb2f25476c7c5d4b6d246c45e8ca42ce5ed217e Mon Sep 17 00:00:00 2001 From: BlackLight Date: Thu, 17 Feb 2011 01:59:33 +0100 Subject: [PATCH] Improving neural correlation algorithm --- neural.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neural.c b/neural.c index 692e2bc..5543c74 100644 --- a/neural.c +++ b/neural.c @@ -289,6 +289,8 @@ double AI_alert_neural_som_correlation ( const AI_snort_alert *a, const AI_snort_alert *b ) { AI_som_alert_tuple t1, t2; + double distance = 0.0, + max_distance = 0.0; t1.gid = a->gid; t1.sid = a->sid; @@ -310,7 +312,9 @@ AI_alert_neural_som_correlation ( const AI_snort_alert *a, const AI_snort_alert t2.timestamp = b->timestamp; t2.desc = b->desc; - return 1.0 / ( 1.0 + __AI_som_alert_distance ( t1, t2 )); + distance = __AI_som_alert_distance ( t1, t2 ); + max_distance = sqrt ((double) ( 2 * (config->outputNeuronsPerSide-1) * (config->outputNeuronsPerSide-1) )); + return (( distance == max_distance ) ? 0.0 : ( 1.0 / ( 1.0 + distance ))); } /* ----- end of function AI_alert_neural_som_correlation ----- */ /**