extent : List comparable -> Maybe ( comparable, comparable )
Returns the minimum and maximum value in the list.
extentBy : (a -> comparable) -> List a -> Maybe ( a, a )
Returns the minimum and maximum value in the given array using comparisons from values passed by the accessor function.
data : List { name : String, age : Int}
data =
[ {name = "John Smith", age = 32 }
, {name = "Mark Luther", age = 45 }
, {name = "Cory Jones", age = 26 }
]
extentBy .age data
--> Just ({name = "Cory Jones", age = 26 }
--> , {name = "Mark Luther", age = 45 })
extentWith : (a -> a -> Basics.Order) -> List a -> Maybe ( a, a )
Returns the minimum and maximum value in the given array using comparisons provided by the comparison function.
variance : List Basics.Float -> Maybe Basics.Float
Returns an unbiased estimator of the population variance of the given list of numbers. If the list has fewer than two values, returns Nothing.
deviation : List Basics.Float -> Maybe Basics.Float
Returns the standard deviation, defined as the square root of the bias-corrected variance, of the given list of numbers. If the list has fewer than two values, returns Nothing.
quantile : Basics.Float -> List Basics.Float -> Maybe Basics.Float
Returns the p-quantile of the given sorted list of numbers, where p
is a number in the range [0, 1]. For
example, the median can be computed using p = 0.5, the first quartile at p = 0.25, and the third quartile at p = 0.75.
This particular implementation uses the R-7 method,
which is the default for the R programming language and Excel. For example:
a : List Float
a = [0, 10, 30]
quantile 0 a --> Just 0
quantile 0.5 a --> Just 10
quantile 1 a --> Just 30
quantile 0.25 a --> Just 5
quantile 0.75 a --> Just 20
quantile 0.1 a --> Just 2
peaks : (a -> Basics.Float) -> { lookaround : Basics.Int, sensitivity : Basics.Float, coallesce : Basics.Int } -> List a -> List a
This functions detects (positive) peaks in a timeseries.
The first argument is there to extract the actual value to perform the computation on.
It also accepts some parameters to tune the behavior of the function:
lookaround
: Each value will be compared to this many neigbours on both sides and will get a score on how much taller it is then the shortest of them.
sensitivity
: This is used as a threshold to filter the candidate peaks to select the gloably biggest.
coallesce
: To prevent peaks that span multiple samples, this parameter will coalesce these into a single sample.
peaks identity { lookaround = 2, sensitivity = 1.4, coallesce = 0 } [ 2, 0, 10, 2, 1 ] --> [ 10 ]
Based on work by Yuri Vishnevsky.
Methods for transforming list and for generating new lists.
ticks : Basics.Float -> Basics.Float -> Basics.Int -> List Basics.Float
Returns a list of approximately n + 1 uniformly-spaced, nicely-rounded values between a start and stop value (inclusive). Each value is a power of ten multiplied by 1, 2 or 5. Note that due to the limited precision of IEEE 754 floating point, the returned values may not be exact decimals.
Ticks are inclusive in the sense that they may include the specified start and stop values if (and only if) they are exact, nicely-rounded values consistent with the inferred step. More formally, each returned tick t satisfies start ≤ t and t ≤ stop.
ticks 1.9 6.4 10 --> [2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6]
ticks 1.9 6 5 --> [2, 3, 4, 5, 6]
tickStep : Basics.Float -> Basics.Float -> Basics.Int -> Basics.Float
Returns the difference between adjacent tick values if the same arguments
were passed to ticks
: a nicely-rounded value that is a power of ten multiplied
by 1, 2 or 5. Note that due to the limited precision of IEEE 754 floating point,
the returned value may not be exact decimals.
tickStep 1.9 6.4 10 -- 0.5
tickStep 1.9 6 5 -- 1
range : Basics.Float -> Basics.Float -> Basics.Float -> List Basics.Float
Returns a List containing an arithmetic progression, similar to the Python built-in range. This method is often used to iterate over a sequence of uniformly-spaced numeric values, such as the indexes of an array or the ticks of a linear scale. (See also ticks for nicely-rounded values.)
Takes a start
, stop
and step
argument. The stop value is exclusive; it is not
included in the result. If step
is positive, the last element is the largest
start + i * step
less than stop
; if step
is negative, the last element is
the smallest start + i * step
greater than stop
. If the returned list would
contain an infinite number of values, an empty range is returned.
The arguments are not required to be whole numbers; however, the results are more predictable if they are.
Differences from List.range from the standard library:
List.range
is inclusive, meaning that the stop value will be included in the resultList.range
supports Int
, whereas this uses Float
List.range
supports only increasing intervals (i.e. List.range 3 1 == []
vs. range 3 1 -1 == [3, 2]
)List.range
doesn't allow for specifying the step value