Esempio n. 1
0
 /**
  * Calculate average stride length
  * @return int [cm]
  */
 public function average()
 {
     if (empty($this->Strides)) {
         return 0;
     }
     $Series = new TimeSeries($this->Strides, $this->Trackdata->time());
     $Series->calculateStatistic();
     return round($Series->mean());
 }
 /**
  * Calculate average Vertical Ratio
  * @return int [%o]
  */
 public function average()
 {
     if (empty($this->VerticalRatio)) {
         return 0;
     }
     if (!$this->Trackdata->has(Trackdata\Entity::TIME)) {
         return round(array_sum($this->VerticalRatio) / $this->Trackdata->num());
     }
     $Series = new TimeSeries($this->VerticalRatio, $this->Trackdata->time());
     $Series->calculateStatistic();
     return round($Series->mean());
 }
 /**
  * Construct time series for trackdata object
  * @param \Runalyze\Model\Trackdata\Object $trackdata
  * @param enum $indexKey
  * @param enum[] $sumDifferencesKeys
  * @param enum[] $avgValuesKeys
  * @throws \InvalidArgumentException
  */
 public function __construct(Trackdata\Object $trackdata, $indexKey, $sumDifferencesKeys = array(), $avgValuesKeys = array())
 {
     $this->Trackdata = $trackdata;
     $this->IndexKey = $indexKey;
     $this->SumDifferencesKeys = $sumDifferencesKeys;
     $this->AvgValuesKeys = $avgValuesKeys;
     foreach (array_merge($sumDifferencesKeys, $avgValuesKeys) as $key) {
         if (!$trackdata->has($key)) {
             $trackdata->set($key, array_fill(0, $trackdata->num(), 0));
         }
     }
     parent::__construct($trackdata->get($indexKey), $trackdata->get(Trackdata\Object::TIME));
     $this->collectData();
 }
Esempio n. 4
0
 /**
  * Calculate by heart rate distribution
  * @param \Runalyze\Calculation\Distribution\TimeSeries $distribution
  * @return int
  */
 public function calculateByHeartrate(TimeSeries $distribution)
 {
     $this->Value = 0;
     foreach ($distribution->histogram() as $hr => $seconds) {
         $this->Value += $this->pointsFor($hr / self::$HRmax, $seconds);
     }
     $this->Value = round($this->Value);
     return $this->Value;
 }