grant_class_base, grant_class_means, grant_class_medians, grant_class_ffracs ], prefixes=['grant_', 'grant_', 'grant_', 'grant_', 'grant_'], postfixes=['', '_mean', '_median', '_ffrac']) grant_class_info['grant_class_number'] = grant_class_info.index grant_class_info['grant_class_size'] = grant_class_size # merge both levels datf_class = firm_class_info.join(grant_class_info).join(trans_class_means) if run_flags[5]: print('Aggregate industry stats') # generate target values targ_model = vt.Bundle() targ_model['median_markup'] = firm_totals['markup'].median() targ_model['median_profit'] = firm_totals['profit'].median() targ_model['mean_markup'] = firm_totals['markup'].mean() - 1.0 targ_model['mean_profit'] = firm_totals['profit'].mean() targ_model['agg_markup'] = firm_totals['revenue'].sum( ) / firm_totals['cogs'].sum() - 1.0 targ_model['agg_profit'] = firm_totals['income'].sum( ) / firm_totals['cost'].sum() targ_model['entry_rate_5year'] = firm_totals['entered'].mean() targ_model['entrant_stock_frac'] = firm_totals['stock_end'][ firm_totals['entered']].sum() / firm_totals['stock_end'].sum() targ_model['internal_cite_frac'] = (firm_totals['n_self_cited'] > 0.0 * firm_totals['n_cited']).mean() targ_model['ind_ptrans_mean'] = datf_class['grant_pos_trans_mean'].mean() targ_model['ind_ptrans_std'] = datf_class['grant_pos_trans_mean'].std()
# astro params N = 2**8 # number of particles M = 1 # sol masses dt = 0.01 # years crad = 1e-1 # AU # scale L = 1.496e11 # length scale (1 AU) K = 1.989e30 # mass scale (1 sol mass) T = 3.154e8 # time step (1 year) # units G = G0 * (1 / L**3) * (K) * (T**2) # state st = vt.Bundle() # initialize st.mas = (1e24 / K) * np.exp(2 * np.random.rand(N) - 1) st.posx = (1e13 / L) * np.random.randn(N) st.posy = (1e13 / L) * np.random.randn(N) rad = np.sqrt(st.posx**2 + st.posy**2) spd = np.sqrt(G * M / rad) st.velx = 0.7 * (st.posy / rad) * spd st.vely = -0.7 * (st.posx / rad) * spd # perturb st.velx += 1 * (2 * np.random.rand(N) - 1) st.vely += 1 * (2 * np.random.rand(N) - 1) # the star
def load_policy(m, pol): m.pol = vt.Bundle(file_or_dict(pol))
def load_eqvars(m, var): m.var = vt.Bundle(file_or_dict(var))
def load_params(m, par): m.par = vt.Bundle(file_or_dict(par))
def load_algpar(m, alg): m.alg = vt.Bundle(file_or_dict(alg))
def file_or_dict(fod): return vt.Bundle(load_json(fod)) if type(fod) is str else fod