wte

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 2 Imported by: 0

README

wte

This library provides an implementation of the Whittaker-Eilers smoothing algorithm in Go. It is designed to smooth time series data or other sequences, offering support for both equally and non-equally spaced data. The library is particularly useful for reducing noise in data while preserving important signals.

Features

  • Whittaker-Eilers smoothing for sequences of float64.
  • Support for both equally and non-equally spaced data.
  • Customizable smoothing parameters.

Installation

To use this library, first ensure you have Go installed on your system. Then, you can install the library using go get:

go get -u github.com/njern/wte

Usage

package main

import (
    "fmt"
    "github.com/njern/wte"
)

func main() {
    data := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
    lambda := 10.0
    order := 2

    // For equally spaced data, pass nil for spacing
    smoothed, err := wte.Smooth(data, lambda, order, nil)
    if err != nil {
        panic(err)
    }

    fmt.Println("Smoothed data:", smoothed)
}

Contributing

Contributions to improve this library are welcome. Feel free to fork the repository, make your changes, and submit a pull request.

License

This library is licensed under the MIT License.

Acknowledgements

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Smooth

func Smooth(data []float64, lambda float64, order int, spacing []float64) ([]float64, error)

Smooth performs Whittaker-Eilers smoothing on a slice of float64. It applies a smoothing operation to the input data using the given lambda (smoothing parameter), order of differences, and spacing between data points.

Parameters: data - A slice of float64 representing the data to be smoothed. lambda - A float64 representing the smoothing parameter. Higher values increase smoothness. order - An int specifying the order of differences to be used in smoothing. spacing - A slice of float64 representing the spacing between consecutive data points.

Pass nil if the data is equally spaced. In this case, the function assumes a unit spacing.

Returns: A slice of float64 containing the smoothed data. The length of this slice will be the same as the input data. An error is returned if the function encounters issues in creating the penalty matrix or solving the system.

Example: smoothedData, err := Smooth([]float64{1, 2, 3, 4, 5}, 10.0, 2, nil)

if err != nil {
    // handle error
}

fmt.Println(smoothedData) // Output: [Smoothed Data]

Types

This section is empty.

Jump to

Keyboard shortcuts

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