print(params) print(labels) # Set up themodel dap = DAPcython(-75, params) U = dap.simulate(dt, t, I) # generate data format for SNPE / OBSERVABLE x_o = {'data': U.reshape(-1), 'time': t, 'dt': dt, 'I': I} # Setup Priors prior_min, prior_max, labels = load_prior_ranges(n_params) prior_unif = Uniform(lower=prior_min, upper=prior_max) # Summary Statistics S = syn_obs_stats(x_o['I'], params=params, dt=x_o['dt'], t_on=t_on, t_off=t_off, n_summary=n_summary, summary_stats=1, data=x_o) M = DAPSimulator(x_o['I'], x_o['dt'], -75) s = DAPSummaryStatsStepMoments(t_on, t_off, n_summary=n_summary) G = Default(model=M, prior=prior_unif, summary=s) # Generator # Runing the simulation inf_snpe = SNPE(generator=G, n_components=n_components, n_hiddens=n_hiddens, obs=S, # reg_lambda=reg_lambda, pilot_samples=0, prior_norm=True) reg_lambda=reg_lambda, pilot_samples=0)
dt = 0.01 percent_accept = 1 # Get current I, t, t_on, t_off = syn_current(duration=70, dt=dt, t_on=15, t_off=20, amp=3.1) params, labels = obs_params_gbar(reduced_model=True) dap = DAPcython(-75, params * 10) # Set up the model sim = DAPSimulator(I, dt, -75, dim_param=2) stats = DAPSummaryStatsMoments(t_on, t_off, n_summary=n_summary) # Setup Priors prior_min = np.array([0, 0]) prior_max = np.array([2, 2]) prior_unif = Uniform(lower=prior_min, upper=prior_max) # generate desired data U = dap.simulate(dt, t, I) y_o = {'data': U.reshape(-1), 'time': t, 'dt': dt, 'I': I} y = stats.calc([y_o]) # Sample Parameters params = prior_unif.gen(n_samples=n_samples) # calculate the distance for each parameters norms = [] for p in tqdm(params): x_o = sim.gen_single(p) y_obs = stats.calc([x_o])
'time': tr, 'dt': dtr, 'I': Ir } x_step = { 'data': vs.reshape(-1), # x_step = {'data': vs, 'time': ts, 'dt': dts, 'I': Is } # Setup Priors prior_min, prior_max, labels = load_prior_ranges(2) prior_unif = Uniform(lower=prior_min, upper=prior_max) # define model dap1 = DAPSimulatorMultiProtocol(I_all, dt_all, -75) # run model stats = dap1.gen_single(params, I_all[0], tr, dtr) data_list = dap1.gen(params_list) # calcualte summary statistics sum_stats_step = DAPSummaryStatsStepMoments(t_ons, t_offs, n_summary=17) sum_stats_mom = DAPSummaryStatsMoments(t_onr, t_offr, n_summary=17) sum_stats = [sum_stats_step, sum_stats_mom] s_step = sum_stats_step.calc([x_step]) s_ramp = sum_stats_mom.calc([x_ramp])