statistics-0.16.2.1: A library of statistical types, data, and functions
Copyright(c) 2009 2010 2011 Bryan O'Sullivan
LicenseBSD3
Maintainerbos@serpentine.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Statistics.Function

Description

Useful functions.

Synopsis
  • minMax :: Vector v Double => v Double -> (Double, Double)
  • sort :: Vector Double -> Vector Double
  • gsort :: (Ord e, Vector v e) => v e -> v e
  • sortBy :: Vector v e => Comparison e -> v e -> v e
  • partialSort :: (Vector v e, Ord e) => Int -> v e -> v e
  • indexed :: (Vector v e, Vector v Int, Vector v (Int, e)) => v e -> v (Int, e)
  • indices :: (Vector v a, Vector v Int) => v a -> v Int
  • nextHighestPowerOfTwo :: Int -> Int
  • within :: Int -> Double -> Double -> Bool
  • square :: Double -> Double
  • unsafeModify :: MVector s Double -> Int -> (Double -> Double) -> ST s ()
  • for :: Monad m => Int -> Int -> (Int -> m ()) -> m ()
  • rfor :: Monad m => Int -> Int -> (Int -> m ()) -> m ()

Scanning

minMax :: Vector v Double => v Double -> (Double, Double) Source #

Compute the minimum and maximum of a vector in one pass.

Sorting

sort :: Vector Double -> Vector Double Source #

Sort a vector.

gsort :: (Ord e, Vector v e) => v e -> v e Source #

Sort a vector.

sortBy :: Vector v e => Comparison e -> v e -> v e Source #

Sort a vector using a custom ordering.

partialSort Source #

Arguments

:: (Vector v e, Ord e) 
=> Int

The number k of least elements.

-> v e 
-> v e 

Partially sort a vector, such that the least k elements will be at the front.

Indexing

indexed :: (Vector v e, Vector v Int, Vector v (Int, e)) => v e -> v (Int, e) Source #

Zip a vector with its indices.

indices :: (Vector v a, Vector v Int) => v a -> v Int Source #

Return the indices of a vector.

Bit twiddling

nextHighestPowerOfTwo :: Int -> Int Source #

Efficiently compute the next highest power of two for a non-negative integer. If the given value is already a power of two, it is returned unchanged. If negative, zero is returned.

Comparison

within :: Int -> Double -> Double -> Bool #

Arithmetic

square :: Double -> Double Source #

Multiply a number by itself.

Vectors

unsafeModify :: MVector s Double -> Int -> (Double -> Double) -> ST s () Source #

Combinators

for :: Monad m => Int -> Int -> (Int -> m ()) -> m () Source #

Simple for loop. Counts from start to end-1.

rfor :: Monad m => Int -> Int -> (Int -> m ()) -> m () Source #

Simple reverse-for loop. Counts from start-1 to end (which must be less than start).