Beispiel #1
0
from docs.source.plots.membership_functions.membership_plot import draw_mf
from yvain.membership_functions import Sigmoid
import matplotlib.pyplot as plt

if __name__ == '__main__':
    draw_mf(Sigmoid(5, 2), 0, 10, "Sigmoid(a=5, b=2)")
    draw_mf(Sigmoid(5, -2), 0, 10, "Sigmoid(a=5, b=-2)")
    plt.vlines(5, ymin=0, ymax=1, colors="gray", linestyles="--")
Beispiel #2
0
from docs.source.plots.membership_functions.membership_plot import draw_mf
from yvain.membership_functions import Gaussian
import matplotlib.pyplot as plt

if __name__ == '__main__':
    mu, sigma = 5, 2
    draw_mf(Gaussian(mu=5, sigma=2), 0, 10, f"Gaussian(mu={mu}, sigma={sigma})")
    plt.vlines(mu, ymin=0, ymax=1, colors="gray",
               linestyles="--")
Beispiel #3
0
from math import isclose

import numpy as np

from docs.source.plots.membership_functions.membership_plot import draw_mf
from yvain.membership_functions import Trapezoid
import matplotlib.pyplot as plt

if __name__ == '__main__':
    a, b, c, d = 1, 3, 7, 9
    universe_start, universe_end = 0, 10
    universe = np.linspace(universe_start, universe_end, 1000)
    mf = Trapezoid(a=1, b=3, c=7, d=9)

    draw_mf(mf, universe_start, universe_end,
            f"Trapezoid(a={a}, b={b}, c={c}, d={d})")
    plt.fill_between(universe, [mf(x) if isclose(mf(x), 1) else 0 for x in universe],
                     alpha=0.4, color="grey")
    plt.vlines([b, c], ymin=0, ymax=1, colors="gray",
               linestyles="--")
Beispiel #4
0
from docs.source.plots.membership_functions.membership_plot import draw_mf
from yvain.membership_functions import Triangle
import matplotlib.pyplot as plt

if __name__ == '__main__':
    a, b, c = 2, 5, 8
    draw_mf(Triangle(a=a, b=b, c=c), 0, 10, f"Triangle(a={a}, b={b}, c={c})")
    plt.vlines(b, ymin=0, ymax=1, colors="gray",
               linestyles="--")
Beispiel #5
0
from docs.source.plots.membership_functions.membership_plot import draw_mf
from yvain.membership_functions import Bell
import matplotlib.pyplot as plt

if __name__ == '__main__':
    mu, sigma, gamma = 5, 2, 2
    draw_mf(Bell(mu=mu, sigma=sigma, gamma=gamma), 0, 10,
            f"Bell(mu={mu}, sigma={sigma}, gamma={gamma})")
    plt.vlines(mu, ymin=0, ymax=1, colors="gray", linestyles="--")