|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.numericalmethod.suanshu.analysis.sequence.Summation
public class Summation
Summation sums up the Summation.Terms.
Summation = ∑(xi)
where xi are the terms.
If a threshold is specified, the summation is treated as a convergent series.
The summing process stops after xi < threshold.
Sample usages:
Summation series = new Summation(new Summation.Term() {
public double evaluate(double i) {
return i;
}
});
double sum = series.sum(1, 100);
Summation series = new Summation(new Summation.Term() {
public double evaluate(double i) {
return 1d / i;
}
}, 0.0001);
double sum = series.sumToInfinity(1);
| Nested Class Summary | |
|---|---|
static interface |
Summation.Term
Define the terms in a summation series. |
| Field Summary | |
|---|---|
Summation.Term |
term
the terms to sum up in a series It takes an index, and computes a value; |
double |
threshold
the convergence threshold for a convergent series When a term falls below this threshold, the summing process stops. |
| Constructor Summary | |
|---|---|
Summation(Summation.Term term)
Constructor a Summation instance with a term structure. |
|
Summation(Summation.Term term,
double threshold)
Construct a Summation instance with a term structure and a threshold. |
|
| Method Summary | |
|---|---|
double |
sum(double[] indices)
Finite summation of the terms. |
double |
sum(double from,
double to,
double inc)
Sum up the terms from from to to with the increment inc. |
double |
sum(int from,
int to)
Sum up the terms from from to to with the increment 1. |
double |
sum(int from,
int to,
int inc)
Sum up the terms from from to to with the increment inc. |
double |
sumToInfinity(double from,
double inc)
Sum up the terms from from to infinity with increment inc until the series converges. |
double |
sumToInfinity(int from)
Sum up the terms from from to infinity with increment 1 until the series converges. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final Summation.Term term
It takes an index, and computes a value;
public final double threshold
When a term falls below this threshold, the summing process stops.
For a finite summation, threshold should be set to 0.
| Constructor Detail |
|---|
public Summation(Summation.Term term,
double threshold)
term structure and a threshold.
This series is assumed to converge with terms falling below the threshold for all terms after a certain index.
term - the terms to sum upthreshold - the convergence thresholdpublic Summation(Summation.Term term)
term structure.
This series is assumed to be a finite summation.
term - the terms to sum up| Method Detail |
|---|
public double sum(int from,
int to)
from to to with the increment 1.
from - the starting indexto - the ending index
public double sum(int from,
int to,
int inc)
from to to with the increment inc.
from - the starting indexto - the ending indexinc - the increment
public double sum(double from,
double to,
double inc)
from to to with the increment inc.
from - the starting indexto - the ending indexinc - the increment
public double sum(double[] indices)
terms.
indices - the indices to evaluate
public double sumToInfinity(int from)
from to infinity with increment 1 until the series converges.
from - the starting index
public double sumToInfinity(double from,
double inc)
from to infinity with increment inc until the series converges.
from - the starting indexinc - the increment
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||