Home > Mateda2.0 > knowledge_extraction > Pareto-approximations > ComputeDiversity.m

# ComputeDiversity

## PURPOSE

[Val] = ComputeDiversity(Pop)

## SYNOPSIS

function[Val] = ComputeDiversity(Pop)

## DESCRIPTION

     [Val] = ComputeDiversity(Pop)
     ComputeDiversity: Computes the average quadratic distance between each pair of vectors
                       in  Pop.
     INPUTS
     Pop: Each row corresponds to a vector
     Val: Average square difference between pairs of vectors

     Last version 2/26/2009. Roberto Santana (roberto.santana@ehu.es)

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function[Val] = ComputeDiversity(Pop)
    0002 % [Val] = ComputeDiversity(Pop)
    0003 % ComputeDiversity: Computes the average quadratic distance between each pair of vectors
    0004 %                   in  Pop.
    0005 % INPUTS
    0006 % Pop: Each row corresponds to a vector
    0007 % Val: Average square difference between pairs of vectors
    0008 %
    0009 % Last version 2/26/2009. Roberto Santana (roberto.santana@ehu.es)
    0010
    0011  Val = 0;
    0012
    0013  [PopSize,n] = size(Pop);
    0014  npairs = PopSize*(PopSize-1)/2;
    0015  for i=1:PopSize-1,
    0016   for j=i+1:PopSize,
    0017     Val = Val + sum((Pop(i,:)-Pop(j,:)).^2);
    0018   end
    0019  end
    0020
    0021  Val = Val/(npairs);