Documentation
¶
Overview ¶
Package math provides APOC mathematical functions.
This package implements all apoc.math.* functions for mathematical operations in Cypher queries.
Index ¶
- func Abs(value float64) float64
- func Acos(value float64) float64
- func Asin(value float64) float64
- func Atan(value float64) float64
- func Atan2(y, x float64) float64
- func Ceil(value float64) float64
- func Clamp(value, min, max float64) float64
- func Cos(angle float64) float64
- func Cosh(value float64) float64
- func Exp(value float64) float64
- func Factorial(n int64) int64
- func Fibonacci(n int64) int64
- func Floor(value float64) float64
- func Gcd(a, b int64) int64
- func IsPrime(n int64) bool
- func Lcm(a, b int64) int64
- func Lerp(start, end, t float64) float64
- func Log(value float64) float64
- func Log10(value float64) float64
- func Logit(value float64) float64
- func MaxDouble(values ...float64) float64
- func MaxLong(values ...int64) int64
- func Mean(values []float64) float64
- func Median(values []float64) float64
- func MinDouble(values ...float64) float64
- func MinLong(values ...int64) int64
- func Mode(values []float64) float64
- func NextPrime(n int64) int64
- func Normalize(value, oldMin, oldMax, newMin, newMax float64) float64
- func Percentile(values []float64, percentile float64) float64
- func Pow(base, exponent float64) float64
- func Product(values []float64) float64
- func Random() float64
- func RandomInt(min, max int64) int64
- func Range(start, end, step int64) []int64
- func Round(value float64, precision int) float64
- func Sigmoid(value float64) float64
- func Sin(angle float64) float64
- func Sinh(value float64) float64
- func Sqrt(value float64) float64
- func StdDev(values []float64) float64
- func Sum(values []float64) float64
- func Tan(angle float64) float64
- func Tanh(value float64) float64
- func Variance(values []float64) float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Atan2 ¶
Atan2 returns the arctangent of y/x (in radians).
Example:
apoc.math.atan2(1, 1) => math.Pi / 4
func Clamp ¶
Clamp restricts a value to a range.
Example:
apoc.math.clamp(15, 0, 10) => 10 apoc.math.clamp(-5, 0, 10) => 0 apoc.math.clamp(5, 0, 10) => 5
func IsPrime ¶
IsPrime checks if a number is prime.
Example:
apoc.math.isPrime(17) => true apoc.math.isPrime(18) => false
func Lerp ¶
Lerp performs linear interpolation between two values.
Example:
apoc.math.lerp(0, 10, 0.5) => 5.0 apoc.math.lerp(0, 10, 0.25) => 2.5
func Logit ¶
Logit returns the logit function (inverse of sigmoid).
Example:
apoc.math.logit(0.5) => 0.0
func MaxDouble ¶
MaxDouble returns the maximum of multiple floats.
Example:
apoc.math.maxDouble(5.5, 2.3, 8.1, 1.9) => 8.1
func MaxLong ¶
MaxLong returns the maximum of multiple integers.
Example:
apoc.math.maxLong(5, 2, 8, 1, 9) => 9
func Median ¶
Median returns the median value of a list.
Example:
apoc.math.median([1,2,3,4,5]) => 3.0
func MinDouble ¶
MinDouble returns the minimum of multiple floats.
Example:
apoc.math.minDouble(5.5, 2.3, 8.1, 1.9) => 1.9
func MinLong ¶
MinLong returns the minimum of multiple integers.
Example:
apoc.math.minLong(5, 2, 8, 1, 9) => 1
func Mode ¶
Mode returns the most frequent value in a list.
Example:
apoc.math.mode([1,2,2,3,3,3,4]) => 3.0
func NextPrime ¶
NextPrime returns the next prime number after n.
Example:
apoc.math.nextPrime(10) => 11
func Normalize ¶
Normalize normalizes a value from one range to another.
Example:
apoc.math.normalize(5, 0, 10, 0, 1) => 0.5
func Percentile ¶
Percentile calculates the nth percentile of a list.
Example:
apoc.math.percentile([1,2,3,4,5,6,7,8,9,10], 50) => 5.5
func Product ¶
Product returns the product of a list of numbers.
Example:
apoc.math.product([2,3,4]) => 24.0
func Random ¶
func Random() float64
Random returns a random float between 0 and 1.
Example:
apoc.math.random() => 0.7234... (random)
func RandomInt ¶
RandomInt returns a random integer in a range [min, max].
Example:
apoc.math.randomInt(1, 10) => 7 (random)
func Range ¶
Range returns a list of numbers from start to end.
Example:
apoc.math.range(1, 5) => [1,2,3,4,5]
func Round ¶
Round rounds a number to a given precision.
Example:
apoc.math.round(3.14159, 2) => 3.14 apoc.math.round(1234.5, -2) => 1200.0
func Sin ¶
Sin returns the sine of an angle (in radians).
Example:
apoc.math.sin(math.Pi / 2) => 1.0
func StdDev ¶
StdDev returns the standard deviation of a list.
Example:
apoc.math.stdDev([2,4,4,4,5,5,7,9]) => 2.0
func Tan ¶
Tan returns the tangent of an angle (in radians).
Example:
apoc.math.tan(math.Pi / 4) => 1.0
Types ¶
This section is empty.