public function addObservation( $x ) {
		$this->numObservations++;

		if ( $this->numObservations <= 5 ) {
			$this->heights[] = $x;
			if ( $this->numObservations === 5 ) {
				sort( $this->heights );
			}
			return;
		}

		if ( $x < $this->heights[0] ) {
			$this->heights[0] = $x;
			$k = 0;
		} elseif ( $x >= $this->heights[4] ) {
			$this->heights[4] = $x;
			$k = 3;
		} else {
			for ( $i = 1; $i < 5; $i++ ) {
				if ( $x < $this->heights[$i] ) {
					$k = $i - 1;
					break;
				}
			}
		}

		for ( $i = $k + 1; $i < 5; $i++ ) {
			$this->positions[$i]++;
		}

		for ( $i = 0; $i < 5; $i++ ) {
			$this->desired[$i] += $this->increments[$i];
		}

		for ( $i = 1; $i < 4; $i++ ) {
			$n     = $this->positions[$i];
			$nPrev = $this->positions[$i - 1];
			$nNext = $this->positions[$i + 1];

			$d = $this->desired[$i] - $n;

			if ( ( $d >= 1 && $nNext - $n > 1 ) || ( $d <= -1 && $nPrev - $n < -1 ) ) {
				$d = ( $d < 0 ) ? -1 : 1;

				$q     = $this->computeParabolic( $i, $d );
				$qPrev = $this->heights[$i - 1];
				$qNext = $this->heights[$i + 1];

				if ( $qPrev < $q && $q < $qNext ) {
					$this->heights[$i] = $q;
				} else {
					$this->heights[$i] = $this->computeLinear( $i, $d );
				}

				$this->positions[$i] += $d;
			}
		}
	}
public function addObservation( $x ) {
		$this->numObservations++;

		if ( $this->numObservations <= 5 ) {
			$this->heights[] = $x;
			if ( $this->numObservations === 5 ) {
				sort( $this->heights );
			}
			return;
		}

		if ( $x < $this->heights[0] ) {
			$this->heights[0] = $x;
			$k = 0;
		} elseif ( $x >= $this->heights[4] ) {
			$this->heights[4] = $x;
			$k = 3;
		} else {
			for ( $i = 1; $i < 5; $i++ ) {
				if ( $x < $this->heights[$i] ) {
					$k = $i - 1;
					break;
				}
			}
		}

		for ( $i = $k + 1; $i < 5; $i++ ) {
			$this->positions[$i]++;
		}

		for ( $i = 0; $i < 5; $i++ ) {
			$this->desired[$i] += $this->increments[$i];
		}

		for ( $i = 1; $i < 4; $i++ ) {
			$n     = $this->positions[$i];
			$nPrev = $this->positions[$i - 1];
			$nNext = $this->positions[$i + 1];

			$d = $this->desired[$i] - $n;

			if ( ( $d >= 1 && $nNext - $n > 1 ) || ( $d <= -1 && $nPrev - $n < -1 ) ) {
				$d = ( $d < 0 ) ? -1 : 1;

				$q     = $this->computeParabolic( $i, $d );
				$qPrev = $this->heights[$i - 1];
				$qNext = $this->heights[$i + 1];

				if ( $qPrev < $q && $q < $qNext ) {
					$this->heights[$i] = $q;
				} else {
					$this->heights[$i] = $this->computeLinear( $i, $d );
				}

				$this->positions[$i] += $d;
			}
		}
	}
public function addObservation ( $ x ) { $ this -> numObservations ++ ; if ( $ this -> numObservations <= 5 ) { $ this -> heights [ ] = $ x ; if ( $ this -> numObservations === 5 ) { sort ( $ this -> heights ) ; } return ; } if ( $ x < $ this -> heights [ 0 ] ) { $ this -> heights [ 0 ] = $ x ; $ k = 0 ; } elseif ( $ x >= $ this -> heights [ 4 ] ) { $ this -> heights [ 4 ] = $ x ; $ k = 3 ; } else { for ( $ i = 1 ; $ i < 5 ; $ i ++ ) { if ( $ x < $ this -> heights [ $ i ] ) { $ k = $ i - 1 ; break ; } } } for ( $ i = $ k + 1 ; $ i < 5 ; $ i ++ ) { $ this -> positions [ $ i ] ++ ; } for ( $ i = 0 ; $ i < 5 ; $ i ++ ) { $ this -> desired [ $ i ] += $ this -> increments [ $ i ] ; } for ( $ i = 1 ; $ i < 4 ; $ i ++ ) { $ n = $ this -> positions [ $ i ] ; $ nPrev = $ this -> positions [ $ i - 1 ] ; $ nNext = $ this -> positions [ $ i + 1 ] ; $ d = $ this -> desired [ $ i ] - $ n ; if ( ( $ d >= 1 && $ nNext - $ n > 1 ) || ( $ d <= - 1 && $ nPrev - $ n < - 1 ) ) { $ d = ( $ d < 0 ) ? - 1 : 1 ; $ q = $ this -> computeParabolic ( $ i , $ d ) ; $ qPrev = $ this -> heights [ $ i - 1 ] ; $ qNext = $ this -> heights [ $ i + 1 ] ; if ( $ qPrev < $ q && $ q < $ qNext ) { $ this -> heights [ $ i ] = $ q ; } else { $ this -> heights [ $ i ] = $ this -> computeLinear ( $ i , $ d ) ; } $ this -> positions [ $ i ] += $ d ; } } }
Add an observation.

@param int|float $x Value to add
Add an observation .