import matplotlib.pyplot as plt sym.init_printing(use_unicode=True) d = 2 p = 0.25 q = 1 - p E = Matrix([[1, 1], [0, 1]]) Qs = [Matrix([[-5, 0], [0, 5]]), Matrix([[1, 2], [0.5, 0.1]])] d = E.shape[0] A = ones((d, d)) import Pymatr.model as Mod red = Mod.reduced(A, E, Qs) import random import math def Gs(i, j): return lambda: random.gauss(Qs[0][i, j], math.sqrt(Qs[1][i, j])) import Pymatr.synthesis as Syn from Pymatr.utils import numerical L = red.dEigen nsyn = 100 Gen = Syn.MatrixRngOpt(numerical(A), numerical(E / L), Gs, nsyn)
d=2 p=0.25 q=1-p E = Matrix( [ [ 1 , 1 ] , [0, 1] ] ) Qs =[ Matrix( [ [ -5 ,0 ] , [ 0 , 5] ] ) , Matrix( [ [ 1 ,2 ] , [0.5 , 0.1] ] ) ] d=E.shape[0] A = ones((d,d)) import Pymatr.model as Mod red= Mod.reduced(A,E, Qs ) import random import math def Gs(i,j): return lambda : random.gauss( Qs[0][i,j], math.sqrt(Qs[1][i,j]) ) import Pymatr.synthesis as Syn from Pymatr.utils import numerical L= red.dEigen nsyn=100 Gen = Syn.MatrixRngOpt(numerical(A),numerical(E/L), Gs, nsyn) def average(): s= sum(Gen()) av= s /nsyn