Independence Sims

Independence simulations are found in Here, we visualize what these simulations look like. Noise-free simulations are overlaid over the noisy simulation. Note that the last 2 simulations have no noise parameter. These simulations were chosen as an aggregate of many popularly tested equations in the literature.

Independence Simulations, Linear, Exponential, Cubic, Joint Normal, Step, Quadratic, W-Shaped, Spiral, Bernoulli, Logarithmic, Fourth Root, Sine 4π, Sine 16π, Square, Two Parabolas, Circle, Ellipse, Diamond, Noise, Independence
import matplotlib.pyplot as plt
import seaborn as sns
from import SIMULATIONS

# make plots look pretty
sns.set(color_codes=True, style="white", context="talk", font_scale=2)
PALETTE = sns.color_palette("Greys", n_colors=9)

# constants
NOISY = 100  # sample size of noisy simulation
NO_NOISE = 1000  # sample size of noise-free simulation

# simulation titles
    "Joint Normal",
    "Fourth Root",
    "Sine 4\u03C0",
    "Sine 16\u03C0",
    "Two Parabolas",

# make a function that runs the code depending on the simulation
def plot_sims():
    """Plot simulations"""
    fig, ax = plt.subplots(nrows=4, ncols=5, figsize=(28, 24))

    plt.suptitle("Independence Simulations", y=0.93, va="baseline")

    for i, row in enumerate(ax):
        for j, col in enumerate(row):
            count = 5 * i + j
            sim_title = SIM_TITLES[count]
            sim = list(SIMULATIONS.values())[count]

            # the multiplicative noise and independence simulation don't have a noise
            # parameter
            if sim_title in ["Noise", "Independence"]:
                x, y = sim(NO_NOISE, 1)
                x_no_noise, y_no_noise = x, y
                x, y = sim(NOISY, 1, noise=True)
                x_no_noise, y_no_noise = sim(NO_NOISE, 1)

            # plot the noise and noise-free sims
            col.scatter(x, y, label="Noisy")
            col.scatter(x_no_noise, y_no_noise, label="No Noise")

            # make the plot look pretty
            if count == 16:
                col.set_ylim([-1, 1])
            sns.despine(left=True, bottom=True, right=True)

    leg = plt.legend(
        bbox_to_anchor=(0.5, 0.1),
        loc="upper center",
    for legobj in leg.legendHandles:

# run the created function for the simultions

Total running time of the script: ( 0 minutes 0.772 seconds)

Gallery generated by Sphinx-Gallery