<jupyter_start><jupyter_text>Latin Hypercube SamplingAuthor: <NAME>Date: June 04, 2018 In this example, the Latin Hypercube design is employed to generate samples from a normal distribution. The method illustrates various aspects of the UQpy LHS class.  Import the necessary libraries. Here we import standard libraries such as numpy and matplotlib, but also need to import the LHS class from UQpy.<jupyter_code>from UQpy.SampleMethods import LHS
import numpy as np
import matplotlib.pyplot as plt
import time<jupyter_output><empty_output><jupyter_text>Run LHS using the different criterion for 5 samples.    - 2 dimensions    - Normal pdf with unit variance. Run with criterion as 'random'<jupyter_code>x = LHS(dist_name=['Uniform', 'Normal'], dist_params=[[2, 5], [0, 1]], lhs_criterion='random', lhs_metric=None, lhs_iter=None, nsamples=5)
samples_random = x.samplesU01<jupyter_output>Successful execution of LHS design..<jupyter_text>Run with criterion as 'centered'<jupyter_code>y = LHS(dist_name=['Normal', 'Normal'], dist_params=[[0, 1], [0, 1]], lhs_criterion='centered', lhs_metric=None, lhs_iter=None, nsamples=5)
samples_centered = y.samplesU01<jupyter_output><empty_output><jupyter_text>Run with criterion as 'maximin'<jupyter_code>z = LHS(dist_name=['Normal', 'Normal'], dist_params=[[0, 1], [0, 1]], lhs_criterion='maximin', lhs_metric='euclidean', lhs_iter=100, nsamples=5)
samples_maximin = z.samplesU01<jupyter_output><empty_output><jupyter_text>Run with criterion as 'correlate'<jupyter_code>u = LHS(dist_name=['Normal', 'Normal'], dist_params=[[0, 1], [0, 1]], lhs_criterion='correlate', lhs_metric=None, lhs_iter=100, nsamples=5)
samples_correlate = u.samplesU01
fig, ax = plt.subplots()
plt.title('random-LHS design')
plt.scatter(samples_random[:, 0], samples_random[:, 1])
ax.set_yticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.set_xticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.yaxis.grid(True)
ax.xaxis.grid(True)
plt.ylim(0, 1)
plt.xlim(0, 1)
plt.show()
fig, ax = plt.subplots()
plt.title('centered-LHS design')
plt.scatter(samples_centered[:, 0], samples_centered[:, 1])
ax.set_yticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.set_xticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.yaxis.grid(True)
ax.xaxis.grid(True)
plt.ylim(0, 1)
plt.xlim(0, 1)
plt.show()
fig, ax = plt.subplots()
plt.title('maximin-LHS design')
plt.scatter(samples_maximin[:, 0], samples_maximin[:, 1])
ax.set_yticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.set_xticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.yaxis.grid(True)
ax.xaxis.grid(True)
plt.ylim(0, 1)
plt.xlim(0, 1)
plt.show()
fig, ax = plt.subplots()
plt.title('correlate-LHS design')
plt.scatter(samples_correlate[:, 0], samples_correlate[:, 1])
ax.set_yticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.set_xticks([0.0, 0.2, 0.4, 0.6, 0.8, 1.0])
ax.yaxis.grid(True)
ax.xaxis.grid(True)
plt.ylim(0, 1)
plt.xlim(0, 1)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17456445993031358, 'fraction_numerical': 0.05644599303135889, 'mean_word_length': 6.124069478908188, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '33743', 'license': 'MIT', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1204, 'n_words': 266, 'path': 'example/LHS/LHS.ipynb', 'repo_name': 'volpatto/UQpy', 'size': '2879'}