Hi, You're looking for the parametric function constructor NumericalMathFunction( function, indices, referencePoint, parametersSet=True ): http://openturns.github.io/user_manual/_generated/openturns.NumericalMathFunction.html
Basically you set the index and value of the frozen parameter: import openturns as ot def a_function(X): cov = X[-1] return [(X[0] + X[1] +X[2] + X[3]) * cov] ot.RandomGenerator.SetSeed(0) cov = 0.0017 myFunction = ot.PythonFunction(5, 1, a_function) myFunction_param = ot.NumericalMathFunction(myFunction, [4], [cov]) myDistribution = ot.Normal([50.0, 1.0, 10.0, 5.0], [1.0]*4, ot.IdentityMatrix(4)) vect = ot.RandomVector(myDistribution) output = ot.RandomVector(myFunction_param, vect) sample1 = output.getSample(10) print(sample1) > De: "Douglas Long" <[email protected]> > À: "users" <[email protected]> > Envoyé: Vendredi 7 Octobre 2016 18:42:36 > Objet: [ot-users] Python Function > Hi Folks, > anyone know how to submit constants or coefficients into a python function. > example. I am trying to submit the coefficient as Y below. > I have tried other methods as well with a composite, composed distribution, > and > several others. any help would be appreciated > import openturns as ot > def a_function(X): > return [(X[ 0 ] + X[ 1 ] +X[ 2 ] + X[ 3 ]) * X[ 4 ]] > if __name__ == "__main__" : > ot.RandomGenerator.SetSeed( 0 ) > cov = 0.0017 > myFunction = ot.PythonFunction( 5 , 1 , a_function( Y =cov)) > myDistribution = ot.Normal([ 50.0 , 1.0 , 10.0 , 5.0 ], [ 1.0 ]* 4 , > ot.IdentityMatrix( 4 )) > vect = ot.RandomVector(myDistribution) > output = ot.RandomVector(myFunction, vect) > sample1 = myDistribution.getSample( 10 ) > print (sample1) > _______________________________________________ > OpenTURNS users mailing list > [email protected] > http://openturns.org/mailman/listinfo/users -- Julien Schueller Phimeca Engineering www.phimeca.com
_______________________________________________ OpenTURNS users mailing list [email protected] http://openturns.org/mailman/listinfo/users
