MyNixOS website logo
Description

Haskell Numeric Library with pure functionality, R & MATLAB Syntax.

Please see the README on GitHub at https://github.com/Axect/HNumeric#readme

HNumeric

Travis

Packages

  • HNum.Vector : Contain vector, matrix, linear algebra
  • HNum.Stats : Contain statistical functions
  • HNum.CSV : CSV Tools for HNum (Contain DataFrame)
  • HNum.Special : Special Function wrapper for HNum
  • HNum.F : Functional Programming Tools for HNum

Installation

1. Cabal Install

cabal update
cabal install HNumeric

That's all!

2. Import to Stack project

If you use this package to your own project, then you should change stack.yaml and package.yaml

1) Change stack.yaml

# In stack.yaml
extra-deps:
  - git: https://github.com/Axect/HNumeric.git
    commit: [Latest Commit]
  - normaldistribution-1.1.0.3
  - random-1.1

2) Change package.yaml

# In package.yaml
dependecies:
- base
- HNumeric
- normaldistribution
- random

Then enjoy!

Documentation

Documentation is prepared on authorea

HNumeric Documentation

Usage

Import Module

  • HNum.Vector
  • HNum.Stats
  • HNum.CSV
  • HNum.F

Basic Vector Usage

-- HNumeric-0.3.0.0 Documentation

let a = vector [1,2,3] -- Vector declaration
let b = Vector [4,5,6] -- small v and large V are same (for convenient)

-- Print Vector
print a

-- You can (+1) by fmap (Vector is functor)
(+1) <$> a 

-- Or MATLAB-like operator (.+, .-, .*, ./, .^)
a .+ 1 -- do not 1 .+ a (. means position of vector)

-- You can make list from vector
toList a -- [1, 2, 3]

-- You can make vector from list
fromList [1,2,3] -- Vector [1,2,3]

-- You can add (subtract, multiply, divide) vectors
a + b -- Vector [5,7,9]

-- Also dot product is here.
a .*. b -- 1*4 + 2*5 + 3*6 = 32

-- Declare Matrix (Syntactic Sugar)
let c = matrix [[1,2],[3,4]]

-- or Declare using R Syntax
let d = Matrix {val = Vector [5,6,7,8], row = 2, col = 2, byRow = True}

-- Determinant
det c

-- Inverse
inv c

-- Transpose
transpose c

-- Matrix ops with Constant (+, -, *, /, ^)
c .+ 1 -- Matrix [[2,3],[4,5]]

-- Matrix ops with Matrix (+, -)
c + c -- Matrix [[2,4],[6,8]]

-- Matrix Multiplication
c %*% d

-- Matrix - Inverse Multiplication
c %/% d

-- Vector Concatenate
hcat a b -- Vector [1,2,3,4,5,6]
vcat a b -- Matrix [[1,2,3],[4,5,6]]

-- Matrix Concatenate
hcat c d -- Matrix [[1,2,5,6],[3,4,7,8]]
vcat c d -- Matrix [[1,2],[3,4],[5,6],[7,8]]

-- Insert Vector to Matrix
vector [1, 2] .: c -- Matrix [[1,2],[1,2],[3,4]]

Basic Stats Usage

-- Sample Vector (import Vector)
v = vector [1..10]
w = vector [10, 9 .. 1]

-- Mean
mean v

-- Var
var v

-- Std
std v

-- Cov Matrix
cov v w

-- Only Cov
cov' v w

-- Linear Fit
(intercept, slope) = lm v w -- (11.0, -1.0) -- (Intercept, Slope)

-- Linear Fit function
lineFit (intercept, slope) (Vector [1 .. 20])

-- RSS
rss v w

-- RSE
rse v w

DONE

  • Effective Matrix Structure (R-like Structure)
  • Divide and Conquer Matrix Multiplication, Determinant, Inverse
  • Module CSV with DataFrame (read / write)
  • FuncTools
  • Parallelize Matrix Arithmetics

TODO (2018.06.18)

  • DSL Documentation by LaTeX (Developing)
  • More Statistical Tools (Like Normal Distribution)
Metadata

Version

0.5.0.2

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows