Slides are here

In this tutorial, we demonstrate how to manually create an arbitrary fuzzy measure and call the fuzzy integral.

First, clear your path and figures.

```
``````
close all;
clear all;
```

Next, let there be four inputs (N=4). We create a binary encoded fuzzy measure (we are picking all the variables values, not learning them from data). Below, g(x1)=0.1, g(x1,x2)=0.2, and so on.

```
``````
%number of inputs
N = 4;
%binary encoding of fuzzy measure versus a lexicographically encoded fuzzy measure
% g = [ x1 x2 x12 x3 x13 x23 x123 x4 x14 x24 x124 x34 x134 x234 x1234 ]
g = [ 0.1 0.2 0.2 0.3 0.3 0.3 0.3 0.4 0.4 0.4 0.4 0.4 0.4 0.4 1 ];
```

The binary encoding is as such

```
``````
1 0 0 0 x1
0 1 0 0 x2
1 1 0 0 x12
0 0 1 0 x3
1 0 1 0 x13
0 1 1 0 x23
1 1 1 0 x123
0 0 0 1 x4
1 0 0 1 x14
0 1 0 1 x24
1 1 0 1 x124
0 0 1 1 x34
1 0 1 1 x134
0 1 1 1 x234
1 1 1 1 x1234
```

Next, compute the choquet integral with respect to the inputs h(x1)=0.2, h(x2)=0.3, h(x3)=0.7 and h(x4)=0.2.

```
``````
fi_choquet_integral_h_and_g_form( [0.2 0.3 0.7 0.2] , g )
```

```
ans = 0.3500
```

The discrete (finite X) ChI is simple (see below).

```
function [res] = fi_choquet_integral_h_and_g_form( inputs , FM )
% for discrete (finite X), first sort our inputs
[SortVal, SortInd] = sort( inputs , 2, 'descend' );
% append 0 for difference form below
SortVal = [SortVal zeros(size(inputs,1),1)];
% get the correct indices
i = cumsum(2.^(SortInd-1),2);
% compute the integral
res = sum(FM(i).*(SortVal(:,1:end-1)-SortVal(:,2:end)),2);
end
```

If you want to create a minimum fuzzy measure/ChI, do the following. Note, for 4 inputs (N=4) an OWA (or linear combination of order statistics (LCOS) since we are using all real-valued values) has 4 weights (whats passed to fi_owa). An OWA means sets of equal cardinality in the fuzzy measure have equal value.

```
``````
[g] = fi_owa( [ 0 0 0 1 ] )'
fi_choquet_integral_h_and_g_form( [0.2 0.3 0.7 0.2] , g )
```

```
g =
Columns 1 through 12
0 0 0 0 0 0 0 0 0 0 0 0
Columns 13 through 15
0 0 1
ans =
0.2000
```

Here is some simple code to get the fuzzy measure from the OWA/LCOS weights.

```
function [FMbinary] = fi_owa( weights )
% how many inputs? (N)
nInputs = length(weights);
% how many variables to make?
vars = 1:2.^nInputs-1;
% do our decimal to binary
varsBin = de2bi(vars, nInputs);
% get the number of layers
layers = sum(varsBin,2);
% compute the resultant binary encoded fuzzy measure
FMbinary = arrayfun(@(x) sum(weights(1:x)), layers);
end
```

The next example is for a maximum fuzzy measure/ChI.

```
``````
[g] = fi_owa( [ 1 0 0 0 ] )'
fi_choquet_integral_h_and_g_form( [0.2 0.3 0.7 0.2] , g )
```

```
g =
Columns 1 through 12
1 1 1 1 1 1 1 1 1 1 1 1
Columns 13 through 15
1 1 1
ans =
0.7000
```

The following is for an average fuzzy measure/ChI.

```
``````
[g] = fi_owa( ones(1,4) ./ 4 )'
fi_choquet_integral_h_and_g_form( [0.2 0.3 0.7 0.2] , g )
```

```
g =
Columns 1 through 7
0.2500 0.2500 0.5000 0.2500 0.5000 0.5000 0.7500
Columns 8 through 14
0.2500 0.5000 0.5000 0.7500 0.5000 0.7500 0.7500
Column 15
1.0000
ans =
0.3500
```

Last, we provide a simple example of how to compute a Sugeno lambda fuzzy measure for three densities (N=3), g(x1)=0.2, g(x2)=0.3 and g(x3)=0.1 and h(x1)=0.4, h(x2)=0.2 and h(x3)=0.1.

```
``````
[g, lambda] = fi_sugeno_lambda_measure( [0.2 0.3 0.1] )
fi_choquet_integral_h_and_g_form( [0.4 0.2 0.1] , g )
```

```
g =
0.2000 0.3000 0.6865 0.1000 0.3622 0.4933 1.0000
lambda =
3.1091
ans =
0.2087
```