1 / 14

5.2 Functions for Computer Science

5.2 Functions for Computer Science. In a previous section, we have come to understand the characteristic function. Universal Set (U)= {1,2,3,4,5,6,7,8,9,10} A = {4,7,9} A is a subset of the Universal Set. The characteristic function of A is defined as a function from U to {0,1} by:

catherinek
Télécharger la présentation

5.2 Functions for Computer Science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 5.2 Functions for Computer Science

  2. In a previous section, we have come to understand the characteristic function. Universal Set (U)= {1,2,3,4,5,6,7,8,9,10} A = {4,7,9} A is a subset of the Universal Set. The characteristic function of A is defined as a function from U to {0,1} by: FA (Ui) = {1 if Ui∈ A, 0 if Ui∈ A} FA(1) = 0 1 in not an element of A FA (2) = 0 2 in not an element of A FA (3) = 0 3 in not an element of A FA (4) = 1 4 is an element of A FA(5) = 0 5 in not an element of A FA(6) = 0 6 in not an element of A FA(7) = 1 7 is an element of A FA(8) = 0 8 is not an element of A FA(9) = 1 9 in an element of A FA(10) = 0 10 in not an element of A FA(12) is undefined as 12 is not an element of A nor of the Universal Set

  3. Floor function Floor function is the largest integer less than or equal to q, where q is a rational number and is denoted ⌊q⌋ f (1.5) = ⌊1.5⌋ = 1 f (-3) = ⌊-3⌋ = -3 f (-2.7) = ⌊-2.7⌋ = -3 (-3 is less than -2.7)

  4. Ceiling Function Ceiling function is the smallest integer greater than or equal to q, where q is a rational number and denoted ⌈q⌉. c (1.5) = ⌈1.5⌉ = 2 c (-3) = ⌈-3⌉ = -3 c (-2.7) = ⌈-2.7⌉ = -2

  5. Base 2 Exponential Function Base 1 logarithm of 32 is 5 5 is how many 2’s must be multiplied to equal 32. 25 = 32 Base 10 logarithm of 1000 is 3. 3 is how many 10’s must be multiplied to equal 1000. 103 = 1000

  6. Hashing Function A hashing function can be used for storage of data. function h of (n) = n of (mod x) Written as: h(n) = n(mod x) x is a prime number Mod stands for modulus We are looking for the remainder h(23) = 23 (mod 3) 23/3 = 7 remainder 2 h(23) = 2

  7. Hashing function example page 1 • 10,000 customer records to store • The computer is able to search a list of 100 records in a short period of time • 101 linked lists will be created for storage • Each customer is assigned a unique 7 digit account number • Define a hashing function form the set of 7 digit numbers to the set {0,1,2,3…..,100} as follows: Function h of (n) = n of (mod 101) written as: h(n) = n(mod 101)

  8. Hashing function example page 2 • Account # 2473871 would be assigned to list 78 h(2473871) = 2473871(mod 101) = 78 2473871/101 = 24493 Remainder 78 • If the first position of list 78 is already occupied, a collision occurs. To resolve this problem, the record will be inserted at the end of the existing list.

  9. Fuzzy Sets The descriptions of many collections are not precise and are subjective. The collection of tall humans. What is considered to be tall? The collection of rich people. What is considered rich? The collection of useful laws. What is considered to be useful?

  10. We need a precise way to handle these fuzzy collections. A fuzzy set in a universal set U is a function f defined on U and having values in the interval [0,1] Recall the characteristic function U = {1,2,3,4} A = {1,2} The characteristic function of A with respect to the universal set is 1100. If the characteristic function of x f(x) = 0 then, x is not in the fuzzy set. If f(x) = 1, then, x is in the fuzzy set. If 0<f(x)<1 (If the characteristic function of x is less than 1 and greater than 0), then the characteristic function of x can be thought of as the degree to which x is in the fuzzy set.

  11. Fuzzy set example U = yearly incomes between $0 and $1,000,000 in thousands U is the interval [0 (least), 1,000 (greatest)] Define the fuzzy set of rich people based on annual income. • Set annual income greater than $250,000 as definitely rich • Set annual income less than $30,000 as definitely not rich • Income between $30,000 and $250,000 has some degree of richness. • 250 – 30 = 220 f(x) = (x-30)/220 30 ≤ x ≤ 250 • A person makes $100,000 per year (100-30)/220 = 7/22 or .32 in the fuzzy set • A person making less than $30,000 per year is not in the fuzzy set at all. • A person making $300,000 per year is definitely rich • See graph 5.4 on page 194.

  12. Fuzzy set operations: Unions, intersections and compliments can be formed on fuzzy sets. A and B are subsets of the same universal set U. • f A∩B(x) = min{fa(x),fb(x)} The characteristic function of A intersect B of x = minimum of {characteristic function of a of (x), characteristic function of b of (x)} B. f A∪B(x) = max {fa(x), f b (x)} C. fA (x) = 1-fA(x)

  13. Fuzzy set operations example page 1 2 fuzzy sets f and g (page 195) • f(x) = 1/16x2 for 0 ≤ x < 4 1 for 4 ≤x < 6 -1/2x + 4 for 6 ≤ x < 8 0 for 8 ≤x ≤10 • g(x) = 1/3x for 0 ≤x < 3 -1/4x + 7/4 for 3 ≤x < 5 ½ for 5 ≤x < 7 -1/6x + 10/6 for 7 ≤x ≤10

  14. Fuzzy set operations example page 2 Compute the degree of membership of 3.5 in f ∩ g • 3.5, for f(x) definition, falls in 0 ≤ x < 4, so we will use 1/16x2. Replace x with 3.5: f(3.5) = 1/16(3.52) = 49/64 • 3.5, for g(x) definition, falls in 3 ≤ x < 5, so we will use -1/4x + 7/4 Replace x with 3.5: g(3.5) = -1/4(3.5) + 7/4 = 3.5/4 = 56/64 • (f ∩g)(3.5) = min {49/64,56/64} (f ∩g)(3.5) = 49/64 b. (f ∪g)(3.5) = max {49/64,56/64} (f ∪g)(3.5)=56/64 c. fA(x) = 1-fA(x) fA(x) = 1-49/64 fA(x) = 15/64

More Related