+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Getting Fuzzy: Part 1

  1. #1
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Getting Fuzzy: Part 1

    This is the first part of a three tutorial series, based on fuzzy logic and fuzzy set theory (yes, they are real). Since many of you may not have heard of these, I'm going to spend part 1 explaining what these mathematical concepts are. My plan is to then implement each in C++ in parts 2 and 3.

    What do I mean by "fuzzy"? Have you ever been given a question where you're pretty sure you know the answer, but not quite certain? This is a case where you are dealing with fuzziness. You may be 90% sure you have the right answer, or even 95% sure, but you aren't 100% sure. We deal with this type of uncertainty on a regular basis in life. Xav might tell you about his sexual exploits, and you decide there's a 5% chance he's telling the truth. I might talk about having a masters in math and you decide there's a 50% chance I'm telling the truth.

    I can apply this to the concept of sets as well. In normal set theory, you have to precisely define the set so a potential element is either definitely in or definitely not in the set. This is great for math, but not so great when you want to talk about the "set of tall people". At 5'10", should I be included in the set? How about my 4'11" tall wife? What about Shaquille O'Neal? Since I don't know how tall is tall enough, I might have a 40% chance of being considered tall. My wife a 1% chance, and Shaq a 100% chance.

    These two concepts are closely related. Rather than deal with TRUE or FALSE, we will deal with % likelihood of being true. Rather than deal with IN or OUT of a set, we will deal with % likelihood of being in. 100% means TRUE or definitely IN. 0% means FALSE or definitely OUT.

    Logic has three primary operations: AND, OR, NOT. We need to define these in Fuzzy Logic. However we define them should cause them to be consistent with standard logic. Evaluating the standard and fuzzy interpretations for what we know gives us this:
    TRUE AND TRUE = TRUE --> 100% AND 100% = 100%
    TRUE AND FALSE = FALSE --> 100% AND 0% = 0%
    FALSE AND TRUE = FALSE --> 0% AND 100% = 0%
    FALSE AND FALSE = FALSE --> 0% AND 0% = 0%

    TRUE OR TRUE = TRUE --> 100% OR 100% = 100%
    TRUE OR FALSE = TRUE --> 100% OR 0% = 100%
    FALSE OR TRUE = TRUE --> 0% OR 100% = 100%
    FALSE OR FALSE = FALSE --> 0% OR 0% = 0%

    NOT TRUE = FALSE --> NOT 100% = 0%
    NOT FALSE = TRUE --> NOT 0% = 100%

    Notice that AND gives the smaller percent, OR gives the higher percent, and NOT gives the "opposite" percent. We'll define AND to be the smaller, OR to be the larger, and NOT to be (100% - given).

    Then we'll get:
    75% AND 75% = 75%
    75% AND 25% = 25%
    25% AND 75% = 25%
    25% AND 25% = 25%

    75% OR 75% = 75%
    75% OR 25% = 75%
    25% OR 75% = 75%
    25% OR 25% = 25%

    NOT 75% = 25%
    NOT 25% = 75%

    For Fuzzy Set Theory, we need to define equivalents to UNION, INTERSECTION, and COMPLEMENT:
    If the "universe" (all available elements) is {1,2,3,4,5}:
    {1,2,3} INTERSECT {2,3,4} = {2,3}
    {1,2,3} UNION {2,3,4} = {1,2,3,4}
    COMPLEMENT {1,2,3} = {4,5}

    Translating this to Fuzzy Sets gives us:
    {1: 100%, 2: 100%, 3: 100%, 4: 0%, 5: 0%} INTERSECT {1: 0%, 2: 100%, 3: 100%, 4: 100%, 5: 0%} = {1: 0%, 2: 100%, 3: 100%, 4: 0%, 5: 0%}

    {1: 100%, 2: 100%, 3: 100%, 4: 0%, 5: 0%} UNION {1: 0%, 2: 100%, 3: 100%, 4: 100%, 5: 0%} = {1: 100%, 2: 100%, 3: 100%, 4: 100%, 5: 0%}

    COMPLEMENT {1: 100%, 2: 100%, 3: 100%, 4: 0%, 5: 0%} = {1: 0%, 2: 0%, 3: 0%, 4: 100%, 5: 100%}

    Notice again that INTERSECT gets the low percentage for each element, UNION gets the high percentage for each element, and COMPLEMENT gets the "opposite" percentage for each element. So some fuzzy sets would give:
    {1: 100%, 2: 75%, 3: 60%, 4: 20%, 5: 0%} INTERSECT {1: 0%, 2: 80%, 3: 65%, 4: 60%, 5: 30%} = {1: 0%, 2: 75%,3: 60%, 4: 20%, 5: 0%}

    {1: 100%, 2: 75%, 3: 60%, 4: 20%, 5: 0%} UNION {1: 0%, 2: 80%, 3: 65%, 4: 60%, 5: 30%} = {1: 100%, 2: 80%,3: 65%, 4: 60%, 5: 30%}

    COMPLEMENT {1: 100%, 2: 75%, 3: 60%, 4: 20%, 5: 0%} = {1: 0%, 2: 25%,3: 40%, 4: 80%, 5: 100%}

    The goal, then, is to take these two concepts, and create classes equivalent to the set and boolean template/type. We won't try to perfectly recreate the mathematical objects, but we would like to extend the C++ functionality that already exists.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: Getting Fuzzy: Part 1

    Excellent read. I'm 90% sure I understand what you are talking about. +rep

  4. #3
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Getting Fuzzy: Part 1

    The key is, if this doesn't make any sense, the tutorials to follow will really not make sense.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  5. #4
    Jordan Guest

    Re: Getting Fuzzy: Part 1

    My response was fuzzy.

    Thanks for the excellent read. I intend on reading part 2 fully in just a few minutes (if I can find it on my mobile).

    Posted via CodeCall Mobile

  6. #5
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Getting Fuzzy: Part 1

    I would imagine that reading code on a mobile device is not the most pleasant of experiences.

    Implementing a Fuzzy Boolean is part II.
    Last edited by WingedPanther; 11-14-2008 at 07:33 PM. Reason: add followup link
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  7. #6
    Join Date
    Jul 2008
    Location
    Somewhere that is shorter to write than "In the gloomy shadows of my personal namespace"
    Posts
    10,725
    Blog Entries
    2
    Rep Power
    90

    Re: Getting Fuzzy: Part 1

    Interesting I've used something similar in a smaller scale +rep
    Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

  8. #7
    Join Date
    Aug 2007
    Location
    Gizeh, Al Jizah, Egypt, Egypt
    Posts
    8,675
    Blog Entries
    12
    Rep Power
    81

    Re: Getting Fuzzy: Part 1

    Wow gr8
    i read about fuzzy but ive never seen real implementation
    thnx alot
    Posted via CodeCall Mobile

  9. #8
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Getting Fuzzy: Part 1

    Xav might tell you about his sexual exploits, and you decide there's a 5% chance he's telling the truth.
    You missed out on your +rep for that.

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

  10. #9
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Getting Fuzzy: Part 1

    LOL. It was worth the lost rep.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  11. #10
    Join Date
    Mar 2008
    Location
    The North Pole
    Posts
    13,174
    Blog Entries
    13
    Rep Power
    114

    Re: Getting Fuzzy: Part 1

    All 75 points?

    Quote Originally Posted by Jordan View Post
    Good members, like yourself, stick around and post for ages to come!
    Mr. Xav | Blog | Forums

+ Reply to Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Intermediate Implementing a Fuzzy Set
    By WingedPanther in forum C Tutorials
    Replies: 11
    Last Post: 01-25-2011, 02:42 AM
  2. Intermediate Extending the Fuzzy Set
    By WingedPanther in forum C Tutorials
    Replies: 14
    Last Post: 11-29-2010, 07:05 PM
  3. Help to run Fuzzy Logic Library
    By ammaerz in forum C and C++
    Replies: 4
    Last Post: 09-03-2010, 12:42 AM
  4. My Fuzzy Boolean Implementation
    By MeTh0Dz in forum C and C++
    Replies: 6
    Last Post: 11-22-2008, 12:47 PM
  5. Intermediate Implementing a Fuzzy Boolean
    By WingedPanther in forum C Tutorials
    Replies: 3
    Last Post: 11-18-2008, 11:42 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts