Re: How is the degree of membership calculated?

CRPFALKSD (crpfalksd@aol.com)
Tue, 28 Apr 1998 16:48:41 +0200 (MET DST)

Fuess wrote:
>crpfalksd@aol.com (CRPFALKSD) wrote:
>
>> Cool Just Right Warm
>> 1 | /\ /\ /\
>> | / \ O \ / \
>> | / \ / \ / \
>> | / X X \
>> | / / \ / \ \
>> | / / O / \ \
>> 0 |/______/_____\/_____\______\_____
>> 45 60 65 70 85
>>
>
>Each MF, as represented above, is a piecewise linear function of one
>variable so, for example,
>Just_Right(X) =
> 0 for x < 60
> (x-60)/5 for 60 <= x < 65
> 1-(x-65)/5 for 65 <= x <= 70
> 0 for x > 70.
>Normally one then takes the maximum value over all of the memberships
>for the linguistic set and assigns that to the result. Hence, in the
>above example one would assert that the temperature is Just Right.

Given this information, would the following be correct:

0 for x < term minimum
(x-term minimum)/5 for term minimum <= x < term top
1-(x-term top)/5 for term top <= x < term maximum
0 for x > term maximum

And would the following program work (I tested it and it seems to be okay.
It's based upon the figures just mentioned.)?:

/* Program to determine the degree of membership of a temperature in
JUST_RIGHT
Language: C/C++
Created: 4/23/1998
By: David Falksen
*/

#include <stdio.h>

void main(void){
//Define Terms
double JUST_RIGHT_MINIMUM = 60;
double JUST_RIGHT_MAXIMUM = 70;
double JUST_RIGHT_TOP = 65;

//Define Misc.
double TEMPERATURE = 66;
double just_right_membership_value = 0;

//If TEMPERATURE below term range, set membership to Zero
if (TEMPERATURE < JUST_RIGHT_MINIMUM){
just_right_membership_value = 0;
}

//If TEMPERATURE between minimum and top, compute membership
else if ( (JUST_RIGHT_MINIMUM <= TEMPERATURE) && (TEMPERATURE <
JUST_RIGHT_TOP) ){
printf ("%f\n",just_right_membership_value);
just_right_membership_value = (TEMPERATURE - JUST_RIGHT_MINIMUM)/5;
printf ("%f\n",just_right_membership_value);
}

//If TEMPERATURE between top and maximum, compute membership
else if ( (JUST_RIGHT_TOP <= TEMPERATURE) && (TEMPERATURE <
JUST_RIGHT_MAXIMUM) ){
just_right_membership_value = 1-(TEMPERATURE - JUST_RIGHT_TOP)/5;
printf ("%f\n",just_right_membership_value);
}

//If TEMPERATURE beyond term range, set membership to Zero
else if (TEMPERATURE > JUST_RIGHT_MAXIMUM){
just_right_membership_value = 0;
}//End If..Else

}//End Main

I appreciate your help so far!