comply

package
v0.0.0-...-325efec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package comply provides routines that do not make sense to be written from scratch/ provided in pkg, or have other design constrains that are imposed for the sake of complying with the problem statements in the assignment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LU

type LU struct {
	// contains filtered or unexported fields
}

We define out own LU decomposition here and not as a reusable package in pkg, since there is already very good LU decomposition functionality in gonum (based on LAPACK and BLAS), which is preferable to this home-cooked solution.

func NewLU

func NewLU(m mat.Matrix) (*LU, error)

NewLU decomposes a given matrix into lower and upper triangular matrix.

func (*LU) Invert

func (lu *LU) Invert() mat.Matrix

Invert returns A^-1 where A = LU.

func (*LU) L

func (lu *LU) L() mat.Matrix

L returns the lower triangular decomposition matrix.

func (*LU) Solve

func (lu *LU) Solve(y mat.Vector) mat.Vector

Solve solves for x in Ax = LUx = y.

func (*LU) U

func (lu *LU) U() mat.Matrix

U returns the upper triangular decomposition matrix.

type Rejection

type Rejection struct {
	C        float64
	Target   distuv.LogProber
	Proposal distuv.RandLogProber
	Src      rand.Source
}

RejectionSample implements rejection sampling. Note that this is implemented in comply, since Gonum has a robust and tested rejection sampling implementation. This types interface is modeled on Gonum's distuv.Rejection type. This implementation is more simplistic than the the Gonum one, and panics on any errors it encounters. It also requires a random source and does not fall back to other sources of randomness if Rejection.Src == nil.

func (*Rejection) Sample

func (r *Rejection) Sample(batch []float64)

Sample samples len(batch) numbers from the target distribution. This implements a distuv.Sampler.

type SplineRange

type SplineRange struct {
	// contains filtered or unexported fields
}

We have a separate spline range here to comply with using the home-cooked LU decomposition instead of the much more stable and faster inline tridiagonal band solver...

func NewSplineRange

func NewSplineRange(xs, ys []float64) (*SplineRange, error)

NewSplineRange is a compliant version of interpolate.NewSplineRange

func (*SplineRange) Bounds

func (r *SplineRange) Bounds() (float64, float64)

Bounds implements a Range.

func (*SplineRange) Eval

func (r *SplineRange) Eval(x float64) (y float64, err error)

Eval implements a Range.

func (*SplineRange) InBounds

func (r *SplineRange) InBounds(x float64) bool

InBounds implements a Range.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL