Lucene.Net.Misc.SweetSpotSimilarity.HyperbolicTf C# (CSharp) Method

HyperbolicTf() public method

Uses a hyperbolic tangent function that allows for a hard max... tf(x)=min+(max-min)/2*(((base**(x-xoffset)-base**-(x-xoffset))/(base**(x-xoffset)+base**-(x-xoffset)))+1)

This code is provided as a convenience for subclasses that want to use a hyperbolic tf function.

public HyperbolicTf ( float freq ) : float
freq float
return float
        public virtual float HyperbolicTf(float freq)
        {
            if (0.0f == freq)
            {
                return 0.0f;
            }

            float min = tf_hyper_min;
            float max = tf_hyper_max;
            double @base = tf_hyper_base;
            float xoffset = tf_hyper_xoffset;
            double x = (double)(freq - xoffset);

            float result = min + (float)((max - min) / 2.0f * (((Math.Pow(@base, x) - Math.Pow(@base, -x)) / (Math.Pow(@base, x) + Math.Pow(@base, -x))) + 1.0d));

            return float.IsNaN(result) ? max : result;
        }
    }