예제 #1
0
def test_parallel_second_order():
    c2o = True
    N = 10000
    problem, param_values = setup_samples(N=N, calc_second_order=c2o)
    Y = Ishigami.evaluate(param_values)

    A, B, AB, BA = sobol.separate_output_values(Y,
                                                D=3,
                                                N=N,
                                                calc_second_order=c2o)
    r = np.random.randint(N, size=(N, 100))
    Z = norm.ppf(0.5 + 0.95 / 2)
    tasks, n_processors = sobol.create_task_list(D=3,
                                                 calc_second_order=c2o,
                                                 n_processors=None)
    Si_list = []
    for t in tasks:
        Si_list.append(sobol.sobol_parallel(Z, A, AB, BA, B, r, t))
    Si = sobol.Si_list_to_dict(Si_list, D=3, calc_second_order=c2o)

    assert_allclose(Si['S1'], [0.31, 0.44, 0.00], atol=5e-2, rtol=1e-1)
    assert_allclose(Si['ST'], [0.55, 0.44, 0.24], atol=5e-2, rtol=1e-1)
    assert_allclose([Si['S2'][0][1], Si['S2'][0][2], Si['S2'][1][2]],
                    [0.00, 0.25, 0.00],
                    atol=5e-2,
                    rtol=1e-1)
예제 #2
0
파일: test_sobol.py 프로젝트: cmutel/SALib
def test_parallel_first_order():
    c2o = False
    N = 10000
    problem,param_values = setup_samples(N=N, calc_second_order=c2o)
    Y = Ishigami.evaluate(param_values)

    A,B,AB,BA = sobol.separate_output_values(Y, D=3, N=N,
                                            calc_second_order=c2o)
    r = np.random.randint(N, size=(N, 100))
    Z = norm.ppf(0.5 + 0.95 / 2)
    tasks, n_processors = sobol.create_task_list(D=3,
                            calc_second_order=c2o, n_processors=None)
    Si_list = []
    for t in tasks:
        Si_list.append(sobol.sobol_parallel(Z, A, AB, BA, B, r, t))
    Si = sobol.Si_list_to_dict(Si_list, D=3, calc_second_order=c2o)

    assert_allclose(Si['S1'], [0.31, 0.44, 0.00], atol=5e-2, rtol=1e-1)
    assert_allclose(Si['ST'], [0.55, 0.44, 0.24], atol=5e-2, rtol=1e-1)