mixFraction

PURPOSE ^

mixFraction compares two sets of sampled points and determines how mixed

SYNOPSIS ^

function mix = mixFraction(sample1, sample2, fixed)

DESCRIPTION ^

 mixFraction compares two sets of sampled points and determines how mixed
 they are.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mix = mixFraction(sample1, sample2, fixed)
0002 % mixFraction compares two sets of sampled points and determines how mixed
0003 % they are.
0004 
0005 %INPUTs
0006 % sample1, sample2      Ordered set of points.  The points must be in
0007 %                       the same order otherwise it does not make sense.
0008 %
0009 %OPTIONAL INPUT
0010 % fixed (optional)      The directions which are fixed and are not expected
0011 %                       to mix.  They are ignored.
0012 %
0013 %OUTPUT
0014 % mix                   the mix fraction.  Goes from 0 to 1 with 1 being
0015 %                       completely unmixed and .5 being essentially
0016 %                       perfectly mixed.
0017 
0018 if nargin <3
0019     fixed = [];
0020 end
0021 
0022 sample1 = full(sample1);
0023 sample2 = full(sample2);
0024 
0025 sample1(fixed, :) = zeros(length(fixed), size(sample1,2));
0026 sample2(fixed, :) = zeros(length(fixed), size(sample2,2));
0027 
0028 m1 = median(sample1, 2);
0029 LPproblem = median(sample2, 2);
0030 
0031 l1 = sample1 > m1*ones(1, size(sample1,2));
0032 eq1 = sample1 == m1*ones(1, size(sample1,2));
0033 l2 = sample2 > LPproblem*ones(1, size(sample1,2));
0034 eq2 = sample2 == LPproblem*ones(1, size(sample1,2));
0035 
0036 eqtotal = eq1 | eq2;
0037 
0038 mix = sum(sum((l1 == l2) & ~eqtotal))/(numel(l1)-sum(sum(eqtotal)));

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003