summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-31 14:38:15 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-31 14:38:15 +0000
commit5084fc612a5f8ed47a80771785e5c26ee4e42d94 (patch)
treed67f0a36ab6fd210d5ac45492664216c0ba9c543
parent318c309206f1cffcc17c9333bb6ac9e2f90b7610 (diff)
Answer to Vincent's email.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2295 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 81231c61a677939c03552b26ae065dfff970b759
-rw-r--r--src/Gudhi_stat/include/gudhi/bootstrap.h5
-rw-r--r--src/Gudhi_stat/test/CMakeLists.txt3
-rw-r--r--src/Gudhi_stat/test/persistence_lanscapes_test.cpp43
-rw-r--r--src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp20
4 files changed, 40 insertions, 31 deletions
diff --git a/src/Gudhi_stat/include/gudhi/bootstrap.h b/src/Gudhi_stat/include/gudhi/bootstrap.h
index dde08130..f88cc8e7 100644
--- a/src/Gudhi_stat/include/gudhi/bootstrap.h
+++ b/src/Gudhi_stat/include/gudhi/bootstrap.h
@@ -134,10 +134,7 @@ double bootstrap( size_t number_of_points , CharacteristicFunction f , DistanceB
// }
// );
// #endif
-
- //size_t position_of_quantile = floor(2*(1-quantile)*vector_of_distances.size());
-
-
+
size_t position_of_quantile = floor(quantile*vector_of_distances.size());
if ( position_of_quantile ) --position_of_quantile;
if ( dbg )
diff --git a/src/Gudhi_stat/test/CMakeLists.txt b/src/Gudhi_stat/test/CMakeLists.txt
index 292549f8..4ae09663 100644
--- a/src/Gudhi_stat/test/CMakeLists.txt
+++ b/src/Gudhi_stat/test/CMakeLists.txt
@@ -16,10 +16,13 @@ endif()
# copy data directory for tests purpose
file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
+# Do not forget to copy test files in current binary dir
+file(COPY "${CMAKE_SOURCE_DIR}/src/Gudhi_stat/test/data" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
add_executable ( persistence_intervals_test persistence_intervals_test.cpp )
target_link_libraries(persistence_intervals_test ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+
# Unitary tests
add_test(NAME persistence_intervals_test
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/persistence_intervals_test
diff --git a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
index 9b9f9d7b..957ddbfb 100644
--- a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
+++ b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
@@ -43,18 +43,18 @@ double epsilon = 0.0000005;
BOOST_AUTO_TEST_CASE(check_construction_of_landscape)
{
- Persistence_landscape p( "data/file_with_diagram" );
-
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
Persistence_landscape q;
- q.load_landscape_from_file( "data/file_with_landscape_from_file_with_diagram" );
-
+ q.load_landscape_from_file( "data/file_with_landscape_from_file_with_diagram" );
BOOST_CHECK( p == q );
}
BOOST_AUTO_TEST_CASE(check_computations_of_integrals)
{
- Persistence_landscape p( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
double integral = p.compute_integral_of_landscape();
//cerr << integral << " " << 2.34992 << endl;
BOOST_CHECK( fabs( integral - 2.34992 ) <= 0.00001 );
@@ -63,7 +63,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals)
BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly)
{
- Persistence_landscape p( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
std::vector< double > integrals_fir_different_levels;
integrals_fir_different_levels.push_back( 0.216432 );
@@ -106,7 +107,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly)
BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape)
{
- Persistence_landscape p( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
std::vector<double> integrals_fir_different_powers;
integrals_fir_different_powers.push_back( 17.1692 );
@@ -124,7 +126,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape)
BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points)
{
- Persistence_landscape p( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
BOOST_CHECK( fabs( p.compute_value_at_a_given_point(1,0.0) ) <= 0.00001 );
@@ -144,7 +147,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points)
BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications)
{
- Persistence_landscape p( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
Persistence_landscape second;
second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1" );
@@ -171,7 +175,8 @@ BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications)
BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms)
{
- Persistence_landscape p( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
Persistence_landscape second;
second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1" );
Persistence_landscape sum = p + second;
@@ -187,8 +192,10 @@ BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms)
BOOST_AUTO_TEST_CASE(check_computations_of_averages)
{
- Persistence_landscape p( "data/file_with_diagram" );
- Persistence_landscape q( "data/file_with_diagram_1" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
+ std::vector< std::pair< double , double > > diag2 = read_standard_file( "data/file_with_diagram_1" );
+ Persistence_landscape q( diag2 );
Persistence_landscape av;
av.compute_average( {&p,&q} );
@@ -202,8 +209,10 @@ BOOST_AUTO_TEST_CASE(check_computations_of_averages)
BOOST_AUTO_TEST_CASE(check_computations_of_distances)
{
- Persistence_landscape p( "data/file_with_diagram" );
- Persistence_landscape q( "data/file_with_diagram_1" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
+ std::vector< std::pair< double , double > > diag2 = read_standard_file( "data/file_with_diagram_1" );
+ Persistence_landscape q( diag2 );
BOOST_CHECK( fabs( p.distance( q )- 25.5824) <= 0.00005 );
BOOST_CHECK( fabs( p.distance( q , 2) - 2.12636 ) <= 0.00001 );
BOOST_CHECK( fabs( p.distance( q , std::numeric_limits<double>::max() )-0.359068 ) <= 0.00001 );
@@ -212,8 +221,10 @@ BOOST_AUTO_TEST_CASE(check_computations_of_distances)
BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product)
{
- Persistence_landscape p( "data/file_with_diagram" );
- Persistence_landscape q( "data/file_with_diagram_1" );
+ std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ Persistence_landscape p( diag );
+ std::vector< std::pair< double , double > > diag2 = read_standard_file( "data/file_with_diagram_1" );
+ Persistence_landscape q( diag2 );
BOOST_CHECK( fabs( p.compute_scalar_product( q ) - 0.754498 ) <= 0.00001 );
}
diff --git a/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp b/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
index 5556a8ee..5c3be0cc 100644
--- a/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
+++ b/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
@@ -71,17 +71,12 @@ int main( int argc , char** argv )
points.push_back( point2 );
points.push_back( point3 );
points.push_back( point4 );
-
-
- std::vector< std::vector<double> > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector<double> , Euclidean_distance<double> >( points );
- Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points );
-
- std::vector<size_t> characteristic_of_all_points = {0,1,2,3};
- std::vector<size_t> characteristic_of_subsampled_points = {2,3};
- std::cerr << "DISTANCE BETWEEN SAMPLE AND SUBSAMPLE: " << distance( characteristic_of_subsampled_points , characteristic_of_all_points ) << std::endl;
+ size_of_subsample = 2;
*/
-
-
+// std::vector< std::vector<double> > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector<double> , Euclidean_distance<double> >( points );
+// Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points );
+
+
std::cout << "Read : " << points.size() << " points.\n";
//comute all-to-all distance matrix:
@@ -89,6 +84,9 @@ int main( int argc , char** argv )
Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points );
identity< std::vector<size_t> > identity_char;
+// std::vector<size_t> characteristic_of_all_points = {0,1,2,3};
+// std::vector<size_t> characteristic_of_subsampled_points = {2,3};
+// std::cerr << "DISTANCE BETWEEN SAMPLE AND SUBSAMPLE: " << distance( characteristic_of_subsampled_points , characteristic_of_all_points ) << std::endl;
@@ -107,7 +105,7 @@ int main( int argc , char** argv )
>
( points.size() , identity_char , distance , number_of_repetitions_of_subsampling , size_of_subsample , quantile );
- std::cout << "result of the subsampling : " << result << std::endl;
+ std::cout << "result of the subsampling : " << 2*result << std::endl;
return 0;