<jupyter_start><jupyter_text>MMH Initial Samples<jupyter_code>model = RunModel(model_script='Rosenbrock_pfn.py', model_object_name="RunPythonModel", ntasks=1)
dist = Rosenbrock(p=100.)
dist_prop1 = Normal(loc=0, scale=1)
dist_prop2 = Normal(loc=0, scale=10)

x = stats.norm.rvs(loc=0, scale=1, size=(100,2), random_state=83276)

mcmc_init1 = MMH(dimension=2, log_pdf_target=dist.log_pdf, seed=x, nburn=1000, 
                 proposal=[dist_prop1, dist_prop2], random_state=8765)
mcmc_init1.run(10000)

x_ss_MMH = SubsetSimulation(mcmc_class=Stretch, runmodel_object=model, p_cond=0.1, 
                            nsamples_per_ss=10000, verbose=False, samples_init=mcmc_init1.samples, 
                            log_pdf_target=dist.log_pdf, dimension=2, nchains=1000, random_state=38546)
for i in range(len(x_ss_MMH.g)):
    plt.scatter(x_ss_MMH.samples[i][:, 0], x_ss_MMH.samples[i][:, 1], marker='o')
plt.grid(True)
plt.xlabel(r'$X_1$')
plt.ylabel(r'$X_2$')
plt.yticks(np.arange(-20, 180, step=20))
plt.xlim((-10,15))
plt.tight_layout()
plt.savefig('Rosenbrock_MMH.pdf')
plt.show()
print(x_ss_MMH.pf)<jupyter_output>4.0450000000000015e-08<jupyter_text>Stretch Initial Samples<jupyter_code>model = RunModel(model_script='Rosenbrock_pfn.py', model_object_name="RunPythonModel", ntasks=1)
dist = Rosenbrock(p=100.)

x = stats.norm.rvs(loc=0, scale=1, size=(100,2), random_state=83276)

# mcmc_init2 = Stretch(dimension=2, log_pdf_target=dist.log_pdf, seed=x, jump=100, nburn=1000, random_state=8765)
mcmc_init2 = Stretch(dimension=2, log_pdf_target=dist.log_pdf, seed=x, nburn=1000, random_state=8765)
mcmc_init2.run(10000)

# dist = Distribution(dist_name='rosenbrock', params=[10])
# dist_prop = [Distribution(dist_name=['normal'], params=[[0, 1]]), 
#             Distribution(dist_name=['normal'], params=[[0, 10]])]
# mcmc_object = MCMC(dimension=2, algorithm='Stretch', log_pdf_target=dist.log_pdf, seed=x)
x_ss_Stretch = SubsetSimulation(mcmc_class=Stretch, runmodel_object=model, p_cond=0.1, 
                            nsamples_per_ss=10000, verbose=False, samples_init=mcmc_init2.samples, 
                            log_pdf_target=dist.log_pdf, dimension=2, nchains=1000, random_state=83456)
for i in range(len(x_ss_Stretch.g)):
    plt.scatter(x_ss_Stretch.samples[i][:, 0], x_ss_Stretch.samples[i][:, 1], marker='o')
plt.grid(True)
plt.xlabel(r'$X_1$')
plt.ylabel(r'$X_2$')
plt.yticks(np.arange(-20, 180, step=20))
plt.xlim((-10,15))
plt.tight_layout()
plt.savefig('Rosenbrock_Stretch.pdf')
plt.show()
print(x_ss_Stretch.pf)
plt.figure()
plt.plot(mcmc_init2.samples[:,0], mcmc_init2.samples[:,1],'o')
plt.plot(mcmc_init1.samples[:,0], mcmc_init1.samples[:,1],'x')
plt.grid(True)
plt.xlabel(r'$X_1$')
plt.ylabel(r'$X_2$')
plt.yticks(np.arange(-20, 180, step=20))
plt.xlim((-10,15))
plt.tight_layout()
plt.savefig('Rosenbrock_Compare.pdf')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17098445595854922, 'fraction_numerical': 0.06839378238341969, 'mean_word_length': 6.186104218362283, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '95732', 'license': 'MIT', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1215, 'n_words': 146, 'path': 'example/Reliability/SubsetSimulation/Example3/Rosenbrock_Initial.ipynb', 'repo_name': 'shellshocked2003/UQpy', 'size': '2895'}