function [ far,  frr,  hter ] = far_frr( tp, fp, tn, fn );

% FUNCTION [ FAR,  FRR,  HTER ] = FAR_FRR( TP, FP, TN, FN );
	  
  if nargin < 4
    error( 'far_frr needs 4 input arguments !' );
  end
  
  if nargout < 1
    error( 'far_frr needs at least 1 output argument !' );
  end

  v = [ tp fp tn fn ];
  
  if any( v < 0 )
    error( [ mfilename ' will not get fooled so easily! All input arguments must be >=0.' ] );
  end
  
  if any( isnan( v ) )
    error( [ mfilename ' will not get fooled so easily! All input arguments must be non-NaN.' ] );
  end
  
  % To remember: FAR evaluated over "desired 0"
  
  tmp = fp + tn;
  if tmp == 0
    far = NaN;
  else
    far = fp ./ tmp;
  end
  
  % To remember: FRR evaluated over "desired 1"
  tmp = fn + tp;
  if tmp == 0
    frr = NaN;
  else
    frr = fn ./ tmp;
  end
  
  hter = ( far + frr ) / 2;
  