Returns a predict samples record.

@param  \core_analytics\local\time_splitting\base $timesplitting
@param  int                                       $rangeindex
@return \stdClass|false
194180
private function get_predict_samples_record(\core_analytics\local\time_splitting\base $timesplitting, int $rangeindex) {
        global $DB;

        $params = array('modelid' => $this->analyser->get_modelid(), 'analysableid' => $timesplitting->get_analysable()->get_id(),
            'timesplitting' => $timesplitting->get_id(), 'rangeindex' => $rangeindex);
        $predictedrange = $DB->get_record('analytics_predict_samples', $params);

        return $predictedrange;
    }
98068
public static function get_pending_files($modelid, $includetarget, $timesplittingids) {
        global $DB;

        $fs = get_file_storage();

        if ($includetarget) {
            $filearea = self::LABELLED_FILEAREA;
            $usedfileaction = 'trained';
        } else {
            $filearea = self::UNLABELLED_FILEAREA;
            $usedfileaction = 'predicted';
        }

        $select = 'modelid = :modelid AND action = :action';
        $params = array('modelid' => $modelid, 'action' => $usedfileaction);
        $usedfileids = $DB->get_fieldset_select('analytics_used_files', 'fileid', $select, $params);

        // Very likely that we will only have 1 time splitting method here.
        $filesbytimesplitting = array();
        foreach ($timesplittingids as $timesplittingid) {

            $filepath = '/timesplitting/' . \core_analytics\analysis::clean_time_splitting_id($timesplittingid) . '/';
            $files = $fs->get_directory_files(\context_system::instance()->id, 'analytics', $filearea, $modelid, $filepath);
            foreach ($files as $file) {

                // Discard evaluation files.
                if ($file->get_filename() === self::EVALUATION_FILENAME) {
                    continue;
                }

                // No dirs.
                if ($file->is_directory()) {
                    continue;
                }

                // Already used for training.
                if (in_array($file->get_id(), $usedfileids)) {
                    continue;
                }

                $filesbytimesplitting[$timesplittingid][] = $file;
            }
        }

        return $filesbytimesplitting;
    }
895433
public function get_range_by_index($rangeindex) {
        if (!isset($this->ranges[$rangeindex])) {
            return false;
        }
        return $this->ranges[$rangeindex];
    }
244430
@Override
	public void onStopwatchStop(Split split, StopwatchSample sample) {
		onStopwatchSplit(split.getStopwatch(), split);
	}
1305898
public function getNextOccurrence($after_timestamp = null) {
		if ($after_timestamp === null) {
			$after_timestamp = time();
		}
		
		$after_timestamp = (int) $after_timestamp;

		$next = false;
		if ($this->isRecurring()) {
			$next = $this->calculateEndAfterTimestamp(1, $after_timestamp, false);
		} else if ($after_timestamp < $this->getStartTimestamp()) {
			$next = $this->getStartTimestamp();
		}

		if ($this->repeat_end_timestamp && $this->repeat_end_timestamp < $next) {
			return false;
		}

		return $next;
	}
430529
def set_sampling_info(self, sample):
        
        if sample.getScheduledSamplingSampler() and sample.getSamplingDate():
            return True
        sampler = self.get_form_value("getScheduledSamplingSampler", sample,
                                      sample.getScheduledSamplingSampler())
        sampled = self.get_form_value("getSamplingDate",
                                      sample.getSamplingDate())
        if not all([sampler, sampled]):
            return False
        sample.setScheduledSamplingSampler(sampler)
        sample.setSamplingDate(DateTime(sampled))
        return True
1096911
public function predict(array $samples)
    {
        $predictions = $this->runSvmPredict($samples, false);

        if (in_array($this->type, [Type::C_SVC, Type::NU_SVC], true)) {
            $predictions = DataTransformer::predictions($predictions, $this->targets);
        } else {
            $predictions = explode(PHP_EOL, trim($predictions));
        }

        if (!is_array($samples[0])) {
            return $predictions[0];
        }

        return $predictions;
    }
764951
public RandomVariable getMonteCarloWeights(int timeIndex)
	{
		// Lazy initialization, synchronized for thread safety
		synchronized(this) {
			if(discreteProcessWeights == null || discreteProcessWeights.length == 0) {
				doPrecalculateProcess();
			}
		}

		// Return value of process
		return discreteProcessWeights[timeIndex];
	}
1124507
public function retrieve_cached_result(\core_analytics\local\time_splitting\base $timesplitting,
        \core_analytics\analysable $analysable) {
        return false;
    }
597273
public StreamCutReferenceRecord findStreamCutReferenceForTime(long time) {
        int beforeIndex = getGreatestLowerBound(this, time, StreamCutReferenceRecord::getRecordingTime);
        if (beforeIndex < 0) {
            return null;
        }

        return retentionRecords.get(beforeIndex);
    }
177859
protected function calculate_sample($sampleid, $samplesorigin, $starttime = false, $endtime = false) {
        global $DB;

        $user = $this->retrieve('user', $sampleid);
        $course = \core_analytics\course::instance($this->retrieve('course', $sampleid));

        // Filter by context to use the db table index.
        $context = $this->retrieve('context', $sampleid);
        $select = "userid = :userid AND contextlevel = :contextlevel AND contextinstanceid = :contextinstanceid AND " .
            "timecreated > :end";
        $params = array('userid' => $user->id, 'contextlevel' => $context->contextlevel,
            'contextinstanceid' => $context->instanceid, 'end' => $course->get_end());
        $logstore = \core_analytics\manager::get_analytics_logstore();
        $nlogs = $logstore->get_events_select_count($select, $params);
        if ($nlogs) {
            return self::get_max_value();
        } else {
            return self::get_min_value();
        }

    }
264656
protected DateTimeField getField(int index, Chronology chrono) {
        switch (index) {
            case HOUR_OF_DAY:
                return chrono.hourOfDay();
            case MINUTE_OF_HOUR:
                return chrono.minuteOfHour();
            case SECOND_OF_MINUTE:
                return chrono.secondOfMinute();
            case MILLIS_OF_SECOND:
                return chrono.millisOfSecond();
            default:
                throw new IndexOutOfBoundsException("Invalid index: " + index);
        }
    }
651776
protected function calculate_sample($sampleid, \core_analytics\analysable $course, $starttime = false, $endtime = false) {

        $userenrol = $this->retrieve('user_enrolments', $sampleid);

        // Get course grade to pass.
        $courseitem = $this->get_course_gradetopass($course->get_id());

        // Get the user grade.
        $usergrade = $this->get_user_grade($courseitem['courseitemid'], $userenrol->userid);

        if ($usergrade >= $courseitem['gradetopass']) {
            return 0;
        }

        return 1;
    }
86868
protected function calculate_sample($sampleid, $sampleorigin, $starttime = false, $endtime = false) {

        $actionevents = \core_calendar_external::get_calendar_action_events_by_timesort($starttime, $endtime, 0, 1,
            true, $sampleid);

        if ($actionevents->events) {

            // We first need to check that at least one of the core_calendar_provide_event_action
            // callbacks has the $userid param.
            foreach ($actionevents->events as $event) {
                $nparams = $this->get_provide_event_action_num_params($event->modulename);
                if ($nparams > 2) {
                    return self::get_max_value();
                }
            }
        }

        return self::get_min_value();
    }
1022415
public void record(double sample, TimeUnit timeUnit) {
        rotate();
        final long sampleNanos = (long) TimeUtils.convert(sample, timeUnit, TimeUnit.NANOSECONDS);
        for (AtomicLong max : ringBuffer) {
            updateMax(max, sampleNanos);
        }
    }
642257
public static Sample ofTimeDouble(long time, double numericValue) {
        return new Sample(time, null, null, null)
                .setNumericValueFromDouble(numericValue);
    }
419750
protected function log_result($timesplittingid, $score, $dir = false, $info = false, $evaluationmode = 'configuration') {
        global $DB, $USER;

        $log = new \stdClass();
        $log->modelid = $this->get_id();
        $log->version = $this->model->version;
        $log->evaluationmode = $evaluationmode;
        $log->target = $this->model->target;
        $log->indicators = $this->model->indicators;
        $log->timesplitting = $timesplittingid;
        $log->dir = $dir;
        if ($info) {
            // Ensure it is not an associative array.
            $log->info = json_encode(array_values($info));
        }
        $log->score = $score;
        $log->timecreated = time();
        $log->usermodified = $USER->id;

        return $DB->insert_record('analytics_models_log', $log);
    }