@@ -296,13 +296,13 @@ void SBF::PrintFilter(int mode)
296296 printf (" Area-related parameters:\n " );
297297 for (int j = 1 ; j < this ->AREA_number +1 ; j++){
298298 potential_elements = (this ->AREA_members [j]*this ->HASH_number )-this ->AREA_self_collisions [j];
299- printf (" Area %d: %d members, %d cells out of %d potential (%d self-collisions)" ,j,this ->AREA_members [j],this ->AREA_cells [j],potential_elements,this ->AREA_self_collisions [j]);
299+ printf (" Area %d: %d members, %.5f expected cells, % d cells out of %d potential (%d self-collisions)" ,j,this ->AREA_members [j], this -> AREA_expected_cells [j],this ->AREA_cells [j],potential_elements,this ->AREA_self_collisions [j]);
300300 printf (" \n " );
301301 }
302302
303303 printf (" \n Emersion, Fpp, Isep:\n " );
304304 for (int j = 1 ; j < this ->AREA_number +1 ; j++){
305- printf (" Area %d: emersion %.5f, a-priori fpp %.5f, fpp %.5f, a-priori isep %.5f" ,j,this ->GetAreaEmersion (j),this ->AREA_a_priori_fpp [j],this ->AREA_fpp [j],this ->AREA_a_priori_isep [j]);
305+ printf (" Area %d: expected emersion %.5f, emersion %.5f, a-priori fpp %.5f, fpp %.5f, a-priori isep %.5f, expected ise %.5f, isep %.5f " ,j,this ->GetExpectedAreaEmersion (j), this -> GetAreaEmersion (j),this ->AREA_a_priori_fpp [j],this ->AREA_fpp [j],this ->AREA_a_priori_isep [j], this -> AREA_a_priori_isep [j]* this -> AREA_members [j], this -> AREA_isep [j]);
306306 printf (" \n " );
307307 }
308308 printf (" \n " );
@@ -336,10 +336,10 @@ void SBF::SaveToDisk(std::string path, int mode)
336336 myfile << " a-priori fpp" << " ;" << this ->GetFilterAPrioriFpp () << std::endl;
337337 myfile << " fpp" << " ;" << this ->GetFilterFpp () << std::endl;
338338 // area-related parameters:
339- // area,members,self-collisions,cells,emersion,a-priori fpp,fpp,a-priori isep
340- myfile << " area" << " ;" << " members" << " ;" << " self-collisions" << " ;" << " cells" << " ;" << " emersion" << " ;" << " a-priori fpp" << " ;" << " fpp" << " ;" << " a-priori isep" << std::endl;
339+ // area,members,expected cells, self-collisions,cells,expected emersion,emersion, a-priori fpp,fpp,a-priori isep,expected ise, isep
340+ myfile << " area" << " ;" << " members" << " ;" << " expected cells " << " ; " << " self-collisions" << " ;" << " cells" << " ;" << " expected emersion" << " ;" << " emersion " << " ; " << " a-priori fpp" << " ;" << " fpp" << " ;" << " a-priori isep " << " ; " << " expected ise " << " ; " << " isep" << std::endl;
341341 for (int j = 1 ; j < this ->AREA_number +1 ; j++){
342- myfile << j << " ;" << this ->AREA_members [j] << " ;" << this ->AREA_self_collisions [j] << " ;" << this ->AREA_cells [j] << " ;" << this ->GetAreaEmersion (j) << " ;" << this ->AREA_a_priori_fpp [j] << " ;" << this ->AREA_fpp [j] << " ;" << this ->AREA_a_priori_isep [j] << std::endl;
342+ myfile << j << " ; " << this -> AREA_members [j] << " ;" << this ->AREA_expected_cells [j] << " ;" << this ->AREA_self_collisions [j] << " ;" << this ->AREA_cells [j] << " ;" << this ->GetExpectedAreaEmersion (j) << " ; " << this -> GetAreaEmersion (j) << " ;" << this ->AREA_a_priori_fpp [j] << " ;" << this ->AREA_fpp [j] << " ;" << this ->AREA_a_priori_isep [j] << " ; " << ( float ) this -> AREA_members [j] * this -> AREA_a_priori_isep [j] << " ; " << ( float ) this -> AREA_isep [j] << std::endl;
343343 }
344344
345345 }
@@ -491,7 +491,7 @@ int SBF::Check(char *string, int size)
491491// Computes a-priori area-specific inter-set error probability (a_priori_isep)
492492void SBF::SetAPrioriAreaIsep ()
493493{
494- double p1 ;
494+ double p ;
495495 int nfill;
496496
497497
@@ -502,16 +502,58 @@ void SBF::SetAPrioriAreaIsep()
502502 nfill += this ->AREA_members [j];
503503 }
504504
505- p1 = (double )(1 - 1 / (double )this ->cells );
506- p1 = (double )(1 - (double )pow (p1 , this ->HASH_number *nfill));
507- p1 = (double )pow (p1 , this ->HASH_number );
505+ p = (double )(1 - 1 / (double )this ->cells );
506+ p = (double )(1 - (double )pow (p , this ->HASH_number *nfill));
507+ p = (double )pow (p , this ->HASH_number );
508508
509- this ->AREA_a_priori_isep [i] = (float )p1 ;
509+ this ->AREA_a_priori_isep [i] = (float )p ;
510510
511511 }
512512}
513513
514514
515+ // Computes a-posteriori area-specific inter-set error probability (isep)
516+ void SBF::SetAreaIsep ()
517+ {
518+ double p;
519+
520+ for (int i = this ->AREA_number ; i>0 ; i--) {
521+
522+ p = (double )(1 - (double )this ->GetAreaEmersion (i));
523+ p = (double )pow (p, this ->HASH_number );
524+
525+ this ->AREA_isep [i] = (float )p;
526+
527+ }
528+ }
529+
530+
531+ // Computes the expected number of cells for each area (expected_cells)
532+ void SBF::SetExpectedAreaCells ()
533+ {
534+ double p1, p2;
535+ int nfill;
536+
537+
538+ for (int i = this ->AREA_number ; i>0 ; i--) {
539+ nfill = 0 ;
540+
541+ for (int j = i + 1 ; j <= this ->AREA_number ; j++) {
542+ nfill += this ->AREA_members [j];
543+ }
544+
545+ p1 = (double )(1 - 1 / (double )this ->cells );
546+ p2 = (double )pow (p1, this ->HASH_number *nfill);
547+ p1 = (double )(1 - (double )pow (p1, this ->HASH_number *this ->AREA_members [i]));
548+
549+ p1 = (double )this ->cells *p1*p2;
550+
551+ this ->AREA_expected_cells [i] = (float )p1;
552+
553+ }
554+ }
555+
556+
515557// Computes a-priori area-specific false positives probability (a_priori_fpp)
516558void SBF::SetAPrioriAreaFpp ()
517559{
@@ -617,6 +659,24 @@ float SBF::GetFilterFpp()
617659 return (float )p;
618660}
619661
662+
663+ // Returns the expected emersion value for the input area
664+ float SBF::GetExpectedAreaEmersion (int area)
665+ {
666+ double p;
667+ int nfill = 0 ;
668+
669+ for (int j = area + 1 ; j <= this ->AREA_number ; j++) {
670+ nfill += this ->AREA_members [j];
671+ }
672+
673+ p = (double )(1 - 1 / (double )this ->cells );
674+ p = (double )pow (p, this ->HASH_number *nfill);
675+
676+ return (float )p;
677+ }
678+
679+
620680// Returns the emersion value for the input area
621681float SBF::GetAreaEmersion (int area)
622682{
0 commit comments