Home | Develop | Download | Contact
test_matrix_statistics.cpp
1
8#include <Pds/Ra>
9
10int main(void)
11{
12 unsigned int L=4;
13 Pds::Matrix A(L,L);
14 A.FillRandC(0.5);
15 A.Print("A:\n");
16
17 Pds::Matrix B=A+2.0*Pds::RandU(L,L);
18
19 std::cout<<"A.MultiplyValues(): "<<A.MultiplyValues() <<std::endl;
20 std::cout<<"A.Max() : "<<A.Max() <<std::endl;
21 std::cout<<"A.Min() : "<<A.Min() <<std::endl;
22 std::cout<<"A.Sum() : "<<A.Sum() <<std::endl;
23 std::cout<<"A.Mean() : "<<A.Mean()<<std::endl;
24 std::cout<<"A.MeanInCols() :\n"<<A.MeanInCols();
25 std::cout<<"A.Std() : "<<A.Std() <<std::endl;
26 std::cout<<"A.Corr(B): "<<A.Corr(B)<<std::endl;
27
28 Pds::Matrix C("-2 2 2 \n-1 2 -1\n 1 1 3");
29 std::cout<<"C.MultiplyValues(): "<<C.MultiplyValues() <<std::endl;
30
31 Pds::Matrix D("1 1\n1 -1");
32
33 C.Print("C:\n");
34 D.Print("D:\n");
35
36 C.XCorr(D).Print("C.XCorr(D):\n");
37 C.XCorr(D,true).Print("C.XCorr(D,true):\n");
38
39
40 A.Print("A:\n");
41 std::vector<Pds::Matrix> G(2);
42 G[0]=A.GetRows(0,2); G[0].Print("G[0]:\n");
43 G[1]=A.GetRows(3,L-1); G[1].Print("G[1]:\n");
44 double IG=A.InformationGain(G,0.5);
45 std::cout<<"IG: "<<IG<<"\n";
46 std::cout<<"IG: "<< A.BinaryEntropy(0.5)
47 -(G[0].Nel()*1.0/A.Nel())*G[0].BinaryEntropy(0.5)
48 -(G[1].Nel()*1.0/A.Nel())*G[1].BinaryEntropy(0.5)<<"\n";
49
50 C.Print("\nC:\n");
51 C.MinInCols().Print("C.MinInCols():\n");
52 C.MaxInCols().Print("C.MaxInCols():\n");
53
54 std::vector<unsigned int> stdlin;
55
56 C.Print("\nC:\n");
57 C.MaxInCols(stdlin).Print("C.MaxInCols(stdlin):\n");
58 std::cout<<"stdlin: "<<Pds::Ra::IndicesToString(stdlin,"\t")<<"\n";
59 C.MinInCols(stdlin).Print("C.MinInCols(stdlin):\n");
60 std::cout<<"stdlin: "<<Pds::Ra::IndicesToString(stdlin,"\t")<<"\n";
61
63
64 C.Print("\nC:\n");
65 C.MaxInCols(Lin).Print("C.MaxInCols(Lin):\n");
66 Lin.Print("Lin:\n");
67 C.MinInCols(Lin).Print("C.MinInCols(Lin):\n");
68 Lin.Print("Lin:\n");
69
70 return 0;
71}
La clase tipo Array . Esta clase genera una agrupación de 2 datos. Para usar incluir Pds/Array.
Definition: Array.hpp:71
La clase tipo Pds::Matrix . Esta clase genera una matriz de Nlin lineas y Ncol columnas....
Definition: Matrix.hpp:96
void Print(std::string str) const
Imprime en pantalla el contenido del array.
Pds::Matrix RandU(unsigned int N)
Crea una matriz con datos aleatórios uniformemente distribuidos entre 0.0 y 1.0.
std::string IndicesToString(std::list< unsigned int > IDs, std::string separator="")
Convierte una lista de indices a un std::string.

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed