mahalanobis

package module
v0.0.0-...-414d745 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2013 License: MIT Imports: 3 Imported by: 0

README

PACKAGE

package mahalanobis
    import "github.com/ant0ine/go.mahalanobis"

    Naive implementation of the Mahalanobis distance using go.matrix
    (https://en.wikipedia.org/wiki/Mahalanobis_distance)

    This is me learning Go, it's probably broken, don't use it.

    Example:

	package main
	import (
	    "fmt"
	    "github.com/skelterjohn/go.matrix"
	    "github.com/ant0ine/go.mahalanobis"
	)
	func main() {
	    points := matrix.MakeDenseMatrix([]float64{
	        1, 4, 3, 4,
	        4, 2, 3, 4,
	    }, 2, 4)
	    fmt.Println("4 points:\n", points)
	    target := matrix.MakeDenseMatrix([]float64{
	        3,
	        4,
	    }, 2, 1)
	    fmt.Println("the target point:\n", target)
	    distance, err := mahalanobis.Distance(points, target)
	    if err != nil {
	        panic(err)
	    }
	    fmt.Println("Mahalanobis distance=", distance)
	}

FUNCTIONS

func CovarianceMatrix(points *matrix.DenseMatrix) *matrix.DenseMatrix
    Return the covariance matrix for this set of points (sample covariance
    is used) points.Rows() = dimensions. points.Cols() = number of points.

func Distance(points, target *matrix.DenseMatrix) (float64, error)
    Return the Mahalanobis distance points.Rows() = dimensions.
    points.Cols() = number of points. target.Cols = 1

func DistanceSquare(points, target *matrix.DenseMatrix) (float64, error)
    Return the square of the Mahalanobis distance points.Rows() =
    dimensions. points.Cols() = number of points. target.Cols = 1

func MeanVector(points *matrix.DenseMatrix) *matrix.DenseMatrix
    Given a set a points, return the mean vector. points.Rows() =
    dimensions. points.Cols() = number of points.


Documentation

Overview

Naive implementation of the Mahalanobis distance using go.matrix (https://en.wikipedia.org/wiki/Mahalanobis_distance)

This is me learning Go, it's probably broken, don't use it.

Example:

package main

import (
    "fmt"
    "github.com/skelterjohn/go.matrix"
    "github.com/ant0ine/go.mahalanobis"
)

func main() {

    points := matrix.MakeDenseMatrix([]float64{
        1, 4, 3, 4,
        4, 2, 3, 4,
    }, 2, 4)
    fmt.Println("4 points:\n", points)

    target := matrix.MakeDenseMatrix([]float64{
        3,
        4,
    }, 2, 1)
    fmt.Println("the target point:\n", target)

    distance, err := mahalanobis.Distance(points, target)
    if err != nil {
        panic(err)
    }
    fmt.Println("Mahalanobis distance=", distance)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CovarianceMatrix

func CovarianceMatrix(points *matrix.DenseMatrix) *matrix.DenseMatrix

Return the covariance matrix for this set of points (sample covariance is used) points.Rows() = dimensions. points.Cols() = number of points.

func Distance

func Distance(points, target *matrix.DenseMatrix) (float64, error)

Return the Mahalanobis distance points.Rows() = dimensions. points.Cols() = number of points. target.Cols = 1

func DistanceSquare

func DistanceSquare(points, target *matrix.DenseMatrix) (float64, error)

Return the square of the Mahalanobis distance points.Rows() = dimensions. points.Cols() = number of points. target.Cols = 1

func MeanVector

func MeanVector(points *matrix.DenseMatrix) *matrix.DenseMatrix

Given a set a points, return the mean vector. points.Rows() = dimensions. points.Cols() = number of points.

Types

This section is empty.

Jump to

Keyboard shortcuts

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