コード例 #1
0
 /**
  * Apply a thresholding function to the data elements.
  * This does not modify the object.
  * 
  * @param
  *        	double thesdholdValue the value to which elements are compared
  * @param
  *        	double lowValue the value to use if <= threshold
  * @param
  *        	double highValue the value to use if > threshold
  * @return MLData The result.
  */
 public function threshold($thresholdValue, $lowValue, $highValue)
 {
     $result = new BasicMLData($size());
     for ($i = 0; $i < $this->size(); ++$i) {
         if ($this->getData($i) > $thresholdValue) {
             $result->setData($i, $highValue);
         } else {
             $result->setData($i, $lowValue);
         }
     }
     return $result;
 }