public function calculate($sampleids, $samplesorigin, $starttime = false, $endtime = false, $existingcalculations = array()) {

        if (!PHPUNIT_TEST && CLI_SCRIPT) {
            echo '.';
        }

        $calculations = array();
        $newcalculations = array();
        $notnulls = array();
        foreach ($sampleids as $sampleid => $unusedsampleid) {

            if (isset($existingcalculations[$sampleid])) {
                $calculatedvalue = $existingcalculations[$sampleid];
            } else {
                $calculatedvalue = $this->calculate_sample($sampleid, $samplesorigin, $starttime, $endtime);
                $newcalculations[$sampleid] = $calculatedvalue;
            }

            if (!is_null($calculatedvalue)) {
                $notnulls[$sampleid] = $sampleid;
                $this->validate_calculated_value($calculatedvalue);
            }

            $calculations[$sampleid] = $calculatedvalue;
        }

        $features = $this->to_features($calculations);

        return array($features, $newcalculations, $notnulls);
    }