Ejemplo n.º 1
0
        public T Mean()
        {
            if (m_isMeanDirty)
            {
                m_isMeanDirty = false;

                try {
                    T     mean = default(T);
                    int   n    = m_values.Count;
                    float w;
                    float totalW = (n * (n + 1)) / 2f;    // Gauss Formula
                    // Calculate new mean
                    for (int i = 0; i < n; ++i)
                    {
                        // Get Normalized weight (0 to 1)
                        w    = (n - i) / totalW;
                        mean = addFn(mean, multiplyFn(m_values.At(n - i - 1), w));
                    }
                    m_mean = mean;
                } catch (Exception e) {
                    // Catch any errors with (dynamic)
                    Debug.LogError("WeightedMean: Mean() Exception: " + e.ToString());
                }
            }
            return(m_mean);
        }
Ejemplo n.º 2
0
    void Update()
    {
        if (m_Stopped)
        {
            return;
        }

        if (m_VisualsDirty)
        {
            // Loop through Log Stack and Write to Text
            StringBuilder sb = new StringBuilder();
            for (int m = 0; m < logStack.Count; ++m)
            {
                sb.Append(Time.time + " ");
                sb.Append(logStack.At(m));
                sb.Append("\n");
            }
            outText.text = sb.ToString();

            m_VisualsDirty = false;
        }
    }