예제 #1
0
#! /usr/bin/env python

from __future__ import print_function
import openturns as ot

# Polynomial factories
factoryCollection = [ot.MonomialFunctionFactory()] * 3

dim = len(factoryCollection)
factory = ot.TensorizedUniVariateFunctionFactory(factoryCollection)
print('factory=', factory)
x = [0.5, 1.0, 1.5]
for i in range(10):
    f = factory.build(i)
    print('i=', i, 'f(X)=', f(x))
예제 #2
0
#! /usr/bin/env python

from __future__ import print_function
import openturns as ot


# Define factory
factory = ot.MonomialFunctionFactory()
print ("factory = ", factory)
print ("Build functions for degrees in 1..9")
for i in range(10):
    print ("P_%d=%s" % (i, factory.build(i).__str__()))

# Build as Monomial factory
print ("Build as MonomialFunction for degrees in 1..9")
for i in range(10):
    print ("P_%d=%s" % (i, factory.buildAsMonomialFunction(i).__repr__()))
예제 #3
0
        [1400, 26, 5.5, 773.3, 13649.8, 19.588],
        [1620, 28, 5.5, 829.26, 14533, 20.1328],
        [1560, 28, 5.4, 856.96, 16892.2, 19.242]]

sample = ot.Sample(data)
sample.setDescription(description)

X = sample[:, 1:6]
Y = sample[:, 0]

#
# Build a model BIO~SAL+pH+K+Na+Zn
dim = X.getDimension()
enumerateFunction = ot.LinearEnumerateFunction(dim)
factory = ot.TensorizedUniVariateFunctionFactory(
    [ot.MonomialFunctionFactory()] * dim, enumerateFunction)

# Build 'interactions' as a list of list [a1,a2,a3,a4,a5], and we will generate tensorized
# polynomials SAL^a1*pH^a2*K^a3*Na^a4*Zn^a5.

# BIO~SAL+pH+K+Na+Zn
interactions = []
interactions.append([0] * dim)
for i in range(dim):
    indices = [0] * dim
    indices[i] = 1
    # Y ~ I(Xi)^1
    interactions.append(indices[:])

funcs = [
    factory.build(enumerateFunction.inverse(indices))