Plot distributions#

Plot some of the distributions available.

identity, log, logit, cloglog, inv_squared, inverse, smoothlog, softplus
/home/docs/checkouts/readthedocs.org/user_builds/generalized-additive-models/envs/latest/lib/python3.11/site-packages/generalized_additive_models/links.py:431: RuntimeWarning: invalid value encountered in sqrt
  return 1.0 / np.sqrt(linear_prediction)

import matplotlib.pyplot as plt
import numpy as np
from generalized_additive_models.links import LINKS

fig, axes = plt.subplots(2, 4, figsize=(7, 3.5))
axes = axes.ravel()


for ax, (link_name, link_func) in zip(axes, LINKS.items()):
    ax.set_title(link_name)

    # The inverse link functions maps from an
    # unbounded linear space to the domain
    x = np.linspace(-5, 5)
    ax.plot(x, link_func().inverse_link(x))
    ax.grid(True, ls="--", alpha=0.33)

plt.tight_layout()
plt.show()

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

Gallery generated by Sphinx-Gallery