1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
{{ objname }}
{{ underline }}
.. plot::
:include-source: False
import openturns as ot
import numpy as np
from matplotlib import pyplot as plt
n_functions = 8
function_factory = ot.{{ objname }}()
if function_factory.getClassName() == "KrawtchoukFactory":
function_factory = ot.{{ objname }}(n_functions, .5)
functions = [function_factory.build(i) for i in range(n_functions)]
measure = function_factory.getMeasure()
if hasattr(measure, "getA") and hasattr(measure, "getB"):
x_min = measure.getA()
x_max = measure.getB()
else:
x_min = measure.computeQuantile(1e-3)[0]
x_max = measure.computeQuantile(1. - 1e-3)[0]
n_points = 200
meshed_support = np.linspace(x_min, x_max, n_points)
fig = plt.figure()
ax = fig.add_subplot(111)
for i in range(n_functions):
plt.plot(meshed_support,
[functions[i](x) for x in meshed_support], lw=1.5,
label=fr"$\phi_{{i}}(x)$")
plt.xlabel(r"$x$")
plt.ylabel(r"$\phi_i(x)$")
plt.xlim(x_min, x_max)
plt.grid()
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width, box.height * 0.9])
plt.legend(loc='upper center', bbox_to_anchor=(.5, 1.25), ncol=4)
.. currentmodule:: {{ module }}
.. autoclass:: {{ objname }}
{% block methods %}
.. automethod:: __init__
{% endblock %}
.. minigallery:: {{module}}.{{objname}}
:add-heading: Examples using the class
|