~ubuntu-branches/ubuntu/maverick/openturns/maverick

« back to all changes in this revision

Viewing changes to lib/test/t_HypothesisTest_correlation.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-08-18 18:14:38 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090818181438-copqi92r4z7y0ejc
Tags: 0.13.1-1ubuntu1
debian/python-openturns.install: update to use python* and *-packages.
This fix a FTBFS with python2.6.  (LP: #350437)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21
21
 *
22
22
 *  @author: $LastChangedBy: dutka $
23
 
 *  @date:   $LastChangedDate: 2008-06-26 13:50:17 +0200 (jeu 26 jun 2008) $
24
 
 *  Id:      $Id: t_HypothesisTest_correlation.cxx 862 2008-06-26 11:50:17Z dutka $
 
23
 *  @date:   $LastChangedDate: 2009-05-28 14:47:53 +0200 (jeu. 28 mai 2009) $
 
24
 *  Id:      $Id: t_HypothesisTest_correlation.cxx 1262 2009-05-28 12:47:53Z dutka $
25
25
 */
26
26
#include <iostream>
27
27
#include <iomanip>
28
28
#include "OT.hxx"
29
29
#include "OTtestcode.hxx"
 
30
#include "OStream.hxx"
30
31
#include <cmath>
31
32
#include "HypothesisTest.hxx"
32
33
#include "NumericalSample.hxx"
37
38
 
38
39
using namespace OT;
39
40
using namespace OT::Test;
 
41
using namespace OT::Base::Common;
40
42
using namespace OT::Base::Stat;
41
43
using namespace OT::Base::Type;
42
44
using namespace OT::Uncertainty::Distribution;
45
47
int main(int argc, char *argv[])
46
48
{
47
49
  TESTPREAMBLE;
 
50
  OStream fullprint(std::cout);
48
51
  setRandomGenerator();
49
52
  
50
53
  UnsignedLong size(100);
95
98
  // PartialPearson : Independence Pearson test between 2 samples : firstSample of dimension n and secondSample of dimension 1. If firstSample[i] is the numerical sample extracted from firstSample (ith coordinate of each point of the numerical sample), PartialPearson performs the Independence Pearson test simultaneously on firstSample[i] and secondSample, for i in the selection. For all i, it is supposed that the couple (firstSample[i] and secondSample) is issued from a gaussian  vector.
96
99
  // Probability of the H0 reject zone : 1-0.90
97
100
 
98
 
  std::cout << "PartialPearsonXY=" << HypothesisTest::PartialPearson(sampleX, sampleY, selection, 0.90) << std::endl;
 
101
  fullprint << "PartialPearsonXY=" << HypothesisTest::PartialPearson(sampleX, sampleY, selection, 0.90) << std::endl;
99
102
 
100
103
  // The three tests must be equal
101
 
  std::cout << "PartialPearsonX0Y=" << HypothesisTest::PartialPearson(sampleX, sampleY, selection2, 0.90) << std::endl;
102
 
  std::cout << "PearsonX0Y=" << HypothesisTest::Pearson(sampleX0, sampleY, 0.90) << std::endl;
103
 
  std::cout << "FullPearsonX0Y=" << HypothesisTest::FullPearson(sampleX0, sampleY, 0.90) << std::endl;
 
104
  fullprint << "PartialPearsonX0Y=" << HypothesisTest::PartialPearson(sampleX, sampleY, selection2, 0.90) << std::endl;
 
105
  fullprint << "PearsonX0Y=" << HypothesisTest::Pearson(sampleX0, sampleY, 0.90) << std::endl;
 
106
  fullprint << "FullPearsonX0Y=" << HypothesisTest::FullPearson(sampleX0, sampleY, 0.90) << std::endl;
104
107
 
105
108
  // FullPearson : Independence Pearson test between 2 samples : firstSample of dimension n and secondSample of dimension 1. If firstSample[i] is the numerical sample extracted from firstSample (ith coordinate of each point of the numerical sample), FullPearson performs the Independence Pearson test simultaneously on firstSample[i] and secondSample. For all i, it is supposed that the couple (firstSample[i] and secondSample) is issued from a gaussian  vector.
106
109
  // Probability of the H0 reject zone : 1-0.90
107
110
 
108
 
  std::cout << "FullPearsonX0Y=" << HypothesisTest::FullPearson(sampleX, sampleY, 0.90) << std::endl;
109
 
  std::cout << "FullPearsonYY=" << HypothesisTest::FullPearson(sampleY, sampleY, 0.90) << std::endl;
 
111
  fullprint << "FullPearsonX0Y=" << HypothesisTest::FullPearson(sampleX, sampleY, 0.90) << std::endl;
 
112
  fullprint << "FullPearsonYY=" << HypothesisTest::FullPearson(sampleY, sampleY, 0.90) << std::endl;
110
113
 
111
114
  // PartialSpearman test between 2 samples : firstSample of dimension n and secondSample of dimension 1. If firstSample[i] is the numerical sample extracted from firstSample (ith coordinate of each point of the numerical sample), PartialSpearman performs the Independence Spearman test simultaneously on firstSample[i] and secondSample, for i in the selection.
112
115
// Probability of the H0 reject zone : 1-0.90
113
116
 
114
117
  // The three tests must be equal
115
 
  std::cout << "PartialSpearmanX0Y=" << HypothesisTest::PartialSpearman(sampleX, sampleY, selection2, 0.90) << std::endl;
116
 
  std::cout << "SpearmanX0Y=" << HypothesisTest::Spearman(sampleX0, sampleY, 0.90) << std::endl;
117
 
  std::cout << "FullSpearmanX0Y=" << HypothesisTest::FullSpearman(sampleX0, sampleY, 0.90) << std::endl;
 
118
  fullprint << "PartialSpearmanX0Y=" << HypothesisTest::PartialSpearman(sampleX, sampleY, selection2, 0.90) << std::endl;
 
119
  fullprint << "SpearmanX0Y=" << HypothesisTest::Spearman(sampleX0, sampleY, 0.90) << std::endl;
 
120
  fullprint << "FullSpearmanX0Y=" << HypothesisTest::FullSpearman(sampleX0, sampleY, 0.90) << std::endl;
118
121
 
119
 
  std::cout << "PartialSpearmanXY=" << HypothesisTest::PartialSpearman(sampleX, sampleY, selection, 0.90) << std::endl;
 
122
  fullprint << "PartialSpearmanXY=" << HypothesisTest::PartialSpearman(sampleX, sampleY, selection, 0.90) << std::endl;
120
123
 
121
124
// FullSpearman : Spearman test between 2 samples : firstSample of dimension n and secondSample of dimension 1. If firstSample[i] is the numerical sample extracted from firstSample (ith coordinate of each point of the numerical sample), FullSpearman performs the Independence Spearman test simultaneously on all firstSample[i] and secondSample.
122
125
// Probability of the H0 reject zone : 1-0.90
123
126
 
124
 
  std::cout << "FullSpearmanYZ=" << HypothesisTest::FullSpearman(sampleY, sampleZ, 0.90) << std::endl;
125
 
  std::cout << "FullSpearmanYY=" << HypothesisTest::FullSpearman(sampleY, sampleY, 0.90) << std::endl;
 
127
  fullprint << "FullSpearmanYZ=" << HypothesisTest::FullSpearman(sampleY, sampleZ, 0.90) << std::endl;
 
128
  fullprint << "FullSpearmanYY=" << HypothesisTest::FullSpearman(sampleY, sampleY, 0.90) << std::endl;
126
129
 
127
130
// Regression test between 2 samples : firstSample of dimension n and secondSample of dimension 1. If firstSample[i] is the numerical sample extracted from firstSample (ith coordinate of each point of the numerical sample), PartialRegression performs the Regression test simultaneously on all firstSample[i] and secondSample, for i in the selection. The Regression test tests ifthe regression model between two scalar numerical samples is significant. It is based on the deviation analysis of the regression. The Fisher distribution is used.
128
131
 
129
132
// The two tests must be equal
130
 
  std::cout << "PartialRegressionX0Y=" << HypothesisTest::PartialRegression(sampleX, sampleY, selection2, 0.90) << std::endl;
131
 
  std::cout << "FullRegressionX0Y=" << HypothesisTest::FullRegression(sampleX0, sampleY, 0.90) << std::endl;
 
133
  fullprint << "PartialRegressionX0Y=" << HypothesisTest::PartialRegression(sampleX, sampleY, selection2, 0.90) << std::endl;
 
134
  fullprint << "FullRegressionX0Y=" << HypothesisTest::FullRegression(sampleX0, sampleY, 0.90) << std::endl;
132
135
 
133
 
  std::cout << "PartialRegressionXY=" << HypothesisTest::PartialRegression(sampleX, sampleY, selection, 0.90) << std::endl;
 
136
  fullprint << "PartialRegressionXY=" << HypothesisTest::PartialRegression(sampleX, sampleY, selection, 0.90) << std::endl;
134
137
 
135
138
// Regression test between 2 samples : firstSample of dimension n and secondSample of dimension 1. If firstSample[i] is the numerical sample extracted from firstSample (ith coordinate of each point of the numerical sample), FullRegression performs the Regression test simultaneously on all firstSample[i] and secondSample. The Regression test tests if the regression model between two scalar numerical samples is significant. It is based on the deviation analysis of the regression. The Fisher distribution is used.
136
139
 
137
 
  std::cout << "FullRegressionXZ=" << HypothesisTest::FullRegression(sampleX, sampleZ, 0.90) << std::endl;
138
 
  std::cout << "FullRegressionZZ=" << HypothesisTest::FullRegression(sampleZ, sampleZ, 0.90) << std::endl;
 
140
  fullprint << "FullRegressionXZ=" << HypothesisTest::FullRegression(sampleX, sampleZ, 0.90) << std::endl;
 
141
  fullprint << "FullRegressionZZ=" << HypothesisTest::FullRegression(sampleZ, sampleZ, 0.90) << std::endl;
139
142
 
140
143
 
141
144
  return ExitCode::Success;