3def fuzzy_quantifier1(p, alpha, beta, increasing=True):
4 """
5 Compute the degree of membership to a fuzzy quantifier.
6
7 Parameters:
8 - p : float or np.array
9 Proportion(s) in the [0, 1] range.
10 - alpha : float
11 Lower threshold (start of transition).
12 - beta : float
13 Upper threshold (full membership).
14 - increasing : bool
15 True for quantifiers like "most", False for "few".
16
17 Returns:
18 - float or np.array
19 Degree(s) of truth for the fuzzy quantifier.
20 """
21 p = np.asarray(p)
22
23 if increasing:
24
25 return np.where(p <= alpha, 0,
26 np.where(p >= beta, 1,
27 (p - alpha) / (beta - alpha)))
28 else:
29
30 return np.where(p <= alpha, 1,
31 np.where(p >= beta, 0,
32 (beta - p) / (beta - alpha)))
33
34