summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-28 08:53:13 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-28 08:53:13 +0000
commit51cce89377cd64a1726f0b281dff8e54fd15a0e2 (patch)
treed8eb67e9197409d8828f867ac5fa8dfc96f84082
parent897783d59fbe6ac6bca89a18ab893fa76cf990c9 (diff)
Removing all the elements which do not belong to the package persistence_representations.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2388 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5d009fdd814e42af9fcbe03a41f5cbd0087d69f4
-rw-r--r--src/Gudhi_stat/include/gudhi/Hausdorff_distances.h149
-rw-r--r--src/Gudhi_stat/include/gudhi/bootstrap.h174
-rw-r--r--src/Gudhi_stat/include/gudhi/fill_in_missing_data.h144
-rw-r--r--src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h179
-rw-r--r--src/Gudhi_stat/include/gudhi/permutation_test.h99
-rw-r--r--src/Gudhi_stat/include/gudhi/time_series_analysis/periodicity_tests.h36
-rw-r--r--src/Gudhi_stat/include/gudhi/time_series_analysis/sliding_window.h272
-rw-r--r--src/Gudhi_stat/include/gudhi/topological_process.h420
-rw-r--r--src/Gudhi_stat/utilities/CMakeLists.txt53
-rw-r--r--src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp138
-rw-r--r--src/Gudhi_stat/utilities/Landscape_bootstrap.cpp186
-rw-r--r--src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp70
-rw-r--r--src/Gudhi_stat/utilities/permutation_test.cpp84
-rw-r--r--src/Gudhi_stat/utilities/sliding_window_embedding.cpp39
14 files changed, 0 insertions, 2043 deletions
diff --git a/src/Gudhi_stat/include/gudhi/Hausdorff_distances.h b/src/Gudhi_stat/include/gudhi/Hausdorff_distances.h
deleted file mode 100644
index 39de764e..00000000
--- a/src/Gudhi_stat/include/gudhi/Hausdorff_distances.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef HAUSDORFF_DISTANCES_H
-#define HAUSDORFF_DISTANCES_H
-
-#include <cmath>
-#include <limits>
-#include <vector>
-#include <cstdlib>
-#include <iostream>
-
-namespace Gudhi
-{
-namespace Gudhi_stat
-{
-
-
-/**
- * This file contains various implementations of Hausrodff distances between collections of points. It contains various implementations that can be used for specific case.
-**/
-
-/**
- * The implementation below works for a case of a metric space given by a distance matrix, and a subspace of a metric space. Our task is to find a Hausdorff distance between the subspace and the whole space.
- * The input is a distance matrix (lower triangular part) and a vector of bools indicating a subspace (elementss set to true belongs to the space, the elements set to false do not).
-**/
-class Hausdorff_distance_between_subspace_and_the_whole_metric_space
-{
-public:
- Hausdorff_distance_between_subspace_and_the_whole_metric_space( const std::vector< std::vector<double> >& distance_matrix ):distance_matrix(distance_matrix){}
- double operator()( const std::vector< bool >& is_subspace )
- {
- double maximal_distance = -std::numeric_limits<double>::max();
- for ( size_t j = 0 ; j != this->distance_matrix.size() ; ++j )
- {
- double minimal_distance = std::numeric_limits<double>::max();
- for ( size_t i = 0 ; i != this->distance_matrix.size() ; ++i )
- {
- if ( !is_subspace[i] )continue;
- double distance = 0;
- if ( i < j )
- {
- distance = this->distance_matrix[i][j];
- }
- else
- {
- if ( i > j )distance = this->distance_matrix[j][i];
- }
- if ( distance > minimal_distance )minimal_distance = distance;
- }
- if ( maximal_distance < minimal_distance )maximal_distance = minimal_distance;
- }
- return maximal_distance;
- }//Hausdorff_distance_between_subspace_and_the_whole_metric_space
-
- double operator()( const std::vector< size_t >& subspace , const std::vector< size_t >& space = std::vector< size_t >() )
- {
- bool dbg = false;
- if ( dbg )
- {
- std::cerr << "Calling double operator()( const std::vector< size_t >& subspace , const std::vector< size_t >& space = std::vector< size_t >() ) method \n";
- std::cerr << "subspace.size() : " << subspace.size() << std::endl;
- }
- double maximal_distance = -std::numeric_limits<double>::max();
- for ( size_t j = 0 ; j != this->distance_matrix.size() ; ++j )
- {
- double minimal_distance = std::numeric_limits<double>::max();
- for ( size_t i = 0 ; i != subspace.size() ; ++i )
- {
- double distance = 0;
- if ( subspace[i] < j )
- {
- distance = this->distance_matrix[ j ][ subspace[i] ];
- }
- else
- {
- if ( subspace[i] > j )distance = this->distance_matrix[ subspace[i] ][ j ];
- }
- if ( distance < minimal_distance )minimal_distance = distance;
- }
- if ( maximal_distance < minimal_distance )maximal_distance = minimal_distance;
- }
- if ( dbg )
- {
- std::cerr << "maximal_distance : " << maximal_distance << std::endl;
- getchar();
- }
- return maximal_distance;
- }//Hausdorff_distance_between_subspace_and_the_whole_metric_space
-private:
- const std::vector< std::vector<double> >& distance_matrix;
-};
-
-template <typename PointType , typename distanceFunction >
-std::vector< std::vector<double> > compute_all_to_all_distance_matrix_between_points( const std::vector< PointType >& points )
-{
- bool dbg = false;
- std::vector< std::vector<double> > result;
- result.reserve( points.size() );
- distanceFunction f;
- for ( size_t i = 0 ; i != points.size() ; ++i )
- {
- std::vector<double> this_row;
- this_row.reserve( i );
- for ( size_t j = 0 ; j != i ; ++j )
- {
- double distance = f( points[i] , points[j] );
- if ( dbg ){std::cerr << "The distance between point : " << i << " and the point : " << j << " is :" << distance << std::endl;}
- this_row.push_back( distance );
- }
- result.push_back( this_row );
- }
- return result;
-}//compute_all_to_all_distance_matrix_between_points
-
-template <typename T>
-class identity
-{
-public:
- T& operator()( T& org )
- {
- return org;
- }
-};
-
-
-}//namespace Gudhi_stat
-}//namespace Gudhi
-
-#endif
diff --git a/src/Gudhi_stat/include/gudhi/bootstrap.h b/src/Gudhi_stat/include/gudhi/bootstrap.h
deleted file mode 100644
index c3cd80c7..00000000
--- a/src/Gudhi_stat/include/gudhi/bootstrap.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/* Thicharacteristic_of_all_pointss file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef BOOTSTRAP_H
-#define BOOTSTRAP_H
-
-
-#ifdef GUDHI_USE_TBB
-#include <tbb/parallel_sort.h>
-#include <tbb/task_scheduler_init.h>
-#endif
-
-#include <vector>
-#include <algorithm>
-#include <random>
-#include <ctime>
-
-namespace Gudhi
-{
-namespace Gudhi_stat
-{
-
-/**
-* This is a generic function to perform bootstrap.
-* In this function we assume that there is a class to compute characteristic of collection of points (PointCloudCharacteristics) and that it stores coordinates of all points. It allows to compute the characteristic
-* of the whole point cloud (by using CharacteristicFunction) or of it proper subset of the whole point cloud (given the list of numers of points in the subset).
-* Both functionalities will be used in this implementation.
-* The characteristic of point cloud, may be the poit cloud itself, its persistence diagram in a fixed dimension, or anything else. We only assume that space of points characteristics is a metric space
-* and that we can compute a distance between two characteristics of collections of points by using DistanceBetweenPointsCharacteristics function.
-**/
-
-
-
-template < typename PointCloudCharacteristics , typename CharacteristicFunction , typename DistanceBetweenPointsCharacteristics >
-double bootstrap( size_t number_of_points , CharacteristicFunction f , DistanceBetweenPointsCharacteristics distance , size_t number_of_repetitions , size_t size_of_subsample , double quantile = 0.95 , size_t maximal_number_of_threads_in_TBB = std::numeric_limits<size_t>::max() )
-{
- bool dbg = false;
-
- #ifdef GUDHI_USE_TBB
- tbb::task_scheduler_init init(maximal_number_of_threads_in_TBB == std::numeric_limits<size_t>::max() ? tbb::task_scheduler_init::automatic : maximal_number_of_threads_in_TBB);
- #endif
-
- if ( size_of_subsample >= number_of_points )
- {
- std::cerr << "Size of subsample is greater or equal to the number of points. The bootstrap procedure do not make sense in this case. \n";
- return 0;
- }
-
- //initialization of a random number generator:
- std::srand ( unsigned ( std::time(0) ) );
-
- //we will shuffle the vector of numbers 0,1,2,...,points.size()-1 in order to pick a subset of a size size_of_subsample
- std::vector<size_t> numbers_to_sample_(number_of_points) ; //create vector of size_t of a size number_of_points
- std::iota (std::begin(numbers_to_sample_), std::end(numbers_to_sample_), 0);//populate it with 1 2 3 ... number_of_points.
-
- //now we compute the characteristic od all the points:
- PointCloudCharacteristics characteristic_of_all_points = f( numbers_to_sample_ );
-
- //vector to keep the distances between characteristic_of_points and characteristic_of_subsample:
- std::vector< double > vector_of_distances( number_of_repetitions , 0 );
-
-
-
-//TODO- at the moment, the operations I am doing over here do not seems to be threat safe. When using TBB, I am getting wrong results.
-//It is quite likelly because I am not using a method to compute persistence which is threat safe. VERIFY this as soon as I merge with
-//the new metod to compute persistence.
-
-// #ifdef GUDHI_USE_TBB
-// tbb::parallel_for ( tbb::blocked_range<size_t>(0, number_of_repetitions), [&](const tbb::blocked_range<size_t>& range)
-// {
-// for ( size_t it_no = range.begin() ; it_no != range.end() ; ++it_no )
-// #else
- for ( size_t it_no = 0 ; it_no < number_of_repetitions ; ++it_no )
-// #endif
- {
- if ( dbg )
- {
- std::cout << "Still : " << number_of_repetitions-it_no << " tests to go. \n The subsampled vector consist of points number : ";
- std::cout << "it_no : " << it_no << std::endl;
- std::cout << "number_of_points : " << number_of_points << std::endl;
- }
- //do a random shuffle of vector_of_characteristics_of_poits
- std::vector<size_t> numbers_to_sample(number_of_points) ; //create vector of size_t of a size number_of_points
- std::iota (std::begin(numbers_to_sample), std::end(numbers_to_sample), 0);//populate it with 1 2 3 ... number_of_points.
- //TODO: consider doing it in a smarter/faster way.
- std::random_shuffle( numbers_to_sample.begin() , numbers_to_sample.end() );
-
- //construct a vector< PointType > of a size size_of_subsample:
- std::vector< size_t > subsampled_points;
- subsampled_points.reserve( size_of_subsample );
- for ( size_t i = 0 ; i != size_of_subsample ; ++i )
- {
- subsampled_points.push_back( numbers_to_sample[i] );
- if ( dbg )std::cout << numbers_to_sample[i] << " , ";
- }
-
-
- //now we can compute characteristic of subsampled_points:
- PointCloudCharacteristics characteristic_of_subsampled_points = f( subsampled_points );
- if ( dbg )std::cout << std::endl << "Characteristic of subsampled points computed.\n";
-
- //and now we compute distance between characteristic_of_points and characteristic_of_subsample. Note that subsampled points go first, and this is neded, since sometimes all points are not needed.
- double dist = distance( characteristic_of_subsampled_points , characteristic_of_all_points );
-
- if ( dbg )
- {
- std::cout << "The distance between characteristic of all points and the characteristic of subsample is : " << dist << std::endl;
- getchar();
- }
-
- vector_of_distances[it_no] = dist;
- }
-// #ifdef GUDHI_USE_TBB
-// }
-// );
-// #endif
-
- size_t position_of_quantile = floor(quantile*vector_of_distances.size());
- if ( position_of_quantile ) --position_of_quantile;
-
-
-
- if ( dbg )
- {
- std::cerr << "quantile : " << quantile << std::endl;
- std::cerr << "position_of_quantile : " << position_of_quantile << std::endl;
-
- std::sort( vector_of_distances.begin() , vector_of_distances.end() );
- //std::cout << "position_of_quantile : " << position_of_quantile << ", and here is the array : " << std::endl;
- for ( size_t i = 0 ; i != vector_of_distances.size() ; ++i )
- {
- std::cout << vector_of_distances[i] << " " ;
- }
- std::cout << std::endl;
- }
-
- //now we need to sort the vector_of_distances and find the quantile:
- std::nth_element (vector_of_distances.begin(), vector_of_distances.begin()+position_of_quantile, vector_of_distances.end());
-
-
- //for Hausdorff bootrstra I have to multily it by 2.
- //In case of other bootsraps, I do not have to do it. We need a special variable saying if Ineed this multiplication or not.//This should be done outside the bootstrap, since the fact hat we need it do not come from bootstrab, but from geometry of bottleneck distance
-
- if ( dbg )std::cout << "Result : " << vector_of_distances[ position_of_quantile ] << std::endl;
-
- return vector_of_distances[ position_of_quantile ];
-
-}//bootstrap
-
-
-
-}//namespace Gudhi_stat
-}//namespace Gudhi
-
-#endif
diff --git a/src/Gudhi_stat/include/gudhi/fill_in_missing_data.h b/src/Gudhi_stat/include/gudhi/fill_in_missing_data.h
deleted file mode 100644
index a9997aa2..00000000
--- a/src/Gudhi_stat/include/gudhi/fill_in_missing_data.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef FILL_IN_MISSING_DATA_H
-#define FILL_IN_MISSING_DATA_H
-
-namespace Gudhi
-{
-namespace Gudhi_stat
-{
-
-/**
- * Quite often in biological sciences we are facing a problem of missing data. We may have for instance a number of sequences of observations made in between times A and B in a discrete
- * collection of times A = t1, t2,...,tn = B. But quite typically some of the observations may be missing. Then quite often it is hard to estimate the values in the missing times.
- * The procedure below assumes that we compute some topological descriptor of the observations we are given. Most typically this will be some type of persistence homology representation.
- * The the values in the missing points are filled in by linear interpolation and extrapolation. The procedure below have minimal requirements: it assumes that we have two elements that
- * filled in. The rest will be filled in by using them.
- * The fill-in process is done based on the idea of linear approximation. Let us assume that we have two positions A and B which are filled in with proper objects of a type Representation_of_topology.
- * Any intermediate time step can be interpolated by taking a linear combination t*A + (1-t)*B, where t \in [0,1].
- * If the missing data are located at the beginning of at the end of vector of Representation_of_topology, then we use the following extrapolation scheme:
- * First we make sure that there are no missing data except at the very beginning and at the very end of a vector of data. Then, we pick two constitutive closest filled-in data A and B and we extrapolate
- * by using a formula: t*A-(t-1)*B, where t is a natural number > 1.
- * Note that both vector of data and the vector is_the_position_filled_in are modified by this procedure. Upon successful termination of the procedure, the vector is_the_position_filled_in has only 'true' entries,
- * and the vector data do not have missing data.
-**/
-
-template < typename Representation_of_topology >
-void fill_in_missing_data( std::vector< Representation_of_topology* >& data , std::vector< bool >& is_the_position_filled_in )
-{
- bool dbg = false;
-
- //first check if at least two positions are filled in:
- size_t number_of_positions_that_are_filled_in = 0;
- for ( size_t i = 0 ; i != is_the_position_filled_in.size() ; ++i )
- {
- if ( is_the_position_filled_in[i] )++number_of_positions_that_are_filled_in;
- }
-
- if ( number_of_positions_that_are_filled_in < 2 )
- {
- std::cerr << "There are too few positions filled in to do extrapolation / interpolation. The program will now terminate.\n";
- throw "There are too few positions filled in to do extrapolation / interpolation. The program will now terminate.\n";
- }
-
- for ( size_t i = 0 ; i != data.size() ; ++i )
- {
- if ( !is_the_position_filled_in[i] )
- {
- //This position is not filled in. Find the next position which is nonzero.
- size_t j = 1;
- while ( (is_the_position_filled_in[i+j] == false) && ( i+j != data.size() ) )++j;
- if ( dbg )
- {
- std::cout << "The position number : " << i << " is not filled in. The next filled-in position is : " << i+j << std::endl;
- }
- if ( i != 0 )
- {
- //this is not the first position of the data:
- if ( i + j != data.size() )
- {
- //this is not the last position of the data either
- for ( size_t k = 0 ; k != j ; ++k )
- {
- double weight1 = double(j-k)/(double)(j+1);
- double weight2 = double(k+1)/(double)(j+1);
- data[i+k] = new Representation_of_topology(weight1*(*data[i-1]) + weight2*(*data[i+j]));
- is_the_position_filled_in[i+k] = true;
- if ( dbg )
- {
- std::cerr << "We fill in a position : " << i+k << " with: position " << i-1 << " with weight " << weight1 << " and position " << i+j << " with weight " << weight2 << std::endl;
- }
- }
- }
- }
- else
- {
- //this is the first position of the data, i.e. i == 0.
- while ( is_the_position_filled_in[i] == 0 )++i;
- }
-
- }
- }
-
-
- if ( is_the_position_filled_in[0] == false )
- {
- //find the first nonzero (then, we know that the second one will be nonzero too, since we filled it in above):
- size_t i = 0;
- while ( is_the_position_filled_in[i] == false )++i;
- //the data at position i is declared. Since, we made sure that all other positions, except maybe a few first and a few last, are declared too. Therefore, if we find a
- //first declared, then the next one will be declared too. So, we can do a telescopic declaration backward and forward.
-
- for ( size_t j = i ; j != 0 ; --j )
- {
- data[j-1] = new Representation_of_topology(2*(*data[j]) + (-1)*(*data[j+1]));
- is_the_position_filled_in[j-1] = true;
- if ( dbg )
- {
- std::cerr << "Filling in a position : " << j-1 << " by using: " << j << " and " << j+1 <<std::endl;
- }
- }
- }
-
- if ( is_the_position_filled_in[ is_the_position_filled_in.size()-1 ] == false )
- {
- //first the first nonzero (then, we know that the second one will be nonzero too):
- size_t i = is_the_position_filled_in.size()-1;
- while ( is_the_position_filled_in[i] == false )--i;
-
- for ( size_t j = i+1 ; j != data.size() ; ++j )
- {
- data[j] = new Representation_of_topology(2*(*data[j-1]) + (-1)*(*data[j-2]));
- is_the_position_filled_in[j] = true;
- if ( dbg )
- {
- std::cerr << "Filling in a position : " << j << " by using: " << j-1 << " and " << j-2 <<std::endl;
- }
- }
- }
-}//fill_in_missing_data
-
-}//namespace Gudhi_stat
-}//namespace Gudhi
-
-#endif
diff --git a/src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h b/src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h
deleted file mode 100644
index a19e6d60..00000000
--- a/src/Gudhi_stat/include/gudhi/multiplicative_bootstrap.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef BOOTSTRAP_H
-#define BOOTSTRAP_H
-
-//concretizations
-#include <gudhi/persistence_vectors.h>
-#include <gudhi/Persistence_landscape.h>
-#include <gudhi/Persistence_landscape_on_grid.h>
-#include <gudhi/Persistence_heat_maps.h>
-
-#ifdef GUDHI_USE_TBB
-#include <tbb/parallel_sort.h>
-#include <tbb/task_scheduler_init.h>
-#endif
-
-#include <vector>
-#include <algorithm>
-#include <random>
-#include <ctime>
-
-namespace Gudhi
-{
-namespace Gudhi_stat
-{
-
-template < typename TopologicalObject >
-class difference_of_objects
-{
-public:
- TopologicalObject operator()( const TopologicalObject& first, const TopologicalObject& second )const
- {
- return first-second;
- }
-};
-
-template < typename TopologicalObject >
-class norm_of_objects
-{
-public:
- norm_of_objects():power(1){}
- norm_of_objects( double power_ ):power(power_){}
- double operator()( const TopologicalObject& obj )const
- {
- TopologicalObject empty;
- double dist = empty.distance( obj , power );
- //std::cerr << "dist : " << dist << std::endl;getchar();
- return dist;
- }
-private:
- double power;
-};
-
-
-
-/**
-* This is a generic function to perform multiplicative bootstrap.
-**/
-template < typename TopologicalObject , typename OperationOnObjects , typename NormOnObjects >
-double multiplicative_bootstrap( const std::vector< TopologicalObject* >& topological_objects , size_t number_of_bootstrap_operations , const OperationOnObjects& oper , const NormOnObjects& norm , double quantile = 0.95 , size_t maximal_number_of_threads_in_TBB = std::numeric_limits<size_t>::max() )
-{
- bool dbg = false;
-
- #ifdef GUDHI_USE_TBB
- tbb::task_scheduler_init init(maximal_number_of_threads_in_TBB == std::numeric_limits<size_t>::max() ? tbb::task_scheduler_init::automatic : maximal_number_of_threads_in_TBB);
- #endif
-
- //initialization of a random number generator:
- std::random_device rd;
- std::mt19937 generator( time(NULL) );
- std::normal_distribution<> norm_distribution(0.,1.);
-
-
- //first compute an average of topological_objects
- TopologicalObject average;
- average.compute_average( topological_objects );
-
- std::vector< double > vector_of_intermediate_characteristics( number_of_bootstrap_operations , 0 );
-
-
- #ifdef GUDHI_USE_TBB
- tbb::parallel_for ( tbb::blocked_range<size_t>(0, number_of_bootstrap_operations), [&](const tbb::blocked_range<size_t>& range)
- {
- for ( size_t it_no = range.begin() ; it_no != range.end() ; ++it_no )
- #else
- for ( size_t it_no = 0 ; it_no < number_of_bootstrap_operations ; ++it_no )
- #endif
- {
- if ( dbg )
- {
- std::cout << "Still : " << number_of_bootstrap_operations-it_no << " tests to go. \n The subsampled vector consist of points number : ";
- }
-
-
- //and compute the intermediate characteristic:
- TopologicalObject result;
- for ( size_t i = 0 ; i != topological_objects.size() ; ++i )
- {
- double rand_variable = norm_distribution( generator );
- result = result + rand_variable*oper(*(topological_objects[i]) , average);
- }
- if ( dbg )
- {
- std::cerr << "Result 1 : " << result << std::endl;
- getchar();
- }
- //HERE THE NORM SEEMS TO BE MISSING!!
- result = result.abs();
- if ( dbg )
- {
- std::cerr << "Result 2 : " << result << std::endl;
- getchar();
- }
- result = result*(1.0/sqrt( topological_objects.size() ));
- if ( dbg )
- {
- std::cerr << "Result 3 : " << result << std::endl;
- getchar();
- }
- //NEED TO TAKE MAX
- if ( dbg )
- {
- std::cerr << "Result 4 : " << norm(result) << std::endl;
- getchar();
- }
- vector_of_intermediate_characteristics[it_no] = norm(result);
- }
- #ifdef GUDHI_USE_TBB
- }
- );
- #endif
-
-
-
- size_t position_of_quantile = floor(quantile*vector_of_intermediate_characteristics.size());
- if ( position_of_quantile ) --position_of_quantile;
- if ( dbg )
- {
- std::cout << "position_of_quantile : " << position_of_quantile << ", and here is the array : " << std::endl;
- for ( size_t i = 0 ; i != vector_of_intermediate_characteristics.size() ; ++i )
- {
- std::cout << vector_of_intermediate_characteristics[i] << std::endl;
- }
- std::cout << std::endl;
- }
-
- //now we need to sort the vector_of_distances and find the quantile:
- std::nth_element (vector_of_intermediate_characteristics.begin(), vector_of_intermediate_characteristics.begin()+position_of_quantile, vector_of_intermediate_characteristics.end());
- double result = vector_of_intermediate_characteristics[ position_of_quantile ]/(sqrt( topological_objects.size() ));
- if ( dbg )std::cout << "Result : " << result << std::endl;
-
- return result;
-
-}//multiplicative_bootstrap
-
-}//namespace Gudhi_stat
-}//namespace Gudhi
-
-#endif
diff --git a/src/Gudhi_stat/include/gudhi/permutation_test.h b/src/Gudhi_stat/include/gudhi/permutation_test.h
deleted file mode 100644
index 69b0790b..00000000
--- a/src/Gudhi_stat/include/gudhi/permutation_test.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef PERMUTATION_TEST_H
-#define PERMUTATION_TEST_H
-
-
-//concretizations
-#include <vector>
-#include <iostream>
-#include <cstdlib>
-#include <algorithm>
-#include <gudhi/read_persistence_from_file.h>
-
-
-namespace Gudhi
-{
-namespace Gudhi_stat
-{
-
-//TODO change the reading procedures so that they accept the dimension value (by default std::nnumeric_limits<unsigned>::max().
-
-template <typename Representation_of_persistence>
-double permutation_test( const std::vector<Representation_of_persistence*>& data_1 , const std::vector<Representation_of_persistence*>& data_2 , size_t number_of_permutations , double exponent = 1 )
-{
- bool dbg = false;
- try
- {
- Representation_of_persistence av_1;// = new Representation_of_persistence;
- av_1.compute_average( data_1 );
- Representation_of_persistence av_2;// = new Representation_of_persistence;
- av_2.compute_average( data_2 );
- double initial_distance = av_1.distance( av_2 , exponent );
-
-
- double counter = 0;
-
-
- //TODO -- TBB. QUestion, why it uses memory. Where is the leak??
- for ( size_t i = 0 ; i != number_of_permutations ; ++i )
- {
- std::vector<Representation_of_persistence*> all_data;
- all_data.insert(all_data.end() , data_1.begin() , data_1.end() );
- all_data.insert(all_data.end() , data_2.begin() , data_2.end() );
- std::random_shuffle( all_data.begin() , all_data.end() );
-
- std::vector<Representation_of_persistence*> first_part(&all_data[0],&all_data[data_1.size()]);
- std::vector<Representation_of_persistence*> second_part(&all_data[data_1.size()],&all_data[all_data.size()]);
-
-
- Representation_of_persistence av_1;// = new Representation_of_persistence;
- Representation_of_persistence av_2;// = new Representation_of_persistence;
-
- av_1.compute_average( first_part );
- av_2.compute_average( second_part );
- double distance_after_permutations = av_1.distance( av_2 , exponent );
- //delete av_1;
- //delete av_2;
- if ( distance_after_permutations > initial_distance )++counter;
- if ( dbg )
- {
- std::cerr << "Permutation number : " << i << std::endl;
- std::cerr << "distance_after_permutations : " << distance_after_permutations << std::endl;
- std::cerr << "initial_distance : " << initial_distance << std::endl;
- std::cerr << "counter : " << counter << std::endl;
- }
- }
- return counter / (double)number_of_permutations;
- }
- catch (...)
- {
- std::cout << "The data structure do not support the operations that are neccessay for a permutation test (averaging, distances) \n";
- }
- return 0;
-}//permutation_test
-
-}//Gudhi_stat
-}//Gudhi
-
-#endif
diff --git a/src/Gudhi_stat/include/gudhi/time_series_analysis/periodicity_tests.h b/src/Gudhi_stat/include/gudhi/time_series_analysis/periodicity_tests.h
deleted file mode 100644
index 5b2a8edd..00000000
--- a/src/Gudhi_stat/include/gudhi/time_series_analysis/periodicity_tests.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2017 Swansea University (UK)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <iostream>
-#include <fstream>
-
-using namespace std;
-
-namespace Gudhi
-{
-namespace Gudhi_stat
-{
-
-TODO
-
-}//namespace Gudhi_stat
-}//namespace Gudhi
diff --git a/src/Gudhi_stat/include/gudhi/time_series_analysis/sliding_window.h b/src/Gudhi_stat/include/gudhi/time_series_analysis/sliding_window.h
deleted file mode 100644
index c8d53a00..00000000
--- a/src/Gudhi_stat/include/gudhi/time_series_analysis/sliding_window.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2017 Swansea University (UK)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include <cassert>
-
-//for persistent homology computations.
-#include <gudhi/graph_simplicial_complex.h>
-#include <gudhi/distance_functions.h>
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-
-//for alpha complexes. Should that be keept over here???
-//#include <CGAL/Epick_d.h>
-#include <gudhi/Alpha_complex.h>
-
-
-using namespace std;
-
-namespace Gudhi
-{
-namespace Gudhi_stat
-{
-
-using namespace Gudhi;
-using namespace Gudhi::persistent_cohomology;
-
-/**
- * This is an implementation of a sliding window embedding class. Sliding window embedding can be constructed either based on a time series (given as a vector of values), or a real-valued
- * function which is sampled on a nunmber of points (which also give a vector of real values).
- * Given a vector of real values V=[v0,v1,v2,...,v(n-1),vn] and a positive integer M (assumed in this example to be 2) the sliding window embedding of V into R^M is the following point cloud:
- * (v0,v1)
- * (v1,v2)
- * (v2,v3)
- * ...
- * (v(n-1),vn)
- * The construction of sliding window embedding allows to build a point-cloud representation of a time series and later analyze this representation by using topological methods.
- * The class presented below build a representation, and compute persistence of it.
-**/
-
-//construction from time series
-//construction from real value function
-//higher dimensional analaogous?? Shall we design periodicity testing in general, multi-d setting??
-
-typedef Simplex_tree<Simplex_tree_options_fast_persistence> ST;//for persistence computations
-
-class Sliding_window_embedding
-{
-public:
-
- /**
- * This is a basic constructor of a Sliding_window_embedding class. It take as an input a vector of time series values and the dimension of embedding and
- * given those construct an object of a Sliding_window_embedding class.
- **/
- Sliding_window_embedding( const std::vector< double >& ts , unsigned _dimension_of_embedding ):dimension_of_embedding(_dimension_of_embedding)
- {
- this->time_series = std::vector<double>(ts);
- }
-
- /**
- * This is a constructor of a Sliding_window_embedding class. It take as an input a c-style pointer to a function, range of parameters for which the sliding window will be constructed,
- * number of steps in the construction (i.e. number of equally distributed points in the desired domain of the function on which the function will be sampled) and the dimension of the
- * embedding. Given those information it construct an object of a Sliding_window_embedding class.
- **/
- Sliding_window_embedding( double (*function)(double) , double x_min , double x_max , unsigned number_of_steps , unsigned _dimension_of_embedding ):dimension_of_embedding(_dimension_of_embedding)
- {
- assert( x_min < x_max );
- this->time_series.reserve( number_of_steps+1 );
- double x = x_min;
- double dx = ( x_max-x_min )/(double)number_of_steps;
- for ( size_t i = 0 ; i <= number_of_steps ; ++i )
- {
- this->time_series.push_back( function(x) );
- x += dx;
- }
- }
-
- /**
- * This is a constructor of a Sliding_window_embedding class. It take as an input a filename of file with the values and the dimension of embedding and
- * given those construct an object of a Sliding_window_embedding class.
- * We assume that the input file is a text file containing numbers separated with a white space.
- **/
- Sliding_window_embedding( const char* filename , unsigned _dimension_of_embedding ):dimension_of_embedding(_dimension_of_embedding)
- {
- ifstream inputFile( filename );
- //read the file and populate this->time_series
- if (inputFile)
- {
- double value;
- while ( inputFile >> value )
- {
- this->time_series.push_back(value);
- }
- }
- inputFile.close();
- }
-
- /**
- * This procedure create a point cloud from a sliding window embedding.
- **/
- std::vector< std::vector<double> > create_point_cloud()
- {
- bool dbg = false;
- std::vector< std::vector<double> > result;
- if ( this->time_series.size() < this->dimension_of_embedding )return result;
- result.reserve( this->time_series.size() - this->dimension_of_embedding );
- for ( size_t i = 0 ; i <= this->time_series.size() - this->dimension_of_embedding ; ++i )
- {
- std::vector<double> point( this->dimension_of_embedding );
- for ( size_t j = 0 ; j != this->dimension_of_embedding ; ++j )
- {
- point[j] = this->time_series[i+j];
- }
- result.push_back( point );
- if ( dbg )
- {
- std::cerr << "Adding point : ";
- for ( size_t k = 0 ; k != point.size() ; ++k )
- {
- std::cerr << point[k] << " ";
- }
- std::cerr << std::endl;
- }
- }
- return result;
- }
-
- /**
- * This procedure store sliding window embedding point cloud in a file.
- **/
- void create_point_cloud( const char* filename )
- {
- ofstream out( filename );
- std::vector< std::vector<double> > point_cloud = this->create_point_cloud();
- for ( size_t i = 0 ; i != point_cloud.size() ; ++i )
- {
- for ( size_t j = 0 ; j != point_cloud[i].size() ; ++j )
- {
- out << point_cloud[i][j] << " ";
- }
- out << endl;
- }
- out.close();
- }
-
-
- /**
- * This procedure compute persistence of the sliding window embedding point cloud by using Vietoris-Rips filtration.
- **/
-
- //persistent_cohomology::Persistent_cohomology<ST, Field_Zp >
- void compute_persistence_of_Vietoris_Rips_complex( double threshold , unsigned dim_max , unsigned field_coef = 2 , double min_persistence = 0 )
- {
- //compute points of the sliding window embedding.
- std::vector< std::vector< double > > points = this->create_point_cloud();
- /*
- // Compute the proximity graph of the points.
- Graph_t prox_graph = compute_proximity_graph(points, threshold , euclidean_distance< std::vector< double > >);
-
- // Construct the Rips complex in a Simplex Tree.
- ST st;
- // insert the proximity graph in the simplex tree.
- st.insert_graph(prox_graph);
- // expand the graph until dimension dim_max.
- st.expansion(dim_max);
-
- std::cout << "The complex contains " << st.num_simplices() << " simplices \n";
- std::cout << " and has dimension " << st.dimension() << " \n";
-
- // Sort the simplices in the order of the filtration.
- st.initialize_filtration();
-
- // Compute the persistence diagram of the complex.
- persistent_cohomology::Persistent_cohomology<ST, Field_Zp > pcoh(st);
- // initializes the coefficient field for homology.
- pcoh.init_coefficients( field_coef );
-
- //compute persistent cohomology.
- pcoh.compute_persistent_cohomology(min_persistence);
-
- //return pcoh;
- pcoh.output_diagram();
- */
- }//compute_persistence_of_Vietoris_Rips_complex
-
- /**
- * This procedure compute persistence of the sliding window embedding point cloud by using Alpha complex filtration.
- **/
-
- /*persistent_cohomology::Persistent_cohomology<ST, Field_Zp >*/
- void compute_persistence_of_Alpha_complex( double threshold , unsigned dim_max , unsigned field_coef = 2 , double min_persistence = 0 )
- {
- /*
- //first we need to take out points and convert it to CGAL points.
- std::vector< std::vector< double > > points = this->create_point_cloud();
- typedef CGAL::Epick_d< CGAL::Dimension_tag<2> > Kernel;
- std::vector< Kernel::Point_d > Vector_of_points;
- Vector_of_points.reserve( points.size() );
- for ( size_t i = 0 ; i != points.size() ; ++i )
- {
- Vector_of_points.push_back( Kernel::Point_d(points[i]) );
- }
- using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >;
- Gudhi::alpha_complex::Alpha_complex<Kernel> alpha_complex_from_file(off_file_points, alpha_square_max_value);
-
- // ----------------------------------------------------------------------------
- // Display information about the alpha complex
- // ----------------------------------------------------------------------------
- std::cout << "Alpha complex is of dimension " << alpha_complex_from_file.dimension() <<
- " - " << alpha_complex_from_file.num_simplices() << " simplices - " <<
- alpha_complex_from_file.num_vertices() << " vertices." << std::endl;
-
- // Sort the simplices in the order of the filtration
- alpha_complex_from_file.initialize_filtration();
-
- std::cout << "Simplex_tree dim: " << alpha_complex_from_file.dimension() << std::endl;
- // Compute the persistence diagram of the complex
- Gudhi::persistent_cohomology::Persistent_cohomology< Gudhi::alpha_complex::Alpha_complex<Kernel>,
- Gudhi::persistent_cohomology::Field_Zp > pcoh(alpha_complex_from_file);
- // initializes the coefficient field for homology
- pcoh.init_coefficients(coeff_field_characteristic);
-
- pcoh.compute_persistent_cohomology(min_persistence
-
- return pcoh;
-
- // Output the diagram in filediag
- if (output_file_diag.empty())
- {
- pcoh.output_diagram();
- }
- else
- {
- std::cout << "Result in file: " << output_file_diag << std::endl;
- std::ofstream out(output_file_diag);
- pcoh.output_diagram(out);
- out.close();
- }
- //here we shoud merge it with what Vincent did to write down the pairs, and we will simply return those pairs.
- */
- }//compute_persistence_of_Alpha_complex
-
-
-
-private:
- std::vector< double > time_series;
- unsigned dimension_of_embedding;
-};
-
-}//namespace Gudhi_stat
-}//namespace Gudhi
diff --git a/src/Gudhi_stat/include/gudhi/topological_process.h b/src/Gudhi_stat/include/gudhi/topological_process.h
deleted file mode 100644
index ee8478ed..00000000
--- a/src/Gudhi_stat/include/gudhi/topological_process.h
+++ /dev/null
@@ -1,420 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef TOPOLOGICAL_PROCESS_H
-#define TOPOLOGICAL_PROCESS_H
-
-
-//concretizations
-#include <gudhi/Vector_distances_in_diagram.h>
-#include <gudhi/Persistence_landscape.h>
-#include <gudhi/Persistence_landscape_on_grid.h>
-#include <gudhi/Persistence_heat_maps.h>
-#include <vector>
-#include <limits>
-
-//extras
-#include <gudhi/common_persistence_representations.h>
-
-namespace Gudhi
-{
-namespace Persistence_representations
-{
-
-
-//TODO, change reading procedures so that they also accept the value of dimension.
-
-//over here we will need a few version of construct_representation_from_file procedure, since different representations may require different parameters. This is a procedure that in my
-//oppinion cannot be standarize, since construction of representation cannot. But, the remaining part of the code in my opinion is free from any details of representation.
-
-
-//the reason I am separating the process of getting the intervals from the process of consstructing the represnetation is the following: for soem representations, we may need to ahve the same
-//scale. To determine the scale, we need to know all the intervals before. So, we read the intervals first, then if needed, process them, to get the parametersof the representation,
-//and only then construct the representations.
-std::vector< std::vector< std::pair< double , double > > > read_persistence_pairs_from_file_with_names_of_files( const char* filename )
-{
- bool dbg = false;
- std::vector< std::vector< std::pair< double , double > > > result;
-
- std::vector< std::string > files = readFileNames( filename );
-
- std::cout << "Here are the filenames in the file : " << filename << std::endl;
- for ( size_t i = 0 ; i != files.size() ; ++i )
- {
- std::cout << files[i] << std::endl;
- }
-
- for ( size_t i = 0 ; i != files.size() ; ++i )
- {
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( files[i].c_str() );
- result.push_back( diag );
- if ( dbg )
- {
- std::cerr << "Here is a diagram from a file : " << files[i].c_str() << std::endl;
- for ( size_t aa = 0 ; aa != diag.size() ; ++aa )
- {
- std::cout << diag[aa].first << " " << diag[aa].second << std::endl;
- }
- getchar();
- }
- }
- return result;
-}
-
-//When workign with time varying data, we tpically have a collection of files with intervals to produce one process. The intervals from all the files that constitute a single process can be read with
-//the read_persistence_pairs_from_file_with_names_of_files procedure.
-//But then, we also may need to read the persistence intervals of collection of proesses we may want to read the intervals first. This is what the procedre
-std::vector< std::vector< std::vector< std::pair< double , double > > > > read_persistence_pairs_from_files_with_names_of_files( const std::vector<const char*>& filenames )
-{
- std::vector< std::vector< std::vector< std::pair< double , double > > > > result;
- result.reserve( filenames.size() );
- for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
- {
- result.push_back( read_persistence_pairs_from_file_with_names_of_files( filenames[file_no] ) );
- }
- return result;
-}//read_persistence_pairs_from_files_with_names_of_files
-
-
-std::pair< std::pair< double,double > , std::pair< double,double > > find_x_and_y_ranges_of_intervals( const std::vector< std::vector< std::pair< double , double > > >& intervals_from_file )
-{
- double min_x = std::numeric_limits< double >::max();
- double max_x = -std::numeric_limits< double >::max();
- double min_y = std::numeric_limits< double >::max();
- double max_y = -std::numeric_limits< double >::max();
- for ( size_t i = 0 ; i != intervals_from_file.size() ; ++i )
- {
- for ( size_t j = 0 ; j != intervals_from_file[i].size() ; ++j )
- {
- if ( min_x > intervals_from_file[i][j].first )min_x = intervals_from_file[i][j].first;
- if ( max_x < intervals_from_file[i][j].first )max_x = intervals_from_file[i][j].first;
-
- if ( min_y > intervals_from_file[i][j].second )min_y = intervals_from_file[i][j].second;
- if ( max_y < intervals_from_file[i][j].second )max_y = intervals_from_file[i][j].second;
- }
- }
- return std::make_pair( std::make_pair( min_x,max_x ) , std::make_pair( min_y,max_y ) );
-}//find_x_and_y_ranges_of_intervals
-
-
-std::pair< std::pair< double,double > , std::pair< double,double > > find_x_and_y_ranges_of_intervals( const std::vector< std::vector< std::vector< std::pair< double , double > > > >& intervals_from_files )
-{
- double min_x = std::numeric_limits< double >::max();
- double max_x = -std::numeric_limits< double >::max();
- double min_y = std::numeric_limits< double >::max();
- double max_y = -std::numeric_limits< double >::max();
- for ( size_t i = 0 ; i != intervals_from_files.size() ; ++i )
- {
- std::pair< std::pair< double,double > , std::pair< double,double > > ranges = find_x_and_y_ranges_of_intervals( intervals_from_files[i] );
- if ( min_x > ranges.first.first ) min_x = ranges.first.first;
- if ( max_x < ranges.first.second ) max_x = ranges.first.second;
- if ( min_y > ranges.second.first ) min_y = ranges.second.first;
- if ( max_y < ranges.second.second ) max_y = ranges.second.second;
- }
- return std::make_pair( std::make_pair( min_x,max_x ) , std::make_pair( min_y,max_y ) );
-}
-
-
-template <typename Representation>
-std::vector< Representation* > construct_representation_from_file( const char* filename )
-{
- std::vector< std::vector< std::pair< double , double > > > intervals_from_file = read_persistence_pairs_from_file_with_names_of_files( filename );
- std::vector< Representation* > result( intervals_from_file.size() );
- for ( size_t i = 0 ; i != intervals_from_file.size() ; ++i )
- {
- Representation* l = new Representation( intervals_from_file[i] );
- result[i] = l;
- }
- return result;
-}
-
-//this one can be use for Persistence_intervals.h and Persistence_landscape.h
-template <typename Representation>
-std::vector< Representation* > construct_representation_from_file( const std::vector< std::vector< std::pair< double , double > > >& intervals_from_file)
-{
-
- std::vector< Representation* > result( intervals_from_file.size() );
- for ( size_t i = 0 ; i != intervals_from_file.size() ; ++i )
- {
- Representation* l = new Representation( intervals_from_file[i] );
- result[i] = l;
- }
- return result;
-}
-
-//this one can be use for Persistence_heat_maps.h
-template <typename Representation>
-std::vector< Representation* > construct_representation_from_file( const std::vector< std::vector< std::pair< double , double > > >& intervals_from_file ,
- std::vector< std::vector<double> > filter = create_Gaussian_filter(5,1),
- bool erase_below_diagonal = false ,
- size_t number_of_pixels = 1000 ,
- double min_ = std::numeric_limits<double>::max() , double max_ = std::numeric_limits<double>::max() )
-{
- std::vector< Representation* > result( intervals_from_file.size() );
- for ( size_t i = 0 ; i != intervals_from_file.size() ; ++i )
- {
- Representation* l = new Representation( intervals_from_file[i] , filter , erase_below_diagonal , number_of_pixels , min_ , max_ );
- result[i] = l;
- }
- return result;
-}
-
-//this one can be use for Persistence_landscape_on_grid.h
-template <typename Representation>
-std::vector< Representation* > construct_representation_from_file( const std::vector< std::vector< std::pair< double , double > > >& intervals_from_file,
- double grid_min_ , double grid_max_ , size_t number_of_points_
-)
-{
- std::vector< Representation* > result( intervals_from_file.size() );
- for ( size_t i = 0 ; i != intervals_from_file.size() ; ++i )
- {
- Representation* l = new Representation( intervals_from_file[i] , grid_min_ , grid_max_ , number_of_points_ );
- result[i] = l;
- }
- return result;
-}
-
-
-//this one can be use for Vector_distances_in_diagram.h
-template <typename Representation>
-std::vector< Representation* > construct_representation_from_file( const std::vector< std::vector< std::pair< double , double > > >& intervals_from_file,
- size_t where_to_cut
-)
-{
- std::vector< Representation* > result( intervals_from_file.size() );
- for ( size_t i = 0 ; i != intervals_from_file.size() ; ++i )
- {
- Representation* l = new Representation( intervals_from_file[i] , where_to_cut );
- result[i] = l;
- }
- return result;
-}
-
-
-template <typename Representation>
-class Topological_process
-{
-public:
- Topological_process(){};
- ~Topological_process()
- {
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- delete this->data[i];
- }
- }
-
- Topological_process( const std::vector< Representation* >& data_ ):data(data_){}
- double distance( const Topological_process& second , double exponent = 1 )
- {
- if ( this->data.size() != second.data.size() )
- {
- throw "Incompatible lengths of topological processes, we cannot compute the distance in this case \n";
- }
- double result = 0;
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- result += this->data[i]->distance( *second.data[i] , exponent );
- }
- return result;
- }
-
- void compute_average( const std::vector< Topological_process* >& to_average )
- {
- //since we will substitute whatever data we have in this object with an average, we clear the data in this object first:
- this->data.clear();
- //then we need to check if all the topological processes in the vector to_average have the same length.
- if ( to_average.size() == 0 )return;
- for ( size_t i = 1 ; i != to_average.size() ; ++i )
- {
- if ( to_average[0]->data.size() != to_average[i]->data.size() )
- {
- throw "Incompatible lengths of topological processes, the averages cannot be computed \n";
- }
- }
-
- this->data.reserve( to_average[0]->data.size() );
-
- for ( size_t level = 0 ; level != to_average[0]->data.size() ; ++level )
- {
- //now we will be averaging the level level:
- std::vector< Representation* > to_average_at_this_level;
- to_average_at_this_level.reserve( to_average.size() );
- for ( size_t i = 0 ; i != to_average.size() ; ++i )
- {
- to_average_at_this_level.push_back( to_average[i]->data[level] );
- }
- Representation* average_representation_on_this_level = new Representation;
- average_representation_on_this_level->compute_average( to_average_at_this_level );
- this->data.push_back( average_representation_on_this_level );
- }
- }
-
- std::pair< double , double > get_x_range()const
- {
- double min_x = std::numeric_limits< double >::max();
- double max_x = -std::numeric_limits< double >::max();
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- std::pair< double , double > xrange = this->data[i]->get_x_range();
- if ( min_x > xrange.first )min_x = xrange.first;
- if ( max_x < xrange.second )max_x = xrange.second;
- }
- return std::make_pair( min_x , max_x );
- }
-
- std::pair< double , double > get_y_range()const
- {
- double min_y = std::numeric_limits< double >::max();
- double max_y = -std::numeric_limits< double >::max();
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- std::pair< double , double > yrange = this->data[i]->get_y_range();
- if ( min_y > yrange.first )min_y = yrange.first;
- if ( max_y < yrange.second )max_y = yrange.second;
- }
- return std::make_pair( min_y , max_y );
- }
-
- /**
- * The procedure checks if the ranges of data are the same for all of them.
- **/
- bool are_the_data_aligned()const
- {
- if ( this->data.size() == 0 )return true;//empty collection is aligned
- std::pair< double , double > x_range = this->data[0]->get_x_range();
- std::pair< double , double > y_range = this->data[0]->get_y_range();
- for ( size_t i = 1 ; i != this->data.size() ; ++i )
- {
- if ( (x_range != this->data[i]->get_x_range()) || (y_range != this->data[i]->get_y_range()) )
- {
- return false;
- }
- }
- return true;
- }
-
-
- //scalar products?
- //confidence bounds?
-
- void plot( const char* filename , size_t delay = 30 , double min_x = std::numeric_limits<double>::max() , double max_x = std::numeric_limits<double>::max() , double min_y = std::numeric_limits<double>::max() , double max_y = std::numeric_limits<double>::max() )
- {
- std::vector< std::string > filenames;
- //over here we need to
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- std::stringstream ss;
- ss << filename << "_" << i;
- if ( ( min_x != max_x ) && ( min_y != max_y ) )
- {
- //in this case, we set up the uniform min and max values for pciture
- //this->data[i]->plot( ss.str().c_str() , min_x , max_x , min_y , max_y );
- }
- else
- {
- //in this case, we DO NOT set up the uniform min and max values for pciture
- this->data[i]->plot( ss.str().c_str() );
- }
- ss << "_GnuplotScript";
- filenames.push_back( ss.str() );
- }
- //and now we have to call it somehow for all the files. We will create a script that will call all the other scripts and ceate a sequence of jpg/png files.
-
-
- std::stringstream gif_file_name;
- gif_file_name << filename << ".gif";
- std::stringstream gif_gnuplot_script_file_name;
- gif_gnuplot_script_file_name << filename << "_gif_gnuplot_script";
-
- std::ofstream out;
- out.open( gif_gnuplot_script_file_name.str().c_str() );
- out << "set terminal gif animate delay " << delay << std::endl;
- out << "set output '" << gif_file_name.str() << "'" << std::endl;
- if ( min_x != max_x )
- {
- out << "set xrange [" << min_x << ":" << max_x << "]" << std::endl;
- out << "set yrange [" << min_y << ":" << max_y << "]" << std::endl;
- }
-
- for ( size_t i = 0 ; i != filenames.size() ; ++i )
- {
- out << " load '" << filenames[i] << "'" << std::endl;
- }
- out.close();
-
- std::cout << std::endl << std::endl << std::endl << "Open gnuplot terminal and type load '" << gif_gnuplot_script_file_name.str() << "' to create an animated gif \n";
- }//plot
-
- /**
- * This procedure compute veliocity of the data in the topological process. The veliocity is devine as distance (of persistence information) over time. In this implementation we assume that
- * the time points when the persistence information is sampled is equally distributed in time. Therefore that we may assume that time between two constitive persistence information is 1, in which
- * case veliocity is just distance between two constitutitve diagrams.
- * There is an obvious intuition behinf the veliocity: large veliocity means large changes in the topoogy.
- **/
- std::vector< double > compute_veliocity( double exponent = 1 )
- {
- std::vector< double > result;
- result.reserve( this->data.size()-1 );
- for ( size_t i = 0 ; i != this-data.size() - 1 ; ++i )
- {
- result.push_back( this->data[i]->distance( *this->data[i+1] , exponent ) );
- }
- return result;
- }
-
- /**
- * This procedure compute veliocity of the data in the topological process. Accleration is defined as an increase of veliocity over time. In this implementation we assume that
- * the time points when the persistence information is sampled is equally distributed in time. Therefore that we may assume that time between two constitive persistence information is 1, in which
- * case acceleration is simply an increase of veliocity (the number may be negative).
- * We have two versions of this procedure:
- * The first one compute the acceleration based on the raw data (computations of veliocity are need to be done first, and later the informationa about veliocity is lost).
- * The second one takes as an input the vector of veliocities, and return the vector of acceleration.
- * There is an obvious intuition behid the acceleration: large (up to absolute value) value of acceleration implies large changes in the topology.
- **/
- std::vector< double > compute_acceleration( const std::vector< double >& veliocity )
- {
- std::vector< double > acceleration;
- acceleration.reserve( veliocity.size() - 1 );
- for ( size_t i = 0 ; i != veliocity.size()-1 ; ++i )
- {
- acceleration.push_back( veliocity[i+1]-veliocity[i] );
- }
- return acceleration;
- }
- std::vector< double > compute_acceleration( double exponent = 1 )
- {
- return this->compute_acceleration( this->compute_veliocity( exponent ) );
- }
-
-
- std::vector< Representation* > get_data(){return this->data;}
-private:
- std::vector< Representation* > data;
-};
-
-
-
-}//Gudhi_stat
-}//Gudhi
-
-#endif
diff --git a/src/Gudhi_stat/utilities/CMakeLists.txt b/src/Gudhi_stat/utilities/CMakeLists.txt
deleted file mode 100644
index 235d5d2e..00000000
--- a/src/Gudhi_stat/utilities/CMakeLists.txt
+++ /dev/null
@@ -1,53 +0,0 @@
-cmake_minimum_required(VERSION 2.6)
-project(GUDHI_STAT)
-
-
-
-#some stat libraries:
-add_executable ( permutation_test permutation_test.cpp )
-target_link_libraries(permutation_test ${Boost_SYSTEM_LIBRARY})
-
-#add_executable ( topological_process topological_process.cpp )
-#target_link_libraries(topological_process ${Boost_SYSTEM_LIBRARY})
-
-#add_executable ( topological_process_2 topological_process_2.cpp )
-#target_link_libraries(topological_process_2 ${Boost_SYSTEM_LIBRARY})
-
-add_executable ( Hausdorff_subsampling Hausdorff_subsampling.cpp )
-if (TBB_FOUND)
-target_link_libraries(Hausdorff_subsampling ${TBB_LIBRARIES})
-endif(TBB_FOUND)
-target_link_libraries(Hausdorff_subsampling ${Boost_SYSTEM_LIBRARY})
-
-
-add_executable ( Landscape_bootstrap Landscape_bootstrap.cpp )
-if (TBB_FOUND)
-target_link_libraries(Landscape_bootstrap ${TBB_LIBRARIES})
-endif(TBB_FOUND)
-target_link_libraries(Landscape_bootstrap ${Boost_SYSTEM_LIBRARY})
-
-
-add_executable ( Multiplicative_bootstrap Multiplicative_bootstrap.cpp )
-if (TBB_FOUND)
-target_link_libraries(Multiplicative_bootstrap ${TBB_LIBRARIES})
-endif(TBB_FOUND)
-target_link_libraries(Multiplicative_bootstrap ${Boost_SYSTEM_LIBRARY})
-
-
-
-
-#just for Pawel's tests:
-#add_executable ( NN_classification NN_classification.cpp )
-#target_link_libraries(NN_classification ${Boost_SYSTEM_LIBRARY})
-#
-#add_executable ( compute_distance_between_vectors compute_distance_between_vectors.cpp )
-#target_link_libraries(compute_distance_between_vectors ${Boost_SYSTEM_LIBRARY})
-
-
-if(CGAL_FOUND)
- add_executable ( sliding_window_embedding sliding_window_embedding.cpp )
- target_link_libraries(sliding_window_embedding ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
- if (TBB_FOUND)
- target_link_libraries(sliding_window_embedding ${TBB_LIBRARIES})
- endif(TBB_FOUND)
-endif(CGAL_FOUND)
diff --git a/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp b/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
deleted file mode 100644
index 44de1029..00000000
--- a/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <gudhi/Hausdorff_distances.h>
-#include <gudhi/bootstrap.h>
-#include <gudhi/read_persistence_from_file.h>
-#include <gudhi/persistence_vectors.h>
-
-
-using namespace Gudhi;
-using namespace Gudhi::Persistence_representations;
-using namespace Gudhi::Gudhi_stat;
-
-
-
-int main( int argc , char** argv )
-{
- std::cout << "The parameters of this program are : " << std::endl;
- std::cout << "(a) a name of a file with points," << std:: endl;
- std::cout << "(b) a number of repetitions of bootstrap (integer)," << std::endl;
- std::cout << "(c) a size of subsample (integer, smaller than the number of points," << std::endl;
- std::cout << "(d) a quantile (real number between 0 and 1. If you do not know what to set, set it to 0.95." << std::endl;
- if ( argc != 5 )
- {
- std::cerr << "Wrong number of parameters, the program will now terminate.\n";
- return 1;
- }
-
- const char* filename = argv[1];
- size_t number_of_repetitions_of_subsampling = (size_t)atoi( argv[2] );
- size_t size_of_subsample = (size_t)atoi( argv[3] );
- double quantile = atof( argv[4] );
-
- std::cout << "Now we will read points from the file : " << filename << " and then perform " << number_of_repetitions_of_subsampling << " times the subsampling on it by choosing subsample of a size " << size_of_subsample << std::endl;
-
- std::vector< std::vector< double > > points = read_numbers_from_file_line_by_line( filename );
- /*
- std::vector< std::vector< double > > points;
- std::vector< double > point1(2);
- point1[0] = -1;
- point1[1] = 0;
- std::vector< double > point2(2);
- point2[0] = 1;
- point2[1] = 0;
- std::vector< double > point3(2);
- point3[0] = -1;
- point3[1] = 3;
- std::vector< double > point4(2);
- point4[0] = 1;
- point4[1] = 3;
- points.push_back( point1 );
- points.push_back( point2 );
- points.push_back( point3 );
- points.push_back( point4 );
- 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 >( 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:
- 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 >( points );
- Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points );
- identity< std::vector<size_t> > identity_char;
-
-
- double max = -1;
- for ( size_t i = 0 ; i != all_to_all_distance_matrix_between_points.size() ; ++i )
- {
- double min = 10000000;
- for ( size_t j = 0 ; j != all_to_all_distance_matrix_between_points.size() ; ++j )
- {
- double distance = 0;
- if ( i > j )
- {
- distance = all_to_all_distance_matrix_between_points[i][j];
- }
- else
- {
- if ( i < j )distance = all_to_all_distance_matrix_between_points[j][i];
- }
- if ( (distance < min)&&(distance != 0) )min = distance;
- }
- std::cerr << "min : " << min << std::endl;
- //getchar();
- if ( min > max )max = min;
- }
- std::cerr << "Max element in distance matrix : " << max << std::endl;
- getchar();
-
-// 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;
-
-
-
-
-
- //and now we can run the real bootstrap.
- //template < typename PointCloudCharacteristics , typename CharacteristicFunction , typename DistanceBetweenPointsCharacteristics >
- //In this case, the PointCloudCharacteristics is just a vector of numbers of points (in a order fixed on points vector).
- //CharacteristicFunction is just identity, transforming std::vector< size_t > to itself.
- //DistanceBetweenPointsCharacteristics is the place were all happens. This class have the information about the coordinates of the points, and allows to compute a Hausdorff distance between
- //the collection of all points, and the subsample.
- double result = bootstrap<
- std::vector< size_t > , //PointCloudCharacteristics
- identity< std::vector<size_t> > , //CharacteristicFunction
- Hausdorff_distance_between_subspace_and_the_whole_metric_space //DistanceBetweenPointsCharacteristics. This function have the information about point's coordinates.
- >
- ( points.size() , identity_char , distance , number_of_repetitions_of_subsampling , size_of_subsample , quantile );
-
- std::cout << "result of the subsampling : " << 2*result << std::endl;
-
-
- return 0;
-}
diff --git a/src/Gudhi_stat/utilities/Landscape_bootstrap.cpp b/src/Gudhi_stat/utilities/Landscape_bootstrap.cpp
deleted file mode 100644
index a2ca93a9..00000000
--- a/src/Gudhi_stat/utilities/Landscape_bootstrap.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-//stat part:
-#include <gudhi/Hausdorff_distances.h>
-#include <gudhi/bootstrap.h>
-#include <gudhi/Persistence_landscape.h>
-#include <gudhi/read_persistence_from_file.h>
-#include <gudhi/persistence_vectors.h>
-//persistence part:
-#include <gudhi/reader_utils.h>
-#include <gudhi/Rips_complex.h>
-#include <gudhi/distance_functions.h>
-#include <gudhi/Simplex_tree.h>
-#include <gudhi/Persistent_cohomology.h>
-
-
-using namespace Gudhi::Gudhi_stat;
-using namespace Gudhi::Persistence_representations;
-using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape;
-
-typedef int Vertex_handle;
-//typedef double Filtration_value;
-
-
-//if this variable is -1, then the infinite interals are ignored. If not, they infinite values are replaced with what_to_replace_infinite_intervals_with:
-double what_to_replace_infinite_intervals_with = -1;
-
-
-
-class compute_persistence_landscape_of_a_point_cloud_in_certain_dimension
-{
-public:
- compute_persistence_landscape_of_a_point_cloud_in_certain_dimension( std::vector< std::vector< double > >& points_ , int dimension , double threshold_ , int coeficient_field_ = 11 , double min_persistence_ = 0 ):dim( dimension ),points(points_),threshold(threshold_),coeficient_field(coeficient_field_),min_persistence(min_persistence_){}
- //This function takes a vector of indices (numbers_to_sample). It will select the points from this->points having those indices, construct Rips complex and persistence intervals based on this.
- //Then it will filter the intervals to find only those in the dimension this->dim, and construct a persistence landascape based on this. Thie will be the result of the procedure.
- Persistence_landscape operator()( std::vector< size_t > numbers_to_sample )
- {
- bool dbg = false;
- //take the subsampled points:
- std::vector< std::vector< double > > points_in_subsample;
- points_in_subsample.reserve( numbers_to_sample.size() );
- for ( size_t i = 0 ; i != numbers_to_sample.size() ; ++i )
- {
- points_in_subsample.push_back( this->points[ numbers_to_sample[i] ] );
- }
-
- using Stree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
- using Filtration_value = Stree::Filtration_value;
- using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>;
- //construct a Rips complex based on it and compute its persistence:
- Rips_complex rips_complex(points_in_subsample, this->threshold, Euclidean_distance());
- // Construct the Rips complex in a Simplex Tree
- Stree st;
- // expand the graph until dimension dim_max
- rips_complex.create_complex(st, this->dim + 1);
- // Compute the persistence diagram of the complex
- Gudhi::persistent_cohomology::Persistent_cohomology<Stree, Gudhi::persistent_cohomology::Field_Zp > pcoh(st);
- // initializes the coefficient field for homology
- pcoh.init_coefficients( this->coeficient_field );
- pcoh.compute_persistent_cohomology(this->min_persistence);
- auto persistence_pairs = pcoh.get_persistent_pairs();
- //From the persistence take only this in the dimension this->dim:
-
- if ( dbg )std::cerr << "Here are the persistence pairs :\n";
- std::vector< std::pair< double,double > > persistence_in_fixed_dimension;
- for ( size_t i = 0 ; i != persistence_pairs.size() ; ++i )
- {
- if ( st.dimension( std::get<0>(persistence_pairs[i]) ) == this->dim )
- {
- double birth = st.filtration( std::get<0>(persistence_pairs[i]) );
- double death = st.filtration( std::get<1>(persistence_pairs[i]) );
-
- if ( std::get<1>(persistence_pairs[i]) != st.null_simplex() )
- {
- //finite interval
- persistence_in_fixed_dimension.push_back( std::pair<double,double>( birth , death ) );
- if (dbg){std::cout << "birth : " << birth << " , death : " << death << std::endl;}
- }
- else
- {
- //infinite interval
- if ( what_to_replace_infinite_intervals_with != -1 )
- {
- persistence_in_fixed_dimension.push_back( std::pair<double,double>( birth , what_to_replace_infinite_intervals_with ) );
- if (dbg){std::cout << "birth : " << birth << " , death : " << what_to_replace_infinite_intervals_with << std::endl;}
- }
- }
- }
- }
- if ( dbg )std::cerr << "Persistence pairs computed \n";
- //Construct and return the persistence landscape:
- return Persistence_landscape( persistence_in_fixed_dimension );
- }
-private:
- int dim;
- std::vector< std::vector< double > >& points;
- double threshold;
- int coeficient_field;
- double min_persistence;
-};
-
-class distance_between_landscapes
-{
-public:
- distance_between_landscapes( double exponent_ ):exponent(exponent_){}
- double operator()( const Persistence_landscape& first , const Persistence_landscape& second )
- {
- return first.distance( second, this->exponent );
- }
-private:
- double exponent;
-};
-
-
-int main( int argc , char** argv )
-{
- std::cout << "The parameters of this program are : " << std::endl;
- std::cout << "(1) a name of a file with points," << std:: endl;
- std::cout << "(2) a number of repetitions of bootstrap (integer)," << std::endl;
- std::cout << "(3) a size of subsample (integer, smaller than the number of points. " << std::endl;
- std::cout << "(4) An real value p such that L^p distance is going to be computed. \n";
- std::cout << "(5) A dimension of persistence that is to be taken into account (positive integer) \n";
- std::cout << "(6) A maximal diameter to which complex is to be grown (positive integer) \n";
- std::cout << "(d) a quantile (real number between 0 and 1. If you do not know what to set, set it to 0.95." << std::endl;
- if ( argc != 8 )
- {
- std::cerr << "Wrong number of parameters, the program will now terminate.\n";
- return 1;
- }
-
- const char* filename = argv[1];
- size_t number_of_repetitions_of_bootstrap = (size_t)atoi( argv[2] );
- size_t size_of_subsample = (size_t)atoi( argv[3] );
- double p = atoi( argv[4] );
- int dimension = atoi( argv[5] );
- double threshold = atof( argv[6] );
- double quantile = atof( argv[7] );
-
- std::cout << "Now we will read points from the file : " << filename << " and then perform " << number_of_repetitions_of_bootstrap << " times the bootstrap on it by choosing subsample of a size " << size_of_subsample << std::endl;
-
- std::vector< std::vector< double > > points = Gudhi::Persistence_representations::read_numbers_from_file_line_by_line( filename );
-
- std::cout << "Read : " << points.size() << " points.\n";
-
- distance_between_landscapes distance( p );//L^p distance.
- compute_persistence_landscape_of_a_point_cloud_in_certain_dimension characteristic_fun( points , dimension , threshold );
-
- //and now we can run the real bootstrap.
- //template < typename PointCloudCharacteristics , typename CharacteristicFunction , typename DistanceBetweenPointsCharacteristics >
- //In this case, the PointCloudCharacteristics is just a vector of numbers of points (in a order fixed on points vector).
- //CharacteristicFunction is just identity, transforming std::vector< size_t > to itself.
- //DistanceBetweenPointsCharacteristics is the place were all happens. This class hace the information about the coordinates of the points, and allows to compute a Hausdorff distance between
- //the collection of all points, and the subsample.
- double result = Gudhi::Gudhi_stat::bootstrap<
- Persistence_landscape , //PointCloudCharacteristics, persistence landascapes constructed based on vector of
- //pairs of birth--death values in a cartain dimension.
- compute_persistence_landscape_of_a_point_cloud_in_certain_dimension , //CharacteristicFunction, in this case, we will need to compute persistence in a certain dimension.
- distance_between_landscapes //DistanceBetweenPointsCharacteristics. In this case
- >
- ( points.size() , characteristic_fun , distance , number_of_repetitions_of_bootstrap , size_of_subsample , quantile );
-
- std::cout << "result of bootstrap : " << result << std::endl;
-
-
- return 0;
-}
diff --git a/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp b/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
deleted file mode 100644
index 8949fba1..00000000
--- a/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <gudhi/Hausdorff_distances.h>
-#include <gudhi/multiplicative_bootstrap.h>
-#include <gudhi/read_persistence_from_file.h>
-#include <gudhi/persistence_vectors.h>
-
-using namespace Gudhi;
-using namespace Gudhi::Gudhi_stat;
-using namespace Gudhi::Persistence_representations;
-
-
-
-int main( int argc , char** argv )
-{
- std::cout << "The parameters of this program are : " << std::endl;
- std::cout << "(a) a name of a file with names of files with persistence diagrams," << std:: endl;
- std::cout << "(b) a number of repetitions of bootstrap (integer)," << std::endl;
- std::cout << "(c) a quantile (real number between 0 and 1. If you do not know what to set, set it to 0.95." << std::endl;
- if ( argc != 4 )
- {
- std::cerr << "Wrong number of parameters, the program will now terminate.\n";
- return 1;
- }
-
- const char* file_with_filenames = argv[1];
- size_t number_of_repetitions_of_bootstrap = (size_t)atoi( argv[2] );
- double quantile = atof( argv[3] );
-
- std::vector< std::string > filenames = readFileNames( file_with_filenames );
- std::vector< Persistence_landscape* > collection_of_landscapes( filenames.size() );
- for ( size_t i = 0 ; i != filenames.size() ; ++i )
- {
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( filenames[i].c_str() );
- collection_of_landscapes[i] = new Persistence_landscape( diag );
- }
-
- //now we can run the bootstrap:
- difference_of_objects<Persistence_landscape> diff;
- norm_of_objects<Persistence_landscape> norm;
-
- double result =
- multiplicative_bootstrap< Persistence_landscape , difference_of_objects<Persistence_landscape> , norm_of_objects<Persistence_landscape> >
- ( collection_of_landscapes , number_of_repetitions_of_bootstrap , diff , norm , quantile , 1 );
-
- std::cout << "result of bootstrap : " << result << std::endl;
- return 0;
-}
-
diff --git a/src/Gudhi_stat/utilities/permutation_test.cpp b/src/Gudhi_stat/utilities/permutation_test.cpp
deleted file mode 100644
index e974b311..00000000
--- a/src/Gudhi_stat/utilities/permutation_test.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <gudhi/permutation_test.h>
-#include <gudhi/Persistence_landscape.h>
-#include <iostream>
-#include <cstring>
-
-using namespace Gudhi;
-using namespace Gudhi::Gudhi_stat;
-using namespace Gudhi::Persistence_representations;
-
-int main( int argc , char** argv )
-{
-
- std::cout << "This program require the following parameters: \n";
- std::cout << "(1-2) Names of files each of them contains the names of files with persistence diagrams. The diagrams from a single file are assumed to be in the same group \n";
- std::cout << "Third parameter is an integer being the number of permutations to be made \n";
- std::cout << "The last parameter is a double, the power of a distance \n";
- if ( argc != 5 )
- {
- std::cout << "Wrong number of parameters, the program will now terminat \n";
- return 1;
- }
- std::cout << "We will now read the data from files : " << argv[1] << " and " << argv[2] << std::endl;
- size_t number_of_permutations = (size_t)(atoi(argv[3]));
- size_t exponent = (double)atof( argv[4] );
-
- std::vector< std::string > first_group = readFileNames( argv[1] );
- std::vector< std::string > second_group =readFileNames( argv[2] );
-
- std::cout << "Here are the filenames in the first group :\n";
- for ( size_t i = 0 ; i != first_group.size() ; ++i )
- {
- std::cout << first_group[i] << std::endl;
- }
- std::cout << "Here are the filenames in the second group :\n";
- for ( size_t i = 0 ; i != second_group.size() ; ++i )
- {
- std::cout << second_group[i] << std::endl;
- }
-
- std::vector< Persistence_landscape* > first_collection( first_group.size() );
- for ( size_t i = 0 ; i != first_group.size() ; ++i )
- {
- std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( first_group[i].c_str() );
- Persistence_landscape* l = new Persistence_landscape( diag );
- first_collection[i] = l;
- }
-
- std::vector< Persistence_landscape* > second_collection( second_group.size() );
- for ( size_t i = 0 ; i != second_group.size() ; ++i )
- {
- std::vector< std::pair< double , double > > diag = read_standard_persistence_file( second_group[i].c_str() );
- Persistence_landscape* l = new Persistence_landscape( diag );
- second_collection[i] = l;
- }
-
- std::cout << "The p-value form a permutation test is : " << permutation_test<Persistence_landscape>( first_collection , second_collection , number_of_permutations , exponent ) << std::endl;
-
-
-
- return 0;
-}
diff --git a/src/Gudhi_stat/utilities/sliding_window_embedding.cpp b/src/Gudhi_stat/utilities/sliding_window_embedding.cpp
deleted file mode 100644
index 84e8f827..00000000
--- a/src/Gudhi_stat/utilities/sliding_window_embedding.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <vector>
-#include <string>
-#include <sstream>
-#include <cstdlib>
-#include <sys/stat.h>
-#include <string>
-
-#include <gudhi/time_series_analysis/sliding_window.h>
-
-using namespace Gudhi;
-using namespace Gudhi_stat;
-
-
-int main( int argc , char** argv )
-{
- //this array contains value of sin(x_n) for x_0 = 0 and x_{n+1} = _{n} + 0.1 for n \in {0,115-23}.
- static const double arr[] = {0, 0.0998334166, 0.1986693308, 0.2955202067, 0.3894183423, 0.4794255386, 0.5646424734, 0.6442176872, 0.7173560909, 0.7833269096, 0.8414709848, 0.8912073601, 0.932039086, 0.9635581854, 0.98544973,
- 0.9974949866, 0.999573603, 0.9916648105, 0.9738476309, 0.9463000877, 0.9092974268, 0.8632093666, 0.8084964038, 0.7457052122, 0.6754631806, 0.5984721441, 0.5155013718, 0.4273798802, 0.3349881502,
- 0.2392493292, 0.1411200081, 0.0415806624, -0.0583741434, -0.1577456941, -0.255541102, -0.3507832277, -0.4425204433, -0.5298361409, -0.6118578909, -0.6877661592, -0.7568024953, -0.8182771111, -0.8715757724,
- -0.9161659367, -0.9516020739, -0.9775301177, -0.9936910036, -0.9999232576, -0.9961646088, -0.9824526126, -0.9589242747, -0.9258146823, -0.8834546557, -0.8322674422, -0.7727644876, -0.7055403256,
- -0.6312666379, -0.5506855426, -0.4646021794, -0.3738766648, -0.2794154982, -0.1821625043, -0.0830894028, 0.0168139005, 0.1165492049, 0.2151199881, 0.3115413635, 0.4048499206, 0.4941133511, 0.5784397644,
- 0.6569865987, 0.7289690401, 0.7936678638, 0.8504366206, 0.8987080958, 0.9379999768, 0.967919672, 0.9881682339, 0.9985433454, 0.9989413418, 0.9893582466, 0.9698898108, 0.9407305567, 0.9021718338, 0.8545989081,
- 0.7984871126, 0.7343970979, 0.6629692301, 0.5849171929, 0.5010208565, 0.4121184852, 0.3190983623, 0.2228899141, 0.1244544235, 0.0247754255, -0.0751511205, -0.1743267812, -0.2717606264, -0.3664791293,
- -0.4575358938, -0.5440211109, -0.6250706489, -0.6998746876, -0.7676858098, -0.8278264691, -0.87969576, -0.9227754216, -0.9566350163, -0.9809362301, -0.9954362533, -0.9999902066, -0.9945525882, -0.9791777292,
- -0.9540192499, -0.9193285257, -0.8754521747};
- vector< double > time_series (arr, arr + sizeof(arr) / sizeof(arr[0]) );
-
- //construct sliding window embeddign to dimension 3 based on time_series:
- Sliding_window_embedding swe( time_series , 3 );
- swe.create_point_cloud("pt_cloud");
-
- //persistent_cohomology::Persistent_cohomology<ST, Field_Zp >& a =
- swe.compute_persistence_of_Vietoris_Rips_complex( 1 , 2 );
-
-
- return 0;
-}