示例#1
0
from numpy import *
import current as pc

dist = pc.Normal()
orths = []
for poly in pc.basis(0, 4, dim=1):

    for orth in orths:

        coef = pc.E(orth * poly, dist) / pc.E(orth**2, dist)
        poly = poly - orth * coef

    orths.append(poly)

orths = pc.Poly(orths)
print orths
#  [1.0, q0, q0^2-1.0, q0^3-3.0q0, q0^4-6.0q0^2+3.0]
#end

orths2 = pc.outer(orths, orths)
print pc.E(orths2, dist)
#  [[  1.   0.   0.   0.   0.]
#   [  0.   1.   0.   0.   0.]
#   [  0.   0.   2.   0.   0.]
#   [  0.   0.   0.   6.   0.]
#   [  0.   0.   0.   0.  24.]]
#end

dist = pc.Gamma(2)
print pc.orth_bert(2, dist)
#  [1.0, q0-2.0, q0^2-6.0q0+6.0]
示例#2
0
文件: coll.py 项目: simetenn/chaospy
from numpy import *
import current as pc


def model_solver(q):
    return q[1] * e**q[0] + 1


#end

coll_points = array([[0, 0, 1], [0, 1, 1]])
#end

basis = pc.basis(0, 1, 2)
print basis
#  [1, q0, q1]
#end

solves = model_solver(coll_points)
print solves
#  [ 1.          2.          3.71828183]
#end

approx_solver = pc.fitter_lr(basis, coll_points, solves)
print approx_solver
#  q1+1.71828182846q0+1.0
#end

print approx_solver(*coll_points)
#  [ 1.          2.          3.71828183]
#end
示例#3
0
from numpy import *
import current as pc

dist = pc.Normal()
orths = []
for poly in pc.basis(0, 4, dim=1):

    for orth in orths:

        coef = pc.E(orth*poly, dist)/pc.E(orth**2, dist)
        poly = poly - orth*coef

    orths.append(poly)

orths = pc.Poly(orths)
print orths
#  [1.0, q0, q0^2-1.0, q0^3-3.0q0, q0^4-6.0q0^2+3.0]
#end

orths2 = pc.outer(orths, orths)
print pc.E(orths2, dist)
#  [[  1.   0.   0.   0.   0.]
#   [  0.   1.   0.   0.   0.]
#   [  0.   0.   2.   0.   0.]
#   [  0.   0.   0.   6.   0.]
#   [  0.   0.   0.   0.  24.]]
#end

dist = pc.Gamma(2)
print pc.orth_bert(2, dist)
#  [1.0, q0-2.0, q0^2-6.0q0+6.0]
示例#4
0
from numpy import *
import current as pc

x, y = pc.variable(2)
print x
# q0
#end

polys = pc.Poly([1, x, x * y])
print polys
#  [1, q0, q0q1]
#end

print pc.basis(4)
#  [1, q0, q0^2, q0^3, q0^4]
#end

print pc.basis(1, 2, dim=2)
#  [q0, q1, q0^2, q0q1, q1^2]
#end

print pc.basis(1, [1, 2])
#  [q0, q1, q0q1, q1^2, q0q1^2]
#end

print pc.basis(1, 2, dim=2, sort="GRI")
#  [q0^2, q0q1, q1^2, q0, q1]
#end

poly = pc.Poly([1, x**2, x * y])
print poly(2, 3)
示例#5
0
文件: coll.py 项目: apetcho/chaospy
from numpy import *
import current as pc

def model_solver(q):
    return q[1]*e**q[0]+1
#end

coll_points = array([[0,0,1],[0,1,1]])
#end

basis = pc.basis(0,1,2)
print basis
#  [1, q0, q1]
#end

solves = model_solver(coll_points)
print solves
#  [ 1.          2.          3.71828183]
#end

approx_solver = pc.fitter_lr(basis, coll_points, solves)
print approx_solver
#  q1+1.71828182846q0+1.0
#end

print approx_solver(*coll_points)
#  [ 1.          2.          3.71828183]
#end
示例#6
0
文件: poly.py 项目: apetcho/chaospy
from numpy import *
import current as pc

x,y = pc.variable(2)
print x
# q0
#end

polys = pc.Poly([1, x, x*y])
print polys
#  [1, q0, q0q1]
#end

print pc.basis(4)
#  [1, q0, q0^2, q0^3, q0^4]
#end

print pc.basis(1, 2, dim=2)
#  [q0, q1, q0^2, q0q1, q1^2]
#end

print pc.basis(1, [1, 2])
#  [q0, q1, q0q1, q1^2, q0q1^2]
#end

print pc.basis(1, 2, dim=2, sort="GRI")
#  [q0^2, q0q1, q1^2, q0, q1]
#end

poly = pc.Poly([1, x**2, x*y])
print poly(2, 3)