def tst_five_d_cube(): hcube = sm.halton(5) result = flex.double([0, 0, 0, 0, 0]) for ii in range(5000): vec = flex.double(hcube.nth_all(ii)) result += vec result = result / 5000.0 for ii in result: assert approx_equal(ii, 0.5, 0.01)
def tst_five_d_cube(): hcube = sm.halton(5) result = flex.double( [0,0,0,0,0] ) for ii in xrange(5000): vec = flex.double(hcube.nth_all(ii)) result += vec result = result/5000.0 for ii in result: assert approx_equal(ii, 0.5, 0.01)
def test_halton_sequence_2(n_points, high_limit=5.0): norm = math.pi * 2.0 h_gen = sm.halton(1) result = 0.0 for ii in range(n_points): x = (1.0 - 2.0 * h_gen.nth_given_base(5, ii)) * high_limit y = (1.0 - 2.0 * h_gen.nth_given_base(7, ii)) * high_limit result += math.exp(-(x * x + y * y) * 0.5) / norm tmp = high_limit * high_limit * 4.0 * result / (float(n_points)) assert approx_equal(tmp, 1.0, eps=1e-2)
def test_halton_sequence_2(n_points, high_limit=5.0): norm = math.pi*2.0 h_gen = sm.halton(1) result = 0.0 for ii in xrange(n_points): x = (1.0-2.0*h_gen.nth_given_base(5, ii))*high_limit y = (1.0-2.0*h_gen.nth_given_base(7, ii))*high_limit result += math.exp( -(x*x+y*y)*0.5 )/norm tmp = high_limit*high_limit*4.0*result/(float(n_points)) assert approx_equal(tmp,1.0,eps=1e-2)
def test_halton_sequence_1(n_points, high_limit=1.0): h_gen = sm.halton(1) result = 0.0 for ii in range(n_points): x = h_gen.nth_given_base(5, ii) * high_limit y = h_gen.nth_given_base(7, ii) * high_limit result += math.exp(float(-x - y)) tmp = (math.exp(-2.0 * high_limit)) * (math.exp(high_limit) - 1.0)**2.0 result /= float(n_points) result *= high_limit * high_limit tmp = (math.exp(-2.0 * high_limit)) * (math.exp(high_limit) - 1.0)**2.0 assert approx_equal(result / tmp, 1.0, eps=1e-2)
def test_halton_sequence_1(n_points, high_limit=1.0): h_gen = sm.halton(1) result = 0.0 for ii in xrange(n_points): x = h_gen.nth_given_base(5, ii)*high_limit y = h_gen.nth_given_base(7, ii)*high_limit result += math.exp( float(-x - y) ) tmp = ( math.exp(-2.0*high_limit) )*( math.exp(high_limit)-1.0 )**2.0 result /= float(n_points) result *= high_limit*high_limit tmp = ( math.exp(-2.0*high_limit) )*( math.exp(high_limit)-1.0 )**2.0 assert approx_equal( result/tmp, 1.0 ,eps=1e-2)