blob: e974b3119cde38ea3859594b45cb8c62696f4f1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/* 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;
}
|