Stay organized with collections
Save and categorize content based on your preferences.
The ML.LP_NORM function
This document describes the ML.LP_NORM scalar function, which lets you
compute the Lp norm for
a vector, where p is the degree.
Syntax
ML.LP_NORM(vector, degree)
Arguments
ML.LP_NORM has the following arguments:
vector: an ARRAY<Numerical type> value that represents a vector,
where Numerical type can be BIGNUMERIC, FLOAT64,
INT64 or NUMERIC. For example ARRAY<BIGNUMERIC>.
Each element of the array denotes one dimension of the vector. An example
of a four-dimensional vector is [0.0, 1.0, 1.0, 0.0].
The function calculates the p degree norm of the numerical type
values in all the values in the array.
degree: a FLOAT64 value that specifies the degree. This can be 0.0,
any value >= 1.0, or CAST('INF' AS FLOAT64) to return the L_infinity
norm of the vector, which is the largest magnitude of the values in
the vector.
Commonly used values are 1.0 to calculate the Manhattan
norm
of the vector and 2.0 to calculate the Euclidean
norm of
the vector.
Output
ML.LP_NORM returns a FLOAT64 value that represents the Lp norm
for the vector. Returns NULL if vector is NULL.
Example
The following example gets the Euclidean norm for vectors consisting of
ARRAY<FLOAT64> values:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003e\u003ccode\u003eML.LP_NORM\u003c/code\u003e is a scalar function that computes the L^p^ norm of a numerical vector, where ^p^ represents the degree.\u003c/p\u003e\n"],["\u003cp\u003eThe function accepts two arguments: a \u003ccode\u003evector\u003c/code\u003e of numerical type (e.g., \u003ccode\u003eBIGNUMERIC\u003c/code\u003e, \u003ccode\u003eFLOAT64\u003c/code\u003e, \u003ccode\u003eINT64\u003c/code\u003e, \u003ccode\u003eNUMERIC\u003c/code\u003e) and a \u003ccode\u003edegree\u003c/code\u003e (\u003ccode\u003eFLOAT64\u003c/code\u003e) to specify the norm's degree.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edegree\u003c/code\u003e can be \u003ccode\u003e0.0\u003c/code\u003e, any value greater than or equal to \u003ccode\u003e1.0\u003c/code\u003e, or \u003ccode\u003eCAST('INF' AS FLOAT64)\u003c/code\u003e to calculate the L_infinity norm.\u003c/p\u003e\n"],["\u003cp\u003eCommon values for the \u003ccode\u003edegree\u003c/code\u003e are \u003ccode\u003e1.0\u003c/code\u003e for the Manhattan norm and \u003ccode\u003e2.0\u003c/code\u003e for the Euclidean norm, and the function returns a \u003ccode\u003eFLOAT64\u003c/code\u003e value representing the calculated L^p^ norm.\u003c/p\u003e\n"],["\u003cp\u003eIf \u003ccode\u003evector\u003c/code\u003e is null, the function returns \u003ccode\u003eNULL\u003c/code\u003e as the output.\u003c/p\u003e\n"]]],[],null,[]]