math

package
v0.0.0-...-e2be882 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fit

func Fit(x, y []float64, degree int) ([]float64, error)

Fit fits the given series of x and y into a polynomial function of the given degree out put is a vector with the coefficients of the corresponding powers of x c[0] + c[1]x + c[2]x^2 + c[3]x^3 + ...

func Format

func Format(f float64) string

Format formats a float based on the given precision TODO : format based on the value

func GenerateFloats

func GenerateFloats(num int, gen Generator) []float64

GenerateFloats generates a series of floats

func IO10

func IO10(f float64) int

IO10 returns the order of the value on a decimal basis NOTE : this does not differentiate between values bigger or smaller than 1 NOTE : It s effectively a value inverse of the O10 NOTE : contradictory to O10 this will differentiate based on the sign NOTE : it returns results in a range of 10, with 10 representing the largest absolute value !!!

func IO2

func IO2(f float64) int

IO2 returns the order of the value on a binary basis NOTE : this does not differentiate between values bigger or smaller than 1 NOTE : It s effectively a value inverse of the O2 NOTE : contradictory to O2 this will differentiate based on the sign NOTE : it returns results in a range of 10, with 10 representing the largest absolute value !!!

func O10

func O10(f float64) int

O10 returns the order of the value on a decimal basis NOTE : this does not differentiate between values bigger or smaller than 1

func O2

func O2(f float64) int

O2 returns the binary order of the value on a decimal basis NOTE : this does not differentiate between values bigger or smaller than 1

func Series

func Series(factor float64, limit int) []float64

func Sine

func Sine(factor float64, limit int, v float64) []float64

func SineEvolve

func SineEvolve(i int, p float64) float64

SineEvolve will evolve the given int to a sine

func String

func String(length int) string

func StringWithCharset

func StringWithCharset(length int, charset string) string

func ToFloat

func ToFloat(ii []int) []float64

func ToInt

func ToInt(ff []float64) []int

Types

type AggregateStats

type AggregateStats struct {
	RSI    int
	ERSI   int
	EMA    float64
	Sample int
}

AggregateStats are the aggregate stats of the bucket windows.

func NewAggregateStats

func NewAggregateStats(indicators *Indicators) AggregateStats

NewAggregateStats create new aggregate stats from the given indicators

type EMA

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

EMA calculates the exponential moving average for the given sample.

func NewEMA

func NewEMA() *EMA

NewEMA creates a new EMA

func (*EMA) Add

func (ema *EMA) Add(f float64)

Add adds a value to the sample

func (*EMA) Get

func (ema *EMA) Get() (value float64, count int)

Get returns the calculated ema

type Generator

type Generator func(i int) float64

func VaryingSine

func VaryingSine(base, amplitude, period float64) Generator

VaryingSine defines a generator which varies around the given sine

type Indicators

type Indicators struct {
	RSI *RSI
	EMA *EMA
}

Indicators is a stats collector based on the rsi and ema indicators

func NewIndicators

func NewIndicators() *Indicators

NewIndicators creates new stats collector

func (*Indicators) Add

func (s *Indicators) Add(f float64)

Add adds the given value to the indicator collectors.

type Network

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

Network defines an ml network.

func NewML

func NewML(network *ff.Network) *Network

NewML creates a new ml network.

func (*Network) Predict

func (n *Network) Predict(in []float64) []float64

Predict returns the predicted output.

func (*Network) Train

func (n *Network) Train(in, out []float64) float64

Train digests the input and returns the currently predicted output.

type RNum

type RNum struct {
	Amplitude float64
	Frequency int
	Cos       complex128
}

RNum defines a complex number attributes

type RSI

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

RSI is an RSI streaming calculator

func NewRSI

func NewRSI() *RSI

NewRSI creates a new RSI calculator

func (*RSI) Add

func (rsi *RSI) Add(f float64)

Add adds another value for the RSI calculation and returns the intermediate result.

func (*RSI) Get

func (rsi *RSI) Get() (value, evalue, count int)

Get returns the rsi for the added samples

type Spectrum

type Spectrum struct {
	Values    []RNum
	Amplitude float64
}

Spectrum is a collection of spectra

func FFT

func FFT(xx []float64) *Spectrum

func (*Spectrum) Mean

func (s *Spectrum) Mean() float64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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