|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmath.Stats
public class Stats
User: lyon Date: Aug 27, 2007 Time: 7:15:31 AM Copyright DocJava, Inc. 2005.
| Constructor Summary | |
|---|---|
Stats()
|
|
| Method Summary | |
|---|---|
static double |
avg(double[] source,
int period,
int startPoint)
|
static double |
bestFit(double[] source,
int period)
Calculate the line of best fit of the data given by source. |
static double[] |
bestFitFunction(double[] source,
int period)
Return the equation of the line of best fit of the data given by source. |
static double |
bollingerLower(double[] source,
int period,
double standardDeviation)
Calculate the lower band of the bollinger graph. |
static double |
bollingerUpper(double[] source,
int period,
double standardDeviation)
Calculate the upper band of the bollinger graph. |
double |
corr(double[] x,
double[] y,
int period)
Calculate the Pearson product-moment correlation between the two variables. |
static double[] |
cumProbability(double[] data,
double[] x)
This method calculates the cumulative probability curve of array data at locations x. |
static double |
cumulativeNormalDistributionFunction(double x)
|
static double |
ema(double[] source,
int period,
double smoothingConstant)
Calculate the Exponential Moving Average (EMA) value. |
static double |
ema(double[] source,
int period,
int startPoint,
double smoothingConstant)
|
static double |
getAverage(byte[] in)
|
static double |
getAverage(double[] in)
|
static double |
getAverage(short[] in)
|
static double |
getAverageUnsigned(byte[] in)
|
static double[] |
getAvg(double[] source,
int period)
Find the average of the given data. |
static double |
getCoefficientOfVariation(double[] doubles)
Compute the coefficient of variation by dividing the standard deviation by the sample mean |
static double[] |
getEma(double[] source,
int period,
double smoothingConstant)
Calculate the Exponential Moving Average (EMA) value. |
static double |
getMean(double[] source,
int period)
Find the average of the given quotes. |
static double |
getStandardDeviation(double[] d)
|
static double |
getStandardDeviation(double[] source,
int period)
Find the standard deviation of the given values. |
static double |
getVariance(double[] data)
This method calculates variance of a data set. |
static double[] |
getWindowedSums(double[] source,
int period)
Find the sum of the given data. |
static double |
getWindowSum(double[] source,
int period,
int startPoint)
Add up the data from the start point for period data points |
static double |
interp1(double[] x,
double[] y,
double x0)
This method linearly interpolates the (x,y) data at points x0. |
static double |
macd(double[] sourceSlow,
double[] sourceFast)
Calculate the Moving Average Convergence Divergence (MACD) value. |
static double |
median(double[] data)
This method calculates the median of a data set. |
static double |
momentum(double[] source,
int period)
Calculate the Momentum value. |
static int |
obv(double[] sourceOpen,
double[] sourceClose,
double[] sourceVolume,
int range,
int initialValue)
Calculate the On Balance Volume (OBV) value. |
static double |
powerMovingAverage(double[] sampleData,
int startPoint,
int period)
startpoint < sampleData.length - period |
static double |
roundDouble(double d,
int places)
|
static double |
rsi(double[] source,
int period)
Calculate the Relative Strength Indicator (RSI) value. |
static double |
sma(double[] sampleData,
int startPoint,
int period)
|
static double |
stdev(double[] source,
int period,
int startpoint)
Find the standard deviation of the given values. |
static void |
testSma()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Stats()
| Method Detail |
|---|
public static double stdev(double[] source,
int period,
int startpoint)
source - the source quotesperiod - the number of days to average
public static double avg(double[] source,
int period,
int startPoint)
public static double getWindowSum(double[] source,
int period,
int startPoint)
source - period - startPoint -
public static double[] getAvg(double[] source,
int period)
source - source of quotes to averageperiod - the number of days to average
public static double getAverage(double[] in)
public static double getAverage(short[] in)
public static double getAverage(byte[] in)
public static double getAverageUnsigned(byte[] in)
public static double[] getWindowedSums(double[] source,
int period)
source - source of data to sumperiod - the number of days to sum
public static double getStandardDeviation(double[] source,
int period)
source - the source quottesperiod - the number of days to average
public static double getStandardDeviation(double[] d)
public static double getMean(double[] source,
int period)
source - source of quotes to averageperiod - the number of days to average
public static double[] getEma(double[] source,
int period,
double smoothingConstant)
k is a smoothing
constant.
source - the source of quotes to averageperiod - the number of days to analysesmoothingConstant -
public static double ema(double[] source,
int period,
int startPoint,
double smoothingConstant)
public double corr(double[] x,
double[] y,
int period)
r = sum(Zx * Zy)
------------
N - 1
Where Zx = X - E(X)
--------
Sx
Where E(X) is the mean of X and Sx is the standard deviation of X.
Simillarly for Zy.
x - values to test againsty - values to detect correlation against xperiod - number of days to analyse
public static double rsi(double[] source,
int period)
100
RSI = 100 - ------
1 + RS
average of x days' up closes
RS = ------------------------------
average of x days' down closes
To calculate an X day RSI you need X + 1 quote values. So make
the period argument one more day that the period of the RSI.
public static double ema(double[] source,
int period,
double smoothingConstant)
k is a smoothing
constant.
source - the source of quotes to averageperiod - the number of days to analysesmoothingConstant - a smoothing constant
public static double macd(double[] sourceSlow,
double[] sourceFast)
sourceSlow - the source of quotes used by EMA to average (slow average)sourceFast - the source of quotes used by EMA to average (fast average)
public static double momentum(double[] source,
int period)
source - the source of quotes
public static int obv(double[] sourceOpen,
double[] sourceClose,
double[] sourceVolume,
int range,
int initialValue)
sourceOpen - the source of open quotessourceClose - the source of close quotessourceVolume - the source of volumesrange - the range which we calculate overinitialValue - the starting value of OBV
public static double bollingerUpper(double[] source,
int period,
double standardDeviation)
source - the source of quotesperiod - the number of days to analyse
public static double bollingerLower(double[] source,
int period,
double standardDeviation)
source - the source of quotesperiod - the number of days to analyse
public static double roundDouble(double d,
int places)
public static double bestFit(double[] source,
int period)
source - the source of quotesperiod - the number of days to analyse
public static double[] bestFitFunction(double[] source,
int period)
source - the source of quotesperiod - the number of days to analyse
public static void testSma()
public static double sma(double[] sampleData,
int startPoint,
int period)
sampleData - startPoint - - offset into the sample dataperiod - - interval of the average
public static double powerMovingAverage(double[] sampleData,
int startPoint,
int period)
sampleData - startPoint - - offset into the sample dataperiod - - interval of the average
public static double getCoefficientOfVariation(double[] doubles)
doubles -
public static double cumulativeNormalDistributionFunction(double x)
public static double median(double[] data)
data - The input data set
public static double getVariance(double[] data)
data - The input data set
public static double[] cumProbability(double[] data,
double[] x)
data - The input data setx - The locations to calculate cumulative probability
public static double interp1(double[] x,
double[] y,
double x0)
x - Input x valuesy - Input y valuesx0 - Locations to interpolate
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||