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
|
#! /usr/bin/env python
from __future__ import print_function
from openturns import *
from math import *
TESTPREAMBLE()
try:
try:
# Function
sampleSize = 20
levelFunction = NumericalMathFunction(
["x1", "x2", "x3", "x4"], ["y1"], ["x1+2*x2-3*x3+4*x4"])
myOperator = LessOrEqual()
threshold = 2.0
mySample = NumericalSample(0, levelFunction.getInputDimension())
random = 0.1
for index in range(sampleSize):
point = NumericalPoint(levelFunction.getInputDimension())
norm = 0.0
for coordinate in range(levelFunction.getInputDimension()):
point[coordinate] = sqrt(-2.0 * log(random))
random = fmod(random + sqrt(2.0), 1.0)
point[coordinate] *= cos(2.0 * atan(1.0) * random)
norm += point[coordinate] * point[coordinate]
for coordinate in range(levelFunction.getInputDimension()):
point[coordinate] /= sqrt(norm)
mySample.add(point)
myNearestPointChecker = NearestPointChecker(
levelFunction, myOperator, threshold, mySample)
for index in range(sampleSize):
print(repr(mySample[index]))
myNearestPointChecker.run()
print("myNearestPointChecker = ", myNearestPointChecker)
except:
raise
except:
import sys
print("t_NearestPointChecker_std.py", sys.exc_info()[0], sys.exc_info()[1])
|