Back to Influxdb

math.lgamma() function

content/flux/v0/stdlib/math/lgamma.md

latest3.6 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/math/math.flux#L1350-L1350 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

math.lgamma() returns the natural logarithm and sign (-1 or +1) of math.gamma(x:x).

Function type signature
js
(x: float) => {sign: int, lgamma: float}

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

x

({{< req >}}) Value to operate on.

Examples

Return the natural logarithm and sign of a gamma function

js
import "math"

math.lgamma(x: 3.14)// {lgamma: 0.8261387047770286, sign: 1}


Use math.lgamma in map

js
import "sampledata"
import "math"

sampledata.float()
    |> map(
        fn: (r) => {
            result = math.lgamma(x: r._value)

            return {r with lgamma: result.lgamma, sign: result.sign}
        },
    )

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time*tag_value
2021-01-01T00:00:00Zt1-2.18
2021-01-01T00:00:10Zt110.92
2021-01-01T00:00:20Zt17.35
2021-01-01T00:00:30Zt117.53
2021-01-01T00:00:40Zt115.23
2021-01-01T00:00:50Zt14.43
_time*tag_value
2021-01-01T00:00:00Zt219.85
2021-01-01T00:00:10Zt24.97
2021-01-01T00:00:20Zt2-3.75
2021-01-01T00:00:30Zt219.77
2021-01-01T00:00:40Zt213.86
2021-01-01T00:00:50Zt21.86

Output data

_time_valuelgammasign*tag
2021-01-01T00:00:00Z-2.180.9031727084064437-1t1
2021-01-01T00:00:10Z10.9214.9165776734256851t1
2021-01-01T00:00:20Z7.357.2439665880040431t1
2021-01-01T00:00:30Z17.5332.166142066335061t1
2021-01-01T00:00:40Z15.2325.8081347732117341t1
2021-01-01T00:00:50Z4.432.35712853214909051t1
_time_valuelgammasign*tag
2021-01-01T00:00:00Z19.8538.89488386914851t2
2021-01-01T00:00:10Z4.973.1329701159049181t2
2021-01-01T00:00:20Z-3.75-1.31726794244636341t2
2021-01-01T00:00:30Z19.7738.658025143277641t2
2021-01-01T00:00:40Z13.8622.1884834341233241t2
2021-01-01T00:00:50Z1.86-0.0526763117068980161t2

{{% /expand %}} {{< /expand-wrapper >}}