Esempio n. 1
0
# -*- coding: utf-8 -*-

from our_lib import tables
import synthetic_data

synthetic_data.set_seed(42)

n = 100

mu_key = 'exp_y'

sigma_key = 'err'

table_keys = ('Dpp', 'Dpm', 'Ppp', 'Ppm')

synth_tables = {}

for key in table_keys:
    table = tables[key]

    synth_tables[key] = synthetic_data.synth_data_from_table(
        table, mu_key, sigma_key, n
    )

    synth_tables[key].to_excel('data/synthetic/{}.xlsx'.format(key),
                               index=False)
Esempio n. 2
0
p_indices = ('a1', 'a2', 'a3', 'a4', 'b')

parameters = pd.DataFrame(columns=p_indices)

start_p = (1.0, 1.0, 1.0, 1.0, 1.0)

# Generate and fit the synthetic data.
for i in range(N):
    # Generate the synthetic data. (4 tables are generated.)
    synth_tables = {}

    for k in ('Dpp', 'Dpm', 'Ppp', 'Ppm'):
        table = our_lib.tables[k]
        synth_tables[k] = (
            synthetic_data.synth_data_from_table(table, 'exp_y', 'err')
        )

    tables_funcs = [(synth_tables[k],
                     our_lib.theor_funcs[k]) for k in ('Dpp', 'Dpm', 'Ppp', 'Ppm')]

    # Fit the synthetic data.
    res_of_p = partial(residuals.res_array_from_tables, tables_funcs)

    opt_p = our_lib.leastsq(res_of_p, start_p)[0]

    # Save the parameters.
    parameters = parameters.append(pd.Series(dict(zip(p_indices, opt_p))),
                                   ignore_index=True)

    # Watch the time go by.