|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.strbio.math.FVector
public class FVector
a class to encapsulate a 1-D array of floats. Can do a bunch of math functions, and save/load from a file.
Version 1.21, 7/7/99 - added equals Version 1.2, 7/6/99 - added findNClosest, append, reverse Version 1.13, 6/7/99 - added print, changed some PrintfStream to Printf Version 1.12, 6/2/99 - added median, print Version 1.11, 4/16/99 - some error conditions (i.e. min() when there's no data) return Float.NaN, instead of (incorrect) 0.0. Version 1.1, 9/30/98 - added linearFit Version 1.01, 5/11/98 - added constructors from IVector, int[]. Version 1.0, 3/30/98 - original version.
IVector
,
FMatrix
Field Summary | |
---|---|
float[] |
data
data contains the actual array itself; it's public so that it can be manipulated directly (for speed, such as that is in java) and so that you can do something like 'dv.data[0] = tmp' as well as 'tmp = dv.data[0]' without needing 2 different functions. |
Constructor Summary | |
---|---|
FVector()
makes a blank vector of dimension 0; you can assign a int[] to the data directly, or load data in from a file |
|
FVector(float[] x)
makes a new FVector object out of a int[] array. |
|
FVector(FVector x)
copies another FVector. |
|
FVector(int dim)
makes an emptry FVector object with a specified dimension All data should be zeroed out... this is not done explicitly, but relies on Java's default values. |
|
FVector(int[] x)
makes a new FVector object out of a int[] array. |
|
FVector(IVector x)
copies an IVector, copying the data and casting to floats. |
Method Summary | |
---|---|
void |
add(FVector x)
Adds another FVector to this one. |
static FVector |
add(FVector a,
FVector b)
Adds two FVector's and returns a new FVector containing the sum. |
void |
append(FVector x)
appends the contents of another FVector to this one. |
static FVector |
append(FVector x,
FVector y)
Returns a new FVector containing the first argument appended to the second. |
float |
average()
Returns the average value in the array. |
float |
averageRW()
Returns the average value in the array, weighting each value using reciprocal weighting. |
float |
covar(FVector y)
Returns the covariance of values in this array with those in another array. |
FVector |
cross(FVector x)
Returns the cross product of multiplying this with another vector. |
static FVector |
cross(FVector x,
FVector y)
Returns the cross product of multiplying two vectors. |
int |
dimension()
returns the dimension the encapsulated array. |
float |
distance(FVector x)
Returns the distance between this point and one pointed two by another FVector. |
static float |
distance(FVector a,
FVector b)
Returns the distance between two points pointed to by FVectors a and b. |
void |
divide(float x)
Divides this FVector by a specified float. |
static FVector |
divide(FVector a,
float b)
Divides a FVector by a float, and returns a new FVector containing the result. |
float |
dot(FVector x)
Returns the dot product of multiplying this with another vector. |
static float |
dot(FVector x,
FVector y)
Returns the dot product of multiplying two vectors. |
boolean |
equals(java.lang.Object x)
mathematical objects are equal if their contents are. |
IVector |
findNClosest(int n,
float v)
What are the indices of the N closest values to a given float? |
int |
length()
returns the dimension the encapsulated array. |
float[] |
linearFit(FVector y)
This will return the best linear fit to a bunch of points, assuming that this FVector contains x's, and FVectory y contains y's. |
void |
load(java.io.BufferedReader infile)
Load from an open BufferedReader. |
void |
load(java.lang.String filename)
Loads from a text file. |
FVector |
makeZScores()
returns a vector containing the Z scores for all data in the array. |
float |
max()
What's the maximum value in the array? |
float |
median()
Returns the median value in the array. |
float |
min()
What's the minimum value in the array? |
void |
multiply(float x)
Multiplies all values in this FVector by a specified int. |
static FVector |
multiply(float b,
FVector a)
Multiplies a FVector by an int and returns a new FVector containing the result. |
void |
multiply(FMatrix x)
Multplies this FVector by a FMatrix. |
static FVector |
multiply(FMatrix b,
FVector a)
Multplies a FVector by a FMatrix, and returns a new FVector with the result. |
static FVector |
multiply(FVector a,
float b)
Multiplies a FVector by an int and returns a new FVector containing the result. |
static FVector |
multiply(FVector a,
FMatrix b)
Multplies a FVector by a FMatrix, and returns a new FVector with the result. |
float |
norm()
What's the norm of this array? |
float |
normalize()
Rescale array so the norm is one. |
float |
pearson(FVector y)
Returns the Pearson correlation coefficient R of values in this array with values in another array. |
void |
print(Printf outfile)
prints in ascii to an open Printf, with a nicer format than 'save'. |
void |
reverse()
reverses the order of data in the vector. |
static FVector |
reverse(FVector x)
returns a vector which is the reverse of this one. |
void |
save(Printf outfile)
Save to an open Printf. |
void |
save(java.lang.String filename)
Saves to a new text file. |
void |
setValue(float x)
Sets every value in the array to a specified float. |
void |
setValueAt(int x,
float d)
Sets the data at a given index. |
IVector |
sort()
returns a vector of indices to sort an FVector (small -> large). |
float |
stdev()
Returns the standard deviation of a distribution containing all values in the array. |
float |
stdevp()
Returns the standard deviation of a distribution containing all values in the array. |
void |
subtract(FVector x)
Subtracts another FVector from this one. |
static FVector |
subtract(FVector a,
FVector b)
Subtracts one FVector's from another returns a new FVector containing the difference. |
void |
transform(FMatrix x)
transforms this vector using a transformation FMatrix. |
float |
valueAt(int x)
Returns the data at a given index. |
float |
zScore(float x)
Shows how many standard deviations (of this array) a given float is below the average (of this array) |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public float[] data
Constructor Detail |
---|
public FVector(int dim)
dim
- dimensionpublic FVector()
public FVector(float[] x)
public FVector(FVector x)
public FVector(int[] x)
public FVector(IVector x)
Method Detail |
---|
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
public final int length()
public final int dimension()
public final float valueAt(int x)
x
- indexpublic final void setValueAt(int x, float d)
x
- indexd
- value to set the data topublic final void setValue(float x)
public final void add(FVector x)
public static final FVector add(FVector a, FVector b)
public final void append(FVector x)
public static final FVector append(FVector x, FVector y)
public final void reverse()
public static final FVector reverse(FVector x)
public final void subtract(FVector x)
public static final FVector subtract(FVector a, FVector b)
public final void multiply(float x)
public static final FVector multiply(FVector a, float b)
public static final FVector multiply(float b, FVector a)
public final void multiply(FMatrix x)
public static final FVector multiply(FVector a, FMatrix b)
public static final FVector multiply(FMatrix b, FVector a)
public final void divide(float x)
public static final FVector divide(FVector a, float b)
public final float norm()
public final float normalize()
FMatrix.normalize()
public static final float distance(FVector a, FVector b)
public final float distance(FVector x)
public final float dot(FVector x)
public static final float dot(FVector x, FVector y)
public final FVector cross(FVector x)
public static final FVector cross(FVector x, FVector y)
public final float average()
public final float averageRW()
public final float median()
public final float stdev()
public final float stdevp()
public final float covar(FVector y)
java.lang.IllegalArgumentException
- if the arrays are not the same size.public final float pearson(FVector y)
java.lang.IllegalArgumentException
- if the arrays are not the same size.public final float[] linearFit(FVector y)
public final float zScore(float x)
makeZScores()
public final float max()
public final float min()
public final IVector findNClosest(int n, float v)
public final FVector makeZScores()
zScore(float)
public final void transform(FMatrix x)
FMatrix.makeTransform(float, float, float, float, float, float)
public IVector sort()
public void print(Printf outfile) throws java.io.IOException
java.io.IOException
save(org.strbio.io.Printf)
public void save(Printf outfile) throws java.io.IOException
java.io.IOException
Printf
public void load(java.io.BufferedReader infile) throws java.io.IOException
java.io.IOException
BufferedReader
public void save(java.lang.String filename) throws java.io.IOException
filename
- the file name.
java.io.IOException
public void load(java.lang.String filename) throws java.io.IOException
filename
- the file name.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |