<jupyter_start><jupyter_text>import libraries<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os

from bloatedHJs import read_planet_data 
from bloatedHJs import SinglePlanetModel
from bloatedHJs import corner_plot
from bloatedHJs import inference
# configure matplotlib for better visualisations
from matplotlib import rcParams as rc

rc['xtick.top'] = True
rc['xtick.major.size']     = 6
rc['xtick.minor.size']     = 3

rc['xtick.direction']      = 'in'
rc['xtick.minor.visible']  = True 
rc['xtick.minor.top']      = True 
rc['xtick.minor.bottom']   = True 

rc['ytick.right']          = True
rc['ytick.major.size']     = 6
rc['ytick.minor.size']     = 3

rc['ytick.direction']      = 'in'
rc['ytick.minor.visible']  = True
rc['ytick.major.right']    = True
rc['ytick.minor.right']    = True

rc['font.size']            = 16
rc['xtick.major.pad']      = 8.0
rc['xtick.minor.pad']      = 8.0
np.random.seed(1234)<jupyter_output><empty_output><jupyter_text>Load planet data<jupyter_code>fp = 'data/sys_HD_209458'
data = read_planet_data(fp)
data = data.iloc[0]
sys = fp.split('sys_')[1]
if not os.path.exists(sys):
    os.mkdir(sys)
data<jupyter_output><empty_output><jupyter_text>Posterior Analysis In this section, we will study the effect of choosing different priors on the inferred internal lmuinosity `Lumi` of the planet (this is the main parameter of interest).To do this, we will assume `Lumi` follows two different distributions:1- uniform distribution in linear space2- uniform distribution in log spaceFor more details why we chose these priors, check the paper ;)  This can be easily done by running MCMC twice and setting `lumi_linear=True` and `lumi_linear=False`, respectively.  Lumi ~ linear uniform distribution<jupyter_code># MCMC was already ran in single_planet_demo notebook
# we're just loading the samples in this notebook
samples_posterior_linear = pd.read_csv('HD_209458/HD_209458_lumilinear_posterior_chains.csv', index_col=0)<jupyter_output><empty_output><jupyter_text>Lumi ~ log uniform<jupyter_code>sp_post_log = SinglePlanetModel(data, lumi_linear=False, progress=False)
samples_posterior_log = sp_post_log.run_mcmc()<jupyter_output>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           HD_209458_lumilog_posterior
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Running MCMC -- 50 walkers -- 500 nburn -- 500 nsteps ... 

Running burn-in ...
Acceptance ratio in the burn-in stage ... 0.5417

Running production chain...
Acceptance ratio 0.5092
MCMC DONE !
Saving samples ... DONE !<jupyter_text>Compare the posterior distributions<jupyter_code>plt.figure(figsize=(12,9))
plt.hist(np.log10(samples_posterior_linear['Lumi']), 20, \
         color='C0', label='Linear-Uniform', density=True)
plt.hist(samples_posterior_log['Lumi'], 20, \
         color='C3', label='Log-Uniform', density=True, alpha=0.5)
plt.legend()
plt.xlabel(r'log$_{10}$ Internal Luminosity [L$_{\rm J}$]')
plt.ylabel('PDF');
plt.figure(figsize=(12,9))
plt.hist(samples_posterior_linear['Epsilon'], 20, \
         color='C0', label='Linear-Uniform', density=True)
plt.hist(samples_posterior_log['Epsilon'], 20, \
         color='C3', label='Log-Uniform', density=True, alpha=0.5)
plt.legend()
plt.xlabel(r'Epsilon [%]')
plt.ylabel('PDF')
plt.xlim(0, 5);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15513626834381553, 'fraction_numerical': 0.026654687032045522, 'mean_word_length': 5.173752310536044, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '525570', 'license': 'MIT', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1121, 'n_words': 262, 'path': 'single_planet_choice_of_prior.ipynb', 'repo_name': 'psarkis/bloatedHJs', 'size': '3339'}