public void addValue(double data,double given,double weight){
  data=round(data);
  given=round(given);
  int insertIndex=findNearestPair(given,data);
  if ((m_NumValues <= insertIndex) || (m_CondValues[insertIndex] != given) || (m_Values[insertIndex] != data)) {
    if (m_NumValues < m_Values.length) {
      int left=m_NumValues - insertIndex;
      System.arraycopy(m_Values,insertIndex,m_Values,insertIndex + 1,left);
      System.arraycopy(m_CondValues,insertIndex,m_CondValues,insertIndex + 1,left);
      System.arraycopy(m_Weights,insertIndex,m_Weights,insertIndex + 1,left);
      m_Values[insertIndex]=data;
      m_CondValues[insertIndex]=given;
      m_Weights[insertIndex]=weight;
      m_NumValues++;
    }
 else {
      double[] newValues=new double[m_Values.length * 2];
      double[] newCondValues=new double[m_Values.length * 2];
      double[] newWeights=new double[m_Values.length * 2];
      int left=m_NumValues - insertIndex;
      System.arraycopy(m_Values,0,newValues,0,insertIndex);
      System.arraycopy(m_CondValues,0,newCondValues,0,insertIndex);
      System.arraycopy(m_Weights,0,newWeights,0,insertIndex);
      newValues[insertIndex]=data;
      newCondValues[insertIndex]=given;
      newWeights[insertIndex]=weight;
      System.arraycopy(m_Values,insertIndex,newValues,insertIndex + 1,left);
      System.arraycopy(m_CondValues,insertIndex,newCondValues,insertIndex + 1,left);
      System.arraycopy(m_Weights,insertIndex,newWeights,insertIndex + 1,left);
      m_NumValues++;
      m_Values=newValues;
      m_CondValues=newCondValues;
      m_Weights=newWeights;
    }
    if (weight != 1) {
      m_AllWeightsOne=false;
    }
  }
 else {
    m_Weights[insertIndex]+=weight;
    m_AllWeightsOne=false;
  }
  m_SumOfWeights+=weight;
  double range=m_CondValues[m_NumValues - 1] - m_CondValues[0];
  m_StandardDev=Math.max(range / Math.sqrt(m_SumOfWeights),m_Precision / (2 * 3));
}

public void addValue ( double data , double given , double weight ) { data = round ( data ) ; given = round ( given ) ; int insertIndex = findNearestPair ( given , data ) ; if ( ( m_NumValues <= insertIndex ) || ( m_CondValues [ insertIndex ] != given ) || ( m_Values [ insertIndex ] != data ) ) { if ( m_NumValues < m_Values . length ) { int left = m_NumValues - insertIndex ; System . arraycopy ( m_Values , insertIndex , m_Values , insertIndex + 1 , left ) ; System . arraycopy ( m_CondValues , insertIndex , m_CondValues , insertIndex + 1 , left ) ; System . arraycopy ( m_Weights , insertIndex , m_Weights , insertIndex + 1 , left ) ; m_Values [ insertIndex ] = data ; m_CondValues [ insertIndex ] = given ; m_Weights [ insertIndex ] = weight ; m_NumValues ++ ; } else { double [ ] newValues = new double [ m_Values . length * 2 ] ; double [ ] newCondValues = new double [ m_Values . length * 2 ] ; double [ ] newWeights = new double [ m_Values . length * 2 ] ; int left = m_NumValues - insertIndex ; System . arraycopy ( m_Values , 0 , newValues , 0 , insertIndex ) ; System . arraycopy ( m_CondValues , 0 , newCondValues , 0 , insertIndex ) ; System . arraycopy ( m_Weights , 0 , newWeights , 0 , insertIndex ) ; newValues [ insertIndex ] = data ; newCondValues [ insertIndex ] = given ; newWeights [ insertIndex ] = weight ; System . arraycopy ( m_Values , insertIndex , newValues , insertIndex + 1 , left ) ; System . arraycopy ( m_CondValues , insertIndex , newCondValues , insertIndex + 1 , left ) ; System . arraycopy ( m_Weights , insertIndex , newWeights , insertIndex + 1 , left ) ; m_NumValues ++ ; m_Values = newValues ; m_CondValues = newCondValues ; m_Weights = newWeights ; } if ( weight != 1 ) { m_AllWeightsOne = false ; } } else { m_Weights [ insertIndex ] += weight ; m_AllWeightsOne = false ; } m_SumOfWeights += weight ; double range = m_CondValues [ m_NumValues - 1 ] - m_CondValues [ 0 ] ; m_StandardDev = Math . max ( range / Math . sqrt ( m_SumOfWeights ) , m_Precision / ( 2 * 3 ) ) ; }
add a new data value to the current estimator .
