GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — study-the_algorithms_python/fuzzy_logic at master · Dwaynekj/study-the_algorithms_python

Expand file tree

/

fuzzy_logic

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

fuzzy_logic

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
README.md
README.md
 
 
__init__.py
__init__.py
 
 
fuzzy_operations.py
fuzzy_operations.py
 
 
fuzzy_set_operations.py
fuzzy_set_operations.py
 
 

README.md

Outline

Fuzzy Logic

Fuzzy logic generalizes classical (crisp) set theory: instead of an element either belonging to a set or not, it belongs to a degree between 0 and 1. That degree is given by a membership function mu: X -> [0, 1] over a universe of discourse X. Fuzzy logic is widely used in control systems, decision making, and pattern recognition where boundaries are naturally vague ("young", "warm", "fast").

Learn more:

  • Fuzzy logic
  • Fuzzy set
  • Membership function
  • T-norm (the family of fuzzy AND/OR operators)

Contents

File What it does
fuzzy_operations.py A FuzzySet class modelling a triangular fuzzy number by its (left, peak, right) points, with membership, union, intersection, complement, and plotting. Best when your fuzzy sets are triangular and you want to keep working with the parameters.
fuzzy_set_operations.py The classic Zadeh operators on sampled membership vectors: union, intersection, complement, difference, algebraic_sum/product, and bounded_sum/difference. Works on any membership shape (triangular, trapezoidal, Gaussian, ...) because it operates on the sampled values directly. Dependency-free (NumPy only).

The two files are complementary: fuzzy_operations.py stays in the parametric (left, peak, right) representation, while fuzzy_set_operations.py works on the discretized membership arrays and therefore supports the full set of Zadeh operators for arbitrary shapes.

Quick example

import numpy as np
from fuzzy_logic.fuzzy_set_operations import (
    triangular_membership,
    fuzzy_union,
    fuzzy_intersection,
)

universe = np.linspace(0, 75, 75)
young = triangular_membership(universe, 0, 25, 50)
middle_aged = triangular_membership(universe, 25, 50, 75)

young_or_middle_aged = fuzzy_union(young, middle_aged)
young_and_middle_aged = fuzzy_intersection(young, middle_aged)

Run the doctests for either module with:

python -m doctest -v fuzzy_logic/fuzzy_set_operations.py
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.