<jupyter_start><jupyter_text>GAMA catalog<jupyter_code>gama_cat = Table.read('./Catalog/gama_dr3_z_0.55_sersic_logms.fits')
gama_cat = gama_cat[(gama_cat['Z'] < 0.3) & (gama_cat['Z'] > 0.25) & (gama_cat['logmstar'] > 11.0)]
count, bin_edge, patches= plt.hist(gama_cat['GALINDEX_r'], 
                                     bins=np.linspace(0, 10, 50), 
                                     histtype='step', linewidth=2, density=True, label=r'$n$');
bin_middle = (bin_edge[:-1] + bin_edge[1:])/2
from scipy.optimize import curve_fit
from scipy.special import factorial
# poisson function, parameter lamb is the fit parameter
def poisson(k, lamb):
    return (lamb**k/factorial(k)) * np.exp(-lamb)
# fit with curve_fit
parameters, cov_matrix = curve_fit(poisson, bin_middle, count) 

x_plot = np.linspace(0, 10, 200)
plt.plot(x_plot, poisson(x_plot, *parameters), 'b--', lw=2, zorder=10)
n_random = np.random.gamma(*parameters, size=[1000])


count, bin_edge, patches = plt.hist(gama_cat['GALRE_r'], 
                                     bins=np.linspace(0, 10, 50), 
                                     histtype='step', linewidth=2, density=True, label=r'$R_e$');
bin_middle = (bin_edge[:-1] + bin_edge[1:])/2
from scipy.stats import gamma
# poisson function, parameter lamb is the fit parameter
def gamma_pdf(x, a, sca):
    return gamma.pdf(x, a, scale=sca, loc=0)
# fit with curve_fit
parameters, cov_matrix = curve_fit(gamma_pdf, bin_middle, count) 

x_plot = np.linspace(0, 10, 200)
plt.plot(x_plot, gamma_pdf(x_plot, *parameters), 'r--', lw=2, zorder=10)
rh_random = np.random.gamma(*parameters, size=[1000])

plt.legend()
plt.savefig('./Figures/gama_z03_m11_distribution.png', bbox_inches='tight')

plt.hist(n_random, bins=np.linspace(0, 10, 50), 
         density=True, histtype='step', lw=2);
plt.hist(rh_random, bins=np.linspace(0, 10, 50), 
         density=True, histtype='step', lw=2);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15991692627206647, 'fraction_numerical': 0.03790238836967809, 'mean_word_length': 3.853904282115869, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '595117', 'license': 'MIT', 'n_tokens_mistral': 799, 'n_tokens_neox': 726, 'n_words': 140, 'path': 'MockGenerate.ipynb', 'repo_name': 'AstroJacobLi/HSC_stacking', 'size': '1926'}