AiSc 3

Pasted Nov 4, 2026, 3:46 PM1 file20 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/ai3
untitled
def triangular_membership(x, a, b, c):
    """Calculates fuzzy membership value for a triangular distribution."""
    if x <= a or x >= c:
        return 0.0
    elif a < x <= b:
        return (x - a) / (b - a)
    elif b < x < c:
        return (c - x) / (c - b)
    return 0.0


# Test with parameters: a=2, b=5, c=8
a, b, c = 2, 5, 8
test_inputs = [1, 3.5, 5, 6.5, 9]

print(f"Triangular Function (a={a}, b={b}, c={c}):")

for x in test_inputs:
    degree = triangular_membership(x, a, b, c)
    print(f"  Input x = {x:<4} -> Membership Degree = {degree:.2f}")

564 chars · codepastes.com