[comment]: # attributes: notoc

[comment]: # translation:outdated

[comment]: # ({70939231-2e2a1a06})
# 8 Voorspellingsfuncties

Alle hier vermelde functies worden ondersteund in:

-   [Trigger expressies](/manual/config/triggers/expression)
-   [Berekende items](/manual/config/items/itemtypes/calculated)

De functies worden vermeld zonder aanvullende informatie. Klik op de functie om de volledige details te zien.

|Functie|Beschrijving|
|--|--------|
|[forecast](#forecast)|De toekomstige waarde, max, min, delta of gemiddelde van het item.|
|[timeleft](#timeleft)|De tijd in seconden die nodig is voor een item om de opgegeven drempel te bereiken.|

[comment]: # ({/70939231-2e2a1a06})

[comment]: # ({7bb9caf7-4d343eb8})
##### Algemene parameters

- `/host/key` is een algemene verplichte eerste parameter voor de functies
    verwijzend naar de geschiedenis van het hostitem
- `(sec|#num)<:time shift>` is een gebruikelijke tweede parameter voor de
    functies die verwijzen naar de geschiedenis van het hostitem, waarbij:
    - **sec** - maximum [evaluatie
        periode](/manual/config/triggers#evaluation_period) in seconden
        (tijd [achtervoegsels](/manual/appendix/suffixes) kan worden gebruikt), of
    - **\#num** - maximum [evaluatie
        bereik](/manual/config/triggers#evaluation_period) in de laatste
        verzamelde waarden (indien voorafgegaan door een hekje)
    - **tijdverschuiving** (optioneel) maakt het mogelijk om het evaluatiepunt te verplaatsen
        terug in de tijd. Bekijk meer
        details](/manual/config/triggers/expression#time_shift) aan
        tijdverschuiving aangeven.

[comment]: # ({/7bb9caf7-4d343eb8})

[comment]: # ({29eea3e8-f3b63bc1})
### Functiedetails

Enkele algemene opmerkingen over functieparameters:

-   Functieparameters zijn gescheiden door een komma
-   Optionele functieparameters (of parameterdelen) worden aangegeven met `<` `>`
-   Functie-specifieke parameters worden bij elke functie beschreven
-   De parameters `/host/key` en `(sec|#num)<:tijdsverschuiving>` mogen nooit tussen aanhalingstekens worden geplaatst

[comment]: # ({/29eea3e8-f3b63bc1})

[comment]: # ({new-e4452b37})

##### forecast(/host/key,(sec|#num)<:time shift>,time,<fit>,<mode>) {#forecast}

The future value, max, min, delta or avg of the item.<br>
Supported value types: *Float*, *Integer*.

Parameters: 

-   See [common parameters](#common-parameters);<br>
-   **time** - the forecasting horizon in seconds (time suffixes can be used); negative values are supported;<br>
-   **fit** (optional; must be double-quoted) - the function used to fit historical data. Supported fits:<br>*linear* - linear function (default)<br>*polynomialN* - polynomial of degree N (1 <= N <= 6)<br>*exponential* - exponential function<br>*logarithmic* - logarithmic function<br>*power* - power function<br>Note that *polynomial1* is equivalent to *linear*;
-   **mode** (optional; must be double-quoted) - the demanded output. Supported modes:<br>*value* - value (default)<br>*max* - maximum<br>*min* - minimum<br>*delta* - *max*-*min*<br>*avg* - average<br>Note that *value* estimates the item value at the moment `now` + `time`; *max*, *min*, *delta* and *avg* investigate the item value estimate on the interval between `now` and `now` + `time`.

Comments:

-   If the value to return is larger than 1.7976931348623158E+308 or less than -1.7976931348623158E+308, the return value is cropped to 1.7976931348623158E+308 or -1.7976931348623158E+308 correspondingly;
-   Becomes unsupported only if misused in the expression (wrong item type, invalid parameters), otherwise returns -1 in case of errors;
-   See also additional information on [predictive trigger functions](/manual/config/triggers/prediction).

Examples:

    forecast(/host/key,#10,1h) #forecast the item value in one hour based on the last 10 values
    forecast(/host/key,1h,30m) #forecast the item value in 30 minutes based on the last hour data
    forecast(/host/key,1h:now-1d,12h) #forecast the item value in 12 hours based on one hour one day ago
    forecast(/host/key,1h,10m,"exponential") #forecast the item value in 10 minutes based on the last hour data and exponential function
    forecast(/host/key,1h,2h,"polynomial3","max") #forecast the maximum value the item can reach in the next two hours based on last hour data and cubic (third degree) polynomial
    forecast(/host/key,#2,-20m) #estimate the item value 20 minutes ago based on the last two values (this can be more precise than using last(), especially if the item is updated rarely, say, once an hour)

[comment]: # ({/new-e4452b37})

[comment]: # ({new-9b065620})

##### timeleft(/host/key,(sec|#num)<:time shift>,threshold,<fit>) {#timeleft}

The time in seconds needed for an item to reach the specified threshold.<br>
Supported value types: *Float*, *Integer*.

Parameters: 

-   See [common parameters](#common-parameters);<br>
-   **threshold** - the value to reach ([unit suffixes](/manual/appendix/suffixes) can be used);
-   **fit** (optional; must be double-quoted) - see [forecast()](#forecast).

Comments:

-   If the value to return is larger than 1.7976931348623158E+308, the return value is cropped to 1.7976931348623158E+308;
-   Returns 1.7976931348623158E+308 if the threshold cannot be reached;
-   Becomes unsupported only if misused in the expression (wrong item type, invalid parameters), otherwise returns -1 in case of errors;
-   See also additional information on [predictive trigger functions](/manual/config/triggers/prediction).

Examples:

    timeleft(/host/key,#10,0) #the time until the item value reaches zero based on the last 10 values
    timeleft(/host/key,1h,100) #the time until the item value reaches 100 based on the last hour data
    timeleft(/host/key,1h:now-1d,100) #the time until the item value reaches 100 based on one hour one day ago
    timeleft(/host/key,1h,200,"polynomial2") #the time until the item value reaches 200 based on the last hour data and assumption that the item behaves like a quadratic (second degree) polynomial

[comment]: # ({/new-9b065620})

[comment]: # ({62849ca2-9958c480})
Zie [alle ondersteunde functies](/handleiding/bijlage/functies).

[comment]: # ({/62849ca2-9958c480})

