Commit 14a24c67 authored by Kaitlyn Lee's avatar Kaitlyn Lee Committed by Jesse Mapel
Browse files

Added GaussianDistribution Tests (#3221)

* Added GaussianDistribution Test.

* Removed unused method and added test for exception.

* Changed comment.

* Added Area3DTests.cpp (#3216)

* Added BasisFunctionTests.cpp. Removed BasisFunction unit test and truthfile.

* changed expectedOutput values for some of the tests

* Made tests for Displacement.cpp using gtest. removed Displacement unitTest and truthfile.

* Added Area3DTests.cpp, removed Area3D truthfile and unit test.

* included TestUtilities.h for use with exception testing, added a test for teh Area3D '=' operator

* changed formatting to adhere to USGS coding standards

* re-addedd the unit test and truth file

* gllssi2isis Original Label Fix (#3226)

* Allowed writting of residuals when value is zero to controlnet pvl

* Updated ControlNetVersioner unit test

* Fixed pvl labels original pvl labels not being written to the resulting cube.

* Updated docstrings and history for updated methods

* Removed the need to set the output cube pixel type

* Reverted proceeimport changes

* Set the dimensions in the process before processing

* Added missing 1 in a history record

* Reverted and applied a more appropriate fix

* Used outfile obtained at the beginning of the program

* Added history comment to app xml

* Removed accidental comma (#3230)

* Update README.md (#3232)

Update readability

* Modifying files for conda build for ISIS3.7.0_RC2 (#3229)

* Modifying files for conda build for ISIS3.7.0_RC_2

* Changes to modifications until issue #3231 can be completed

* Small typo

* One final added comment for clarification

* Adding tab completion for tcsh on conda activation (#3244)

* Modifying meta.yaml and version files for ISIS3.7.0 Public Release (#3254)

* Modifying meta.yaml and version files for ISIS3.7.0 Public Release

* Fixing date on version file

* Put the Probability method back and removed the old unit test and truth data.
parent 955cc58a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ namespace Isis {
    p_stdev = standardDeviation;
  }


  /**
   * Computes and returns the probability of the specified value
   * on the gaussian distribution.
@@ -51,6 +52,7 @@ namespace Isis {
    return std::exp(-0.5 * std::pow((value - p_mean) / p_stdev, 2)) / (std::sqrt(2 * PI) * p_stdev);
  }


  /**
   * Computes and returns the cumulative distribution up to the
   * specified value on the gaussian distribution.
+0 −26
Original line number Diff line number Diff line
Cumulative Distribution
-3    0.13498980316%
-2.5    0.62096653258%
-2    2.2750131948%
-1.5    6.6807201269%
-1    15.865525393%
-0.5    30.853753873%
0    50%
0.5    69.146246127%
1    84.134474607%
1.5    93.319279873%
2    97.724986805%
2.5    99.379033467%
3    99.865010197%
Inverse Cumulative Distribution
0%    2.2250738585e-308
10%    -1.2815515913
20%    -0.8416212744
30%    -0.52440046989
40%    -0.25334712873
50%    0
60%    0.25334712873
70%    0.52440046989
80%    0.8416212744
90%    1.2815515913
100%    1.7976931349e+308
+0 −26
Original line number Diff line number Diff line
#include <iostream>
#include <iomanip>
#include "GaussianDistribution.h"
#include "IException.h"
#include "Preference.h"

using namespace std;

int main(int argc, char *argv[]) {
  Isis::Preference::Preferences(true);
  Isis::GaussianDistribution g;

  cout << setprecision(11);

  cout << "Cumulative Distribution" << endl;
  for(int i = -30; i <= 30; i += 5) {
    double x = i / 10.0;
    cout << x << "    " << g.CumulativeDistribution(x) << "%" << endl;
  }

  cout << "Inverse Cumulative Distribution" << endl;
  for(int i = 0; i <= 10; i++) {
    double p = 0.1 * i;
    cout << (10 * i) << "%    " << g.InverseCumulativeDistribution(p * 100.0) << endl;
  }
}
+67 −0
Original line number Diff line number Diff line
#include "GaussianDistribution.h"
#include "IException.h"
#include "TestUtilities.h"

#include <gtest/gtest.h>
#include <QPair>
#include <QString>

class DoubleTest : public ::testing::TestWithParam<QPair <double, double> > {
  // Intentionally empty
};


TEST(GaussianDistribution, DefaultConstructor) {
  Isis::GaussianDistribution dist;
  EXPECT_EQ(dist.Mean(), 0);
  EXPECT_EQ(dist.StandardDeviation(), 1.0);
}


TEST(GaussianDistribution, Constructor) {
  Isis::GaussianDistribution dist(1.0, 2.0);
  EXPECT_EQ(dist.Mean(), 1.0);
  EXPECT_EQ(dist.StandardDeviation(), 2.0);
}


TEST(GaussianDistribution, InvalidPercentage) {
  Isis::GaussianDistribution dist;
  QString message = "Argument percent outside of the range 0 to 100";
  try {
    dist.InverseCumulativeDistribution(110);
  }
  catch(Isis::IException &e) {
    EXPECT_PRED_FORMAT2(Isis::AssertIExceptionMessage, e, message);
  }
  catch(...) {
    FAIL() << "Expected error message: \"" << message.toStdString() << "\"";
  }
}


TEST_P(DoubleTest, Distributions) {
  Isis::GaussianDistribution dist;
  EXPECT_NEAR(dist.CumulativeDistribution(GetParam().first), GetParam().second, .000000000000000001);
  EXPECT_NEAR(dist.InverseCumulativeDistribution(GetParam().second), GetParam().first, .000001);
}


QPair <double, double> neg3(-3.0, 0.13498980316295217);
QPair <double, double> neg2point5(-2.5, 0.62096653257757595);
QPair <double, double> neg2(-2.0, 2.2750131948179018);
QPair <double, double> neg1point5(-1.5, 6.6807201268857881);
QPair <double, double> neg1(-1.0, 15.865525393145695);
QPair <double, double> negpoint5(-0.5, 30.853753872598688);
QPair <double, double> zero(0.0, 50);
QPair <double, double> pospoint5(0.5, 69.146246127401312);
QPair <double, double> pos1(1.0, 84.134474606854297);
QPair <double, double> pos1point5(1.5, 93.319279873114212);
QPair <double, double> pos2(2.0, 97.724986805182098);
QPair <double, double> pos2point5(2.5, 99.379033467422431);
QPair <double, double> pos3(3.0, 99.865010196837048);


INSTANTIATE_TEST_CASE_P(GaussianDistribution, DoubleTest, ::testing::Values(neg3, neg2point5, 
                        neg2, neg1point5, neg1, negpoint5, zero, pospoint5, pos1, pos1point5, 
                        pos2, pos2point5, pos3));
 No newline at end of file