Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApproximateConvergence ¶ added in v0.1.12
ApproximateConvergence approximates the convergence of a series. It calculates the average of the last n values.
Parameters:
- n: The number of values to calculate the average.
Returns:
- *big.Float: The average of the last n values.
- error: An error if the calculation fails.
Errors:
- *luc.ErrInvalidParameter: If n is less than or equal to 0 or if there are not enough values to calculate the average.
func CalculateConvergence ¶ added in v0.1.12
func CalculateConvergence(series Serieser, upperLimit int, delta int) (values []*big.Float, err error)
CalculateConvergence calculates the convergence of a series. It calculates the quotient of the ith term and the (i+delta)th term.
Parameters:
- series: The series to calculate the convergence.
- upperLimit: The upper limit of the series to calculate the convergence.
- delta: The difference between the terms to calculate the convergence.
Returns:
- *ConvergenceResult: The convergence result.
- error: An error if the calculation fails.
Types ¶
type LinearRegression ¶ added in v0.1.12
type LinearRegression struct { // A is the coefficient of the linear regression. A *big.Float // B is the exponent of the linear regression. B *big.Float }
LinearRegression is a struct that holds the equation of a linear regression.
func NewLinearRegression ¶ added in v0.1.12
func NewLinearRegression() *LinearRegression
NewLinearRegression creates a new LinearRegression.
Returns:
- LinearRegression: The new LinearRegression.
func (*LinearRegression) FindEquation ¶ added in v0.1.12
func (l *LinearRegression) FindEquation(values []*big.Float) bool
FindEquation is a method of ConvergenceResult that finds the equation of the series that best fits the convergence values.
The equation is of the form y = a * x^b.
Returns:
- bool: False if there are less than 2 values to calculate the equation. True otherwise.
If the receiver is nil, then false is returned.
func (*LinearRegression) String ¶ added in v0.1.12
func (lr *LinearRegression) String() string
String implements the fmt.Stringer interface.
Format: y = a * x^b
type Serieser ¶ added in v0.1.12
type Serieser interface { // Term returns the nth term of the series. // // Parameters: // - n: The term number. // // Returns: // - *big.Int: The nth term of the series. // - error: An error if the term cannot be calculated. Term(n int) (*big.Int, error) }
Serieser is an interface for series.