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
|
#! /usr/bin/env python
from __future__ import print_function
from openturns import *
TESTPREAMBLE()
try:
size = 10
dimension = 2
sample = NumericalSample(size, dimension)
# Fill-in the sample
for i in range(size):
p = NumericalPoint(dimension)
for j in range(dimension):
p[j] = i + j * 1.0 / dimension
sample[i] = p
print("sample=", repr(sample))
# History using the Null strategy
nullStrategy = Null()
for i in range(size):
nullStrategy.store(sample[i])
print("Null strategy sample=", repr(nullStrategy.getSample()))
# History using the Full strategy
fullStrategy = Full()
for i in range(size):
fullStrategy.store(sample[i])
print("Full strategy sample=", repr(fullStrategy.getSample()))
# History using the Last strategy, large storage
lastStrategy = Last(3 * size)
for i in range(size):
lastStrategy.store(sample[i])
print("Last strategy sample (large storage)=",
repr(lastStrategy.getSample()))
lastStrategy = Last(size // 3)
# History using the Last strategy, small storage
for i in range(size):
lastStrategy.store(sample[i])
print("Last strategy sample (small storage)=",
repr(lastStrategy.getSample()))
# History using the Compact strategy, large storage
compactStrategy = Compact(3 * size)
for i in range(size):
compactStrategy.store(sample[i])
print("Compact strategy sample (large storage)=",
repr(compactStrategy.getSample()))
compactStrategy = Compact(size // 3)
# History using the Compact strategy, small storage
for i in range(size):
compactStrategy.store(sample[i])
print("Compact strategy sample (small storage)=",
repr(compactStrategy.getSample()))
except:
import sys
print("t_HistoryStrategy_std.py", sys.exc_info()[0], sys.exc_info()[1])
|