Perform complex summations and weighted averages.
value
(numeric): The input values to calculate the delta sum.deltaSumTimestamp
instead.deltaSum
calculates the sum of positive price differences:
value
(numeric, Date
, or DateTime
): The values to sum.timestamp
(numeric, Date
, or DateTime
): The parameter for ordering values.value
.
Example:
deltaSum
function instead.value
(numeric): The value to be averaged.timeunit
(numeric): An index representing the time interval, not a timestamp. Can be calculated using intDiv
or toRelativeHourNum
.x
(numeric): The half-life period. This is the time lag at which the exponential weights decay by one-half.x
time at the latest point in time. [Float64
]
Example:
timeunit
argument should be a monotonically increasing value. Using toRelativeHourNum()
or intDiv(toUInt32(sale_time), 3600)
ensures this for hourly data.v
(numeric): Value. Integer
, Float
, or Decimal
.t
(numeric or DateTime
): Time. Integer
, Float
, Decimal
, DateTime
, or DateTime64
.x
(numeric): Half-life period. Integer
, Float
, or Decimal
.Float64
]
Example:
sales_trend
column provides a visual representation of the smoothed sales trend.
x
(numeric): The half-life period.t
(numeric or DateTime
): The time value.Float64
]
Example:
exponentialTimeDecayedCount
function is applied with a half-life of 10 hours.decayed_count
shows how the cumulative value decays over time, with new orders increasing the count.visual_decay
column provides a bar chart representation of the decayed count.value
(numeric): The value to be smoothed.timeunit
(numeric or DateTime
or DateTime64
): The time unit associated with each value.x
(numeric): The half-life period for the exponential decay.Float64
]
Example:
smoothed_price
column shows the result of exponentialTimeDecayedMax
with a half-life of 5 time units.price_trend
column visualizes the smoothed price using a bar chart.v
(numeric): The value in the time series.t
(numeric or DateTime
or DateTime64
): The timestamp of the value.x
(numeric): The half-life period for the exponential decay.Float64
]
Example:
bar
function visualizes the trend of smoothed sales.sum
, count
, or avg
functions.
Syntax:
x
(Integer
, Float
, or Decimal
): The numeric value to be summed.sum
)count
)Tuple(sum, count)
Example:
x
(Integer
, Float
, or Decimal
): The values to sum.sum
function but offers improved accuracy for floating-point calculations.Float
types.sum
and sumKahan
for taco prices ordered on a specific date. The sumKahan
function provides a more accurate result (50) compared to the regular sum
function, which shows a small floating-point error.
sumKahan
when dealing with floating-point numbers and high precision is required, especially when summing a large number of small values.keys
(Array
): An array of keys.values
(Array
): An array of values corresponding to the keys.keys
and values
must be the same for each row.keys
(Array
): Array of keys.values
(Array
): Array of values.tuple
containing both the keys
and values
arrays.
Returns:
A tuple
containing two arrays:
sumMapWithOverflow
calculates the total quantity for each taco type, maintaining the original UInt8
data type for quantities. This allows for potential overflow if the sum exceeds 255.
sumMap
in that it performs summation with overflow, preserving the original data type of the values. Use this function when you want to maintain the input data type and allow for overflow in calculations.num
(UInt*
, Int*
, Float*
, or Decimal*
): A column of numeric values.sum
function automatically widens the result type to UInt64
to accommodate the larger sum. However, sumWithOverflow
keeps the original UInt16
type, resulting in an overflow when the sum exceeds 65,535 (the maximum value for UInt16
).