Ok... I decided to compare against* eps(Float64)*

function calculatezscore{T,N}(value::AbstractArray{T,N}, average::
AbstractArray{T,N}, sd::AbstractArray{T,N}, tolerance::T=eps(T))
  zscore = similar(value)
  if size(value) == size(average) == size(sd)
    for i in eachindex(zscore)
      val = value[i]
      ave = average[i]
      sta = sd[i]
      if abs(val - ave) <= tolerance
        zscore[i] = 0.0
      elseif abs(sta) > tolerance
        zscore[i] = (val - ave)/sta
      else
        zscore[i] = NaN
      end
    end
  else
    throw(ErrorException("The elements should have the same size"))
  end
  zscore
end

I guess is the best option, isn't it? Thanks! 


Reply via email to