Open In Colab

fastkde.plot Example

This notebook demonstrates basic usage of fastkde.plot.

import numpy as np

try: 
    import fastkde
except:
    # install fastkde if not already installed
    !pip install fastkde
    import fastkde

For this example, we will generate data with the following relationships:

$$ x := \mathcal{N}(0,1)$$ $$ y := \mathcal{N}(x,1)$$ $$ z := \mathcal{N}(3x + 2y, 0.2)$$

""" Sample the three variables """
N = int(1e4)
x = np.random.normal(size=N)
y = x + np.random.normal(scale=1, size=N)
z = 3 * x + 2 * y + np.random.normal(scale=0.2, size=N)
""" Demonstrate the fastkde.pair_plot function """

fastkde.pair_plot([x, y, z], var_names=["x", "y", "z"])
../_images/006a8504aad1648c9ed17d04d37d1408286d97631985c47afd17839764d921be.png
""" Demonstrate the pair_plot function, plotting conditional distributions """

fastkde.pair_plot([x, y, z], var_names=["x", "y", "z"], conditional=True)
../_images/4d0a7644122c70d4ac6522d70776a1b8825948698b2128b639e8823c0bff503c.png