    # Trust Function Evaluation (and Cultural Tolerance)   HOME    The idea of trust evaluation is that it provides a mechanism to map from an observed input (being the Hamming distance between individual cultural identities) onto an output action (being the attitude towards the iterated Prisoner's Dilemma game).

For the purpose of evolutionary computation, we need a function that can adapt (i.e. it must not be a fixed function) and no particular forced bias should be built into this. This simulation uses a three-parameter quadratic function which can approximately be split into low / middle / high as plotted in the graphs below.

```double tolfunc( double x,
double q_l, double q_m, double q_h )
{
double y = 0;

if( x < 0 ) x = 0;
if( x > 1 ) x = 1;
y +=     ( 1 - x ) * q_l; /* low    */
y += x * ( 1 - x ) * q_m; /* middle */
y += x             * q_h; /* high   */
if( y > 1 ) y = 1;
if( y < 0 ) y = 0;
return( y );
}
```

Above is the C-code for this function, which includes hard limits on both the input and output to keep within the bounds of zero to one. In principle, the Hamming distance (seen as a percentage) only makes sense between zero (i.e. culturally identical) and one (i.e. total antithesis). Sometimes these components are knowns as shape functions.

## Results from Simulation

By plotting the statistical density of actual interactions between individuals in the simulation, we can get an idea of how the tolerance function operates in practice (this is at the end of the simulation, where the parameters have evolved and settled to a stable position). Note that the general outcome is always that individuals very culturally similar (i.e. low Hamming distance) tend to be cooperative, and those at a large Hamming distance tend to be non-cooperative. However, in the middle there is a threshold where it rapidly swings across from one to the other. Also note that the majority of actual interactions are cooperative. ## Plots Showing Effect of Parameters   