diff --git a/src/gleam_community/maths/conversion.gleam b/src/gleam_community/maths/conversion.gleam index d0eb040..9ac9036 100644 --- a/src/gleam_community/maths/conversion.gleam +++ b/src/gleam_community/maths/conversion.gleam @@ -30,6 +30,7 @@ //// * [`int_to_float`](#int_to_float) //// * [`degrees_to_radians`](#degrees_to_radians) //// * [`radians_to_degrees`](#radians_to_degrees) +//// import gleam/int diff --git a/src/gleam_community/maths/elementary.gleam b/src/gleam_community/maths/elementary.gleam index c71ebf6..e130e07 100644 --- a/src/gleam_community/maths/elementary.gleam +++ b/src/gleam_community/maths/elementary.gleam @@ -1000,7 +1000,7 @@ pub fn power(x: Float, y: Float) -> Result(Float, String) { // 2. If the base (x) is 0 and the exponent (y) is negative then the // expression is equivalent to the exponent (y) divided by 0 and an // error should be returned - case x <. 0.0 && fractional || x == 0.0 && y <. 0.0 { + case { x <. 0.0 && fractional } || { x == 0.0 && y <. 0.0 } { True -> "Invalid input argument: x < 0 and y is fractional or x = 0 and y < 0." |> Error diff --git a/src/gleam_community/maths/metrics.gleam b/src/gleam_community/maths/metrics.gleam index e663d65..286044c 100644 --- a/src/gleam_community/maths/metrics.gleam +++ b/src/gleam_community/maths/metrics.gleam @@ -20,12 +20,18 @@ //// -//// +//// //// --- //// //// Metrics: A module offering functions for calculating distances and other //// types of metrics. //// +//// Disclaimer: In this module, the terms "distance" and "metric" are used in +//// a broad and practical sense. That is, they are used to denote any difference +//// or discrepancy between two inputs. Consequently, they may not align with their +//// precise mathematical definitions (in particular, some "distance" functions in +//// this module do not satisfy the triangle inequality). +//// //// * **Distance measures** //// * [`norm`](#norm) //// * [`manhattan_distance`](#manhattan_distance) @@ -40,26 +46,24 @@ //// * [`sorensen_dice_coefficient`](#sorensen_dice_coefficient) //// * [`tversky_index`](#tversky_index) //// * [`overlap_coefficient`](#overlap_coefficient) -//// * [`levenshtein_distance`](#levenshtein_distance) //// * **Basic statistical measures** //// * [`mean`](#mean) //// * [`median`](#median) //// * [`variance`](#variance) //// * [`standard_deviation`](#standard_deviation) -//// +//// import gleam/bool +import gleam/float +import gleam/int import gleam/list +import gleam/option import gleam/pair +import gleam/set import gleam_community/maths/arithmetics import gleam_community/maths/conversion import gleam_community/maths/elementary import gleam_community/maths/piecewise -import gleam/set -import gleam/float -import gleam/int -import gleam/string -import gleam/option /// Utility function that checks all lists have the expected length and contents /// The function is primarily used by all distance measures taking 'List(Float)' @@ -1126,125 +1130,6 @@ pub fn cosine_similarity( } } -///