jhplot
Class P0I

java.lang.Object
  extended by jhplot.P0I
All Implemented Interfaces:
java.io.Serializable

public class P0I
extends java.lang.Object
implements java.io.Serializable

A container to hold data points in one dimension. All numbers are expected to be integers. It extends ArrayList and adds many new features for data manipulation. The class does not have graphical option (use H1D to show the data or methods of this class which transform P0I to a H1D histogram).

See Also:
Serialized Form

Constructor Summary
P0I()
          Construct an empty container with a title
P0I(int[] d)
          Construct P0I from an integer array.
P0I(IntArrayList d)
          Construct P0I from IntegerArrayList from cern.colt.list.IntegerArrayList;
P0I(java.lang.Integer[] d)
          Construct P0I from array;
P0I(java.lang.String title)
          Construct an empty container with a title
P0I(java.lang.String title, boolean shallow, P0I P0I)
          Construct a copy from a P0I.
P0I(java.lang.String title, int[] d)
          Create P0I from an array.
P0I(java.lang.String title, java.lang.Integer[] d)
          Construct P0I from integers.
P0I(java.lang.String title, java.lang.String sfile)
          Construct a P0I from a file.
 
Method Summary
 void add(int value)
          Adds (appends) the specified element to the end of this list.
 void add(java.lang.Integer value)
          Adds (appends) the specified element to the end of this list.
 void clear()
          Clear the container
 boolean contains(java.lang.Integer d)
          Returns true if value exists
 P0I copy()
          Get a copy of the current holder
 P0I copy(java.lang.String newtitle)
          Create an exact copy of the current P0I.
 double correlation(P0I P0I)
          Returns the correlation coefficient.
 double covariance(P0I P0I)
          Returns the covariance
 void doc()
          Show online documentation.
 void fill(int[] values)
          Fill a P0I container from an array.
 void fill(java.lang.Integer[] values)
          Fill a P0I container from an array.
 void fill(int TotNumber, java.lang.Integer min, java.lang.Integer max)
          Fill with a sequence of numbers between min and max.
 int find(java.lang.Integer d)
          Returns the index of first occurrence of the specified element
 P0I func(F1D f1d)
          Transform P0I array to array with values given by a function.
 P0I func(java.lang.String title, F1D f1d)
          Make transformation of P0I using a function.
 java.lang.Integer get(int i)
          Return a specific value at ith position.
 P0I get(int d, java.lang.String opi)
          Get P0I with values below, above or equal a specified value.
 int[] getArray()
          Get integer array with P0I values.
 double[] getArrayDouble()
          Get a double array with P0I values.
 java.util.ArrayList<java.lang.Integer> getArrayList()
          Get data in form of ArrayList
 H1D getH1D(int bins)
          Return H1D histogram with P0I content.
 H1D getH1D(int bins, java.lang.Integer min, java.lang.Integer max)
          Return H1D histogram with P0I content.
 IntArrayList getIntArrayList()
          Get data in form of IntArrayList from cern.colt package
 DoubleArrayList getIntegerArrayList()
          Get data in form of DoubleArrayList from cern.colt package
 java.lang.Integer getMax()
          Returns the maximum value.
 int getMaxIndex()
          Returns index corresponding to maximum value.
 java.lang.Integer getMin()
          Returns the minimum value.
 int getMinIndex()
          Returns index corresponding to minimum value.
 java.lang.String getStat()
          Print all statistics of the container
 java.lang.Integer getSum()
          Returns the sum of all values.
 java.lang.String getTitle()
          Get a new title
 double kurtosis()
          Returns the kurtosis.
static void main(java.lang.String[] args)
          Test
 double mean()
          Returns the mean value.
 double median()
          Returns the median.
 P0I merge(P0I a)
          Merge two P0I containers
 double moment(int k, java.lang.Integer c)
          Returns the moment of k-th order with value c, which is Sum( (x[i]-c)k ) / size().
 P0I oper(P0I P0I, java.lang.String what)
          Operations on P0I containers: add, subtract, multiply, divide.
 P0I oper(P0I P0I, java.lang.String title, java.lang.String what)
          Operations on P0I containers: add, subtract, multiply, divide.
 P0I operScale(java.lang.Integer scale)
          Scale P0I with a factor scale.
 P0I operShift(java.lang.Integer shift)
          Shift all values in the array by a constant.
 P0I operShiftAndScale(java.lang.Integer shift, java.lang.Integer scale)
          Shift all values by a constant "shift", then scale it.
 void print()
          Print a P0I container.
 void random(int TotNumber, AbstractDistribution dist)
          Fill array with random numbers
 void randomNormal(int TotNumber, double mu, double sigma)
          Fill with random numbers distributed using the normal (gaussian) distribution.
 void randomUniform(int TotNumber, java.lang.Integer min, java.lang.Integer max)
          Fill with with uniform random numbers between min and max.
 P0I range(int min, int max)
          Get range between min and max
 int read(java.lang.String sfile)
          Read one dimensional data from uncompressed ASCII file.
 int readBinary(java.lang.String name)
          Read a P0I from a binary file (big endian by default).
 int readGZip(java.lang.String sfile)
          Read one dimensional data from GZIP ASCII file.
 P0I readSerialized(java.lang.String name)
          Read a P0I object from a serialized file
 int readZip(java.lang.String sfile)
          Read one dimensional data from ZIP ASCII file.
 void remove(int i)
          Remove a value at the specified position.
 P0I reverse()
          Reverse the order of elements
 int search(java.lang.Integer value)
          Search for the first occurrence of the given argument
 void set(int i, java.lang.Integer value)
          Sets a value at the specified position.
 void setArray(int[] array)
          Set an integer array.
 void setArray(java.lang.Integer[] array)
          Set a Integer array.
 void setArrayList(java.util.ArrayList<java.lang.Integer> array)
          Set the data in form of ArrayList
 void setTitle(java.lang.String title)
          Set a new title
 int size()
          Return the P10 data length.
 double skew()
          Returns the skew, which is moment(3,mean()) / standardDeviation() Run getStat(0 for evaluation
 P0I sort()
          Sort into ascending order
 double standardError()
          Returns the sample standard error, which is Math.sqrt(variance() / size()).
 double stddeviation()
          Returns the standard deviation (square root of variance)
 void toFile(java.lang.String name)
          Write a P0I to an external file.
 java.lang.String toString()
          Get a P0I as a string.
 void toTable()
          Print the P0I container to a Table in a separate Frame.
 void toTable(boolean format)
          Print the P0I array to a Table in a separate Frame.
 double variance()
          Returns the variance.
 void writeBinary(java.lang.String name)
          Write a P0I to a binary file (big endian by default).
 int writeSerialized(java.lang.String name)
          Write a P0I object to a serialized file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

P0I

public P0I(java.lang.String title)
Construct an empty container with a title

Parameters:
title - New title

P0I

public P0I(IntArrayList d)
Construct P0I from IntegerArrayList from cern.colt.list.IntegerArrayList;

Parameters:
d - IntegerArrayList from

P0I

public P0I(java.lang.Integer[] d)
Construct P0I from array;

Parameters:
d - array (Integer)

P0I

public P0I(java.lang.String title,
           int[] d)
Create P0I from an array.

Parameters:
title - title
d - input array

P0I

public P0I(int[] d)
Construct P0I from an integer array.

Parameters:
d - integer array

P0I

public P0I(java.lang.String title,
           java.lang.Integer[] d)
Construct P0I from integers.

Parameters:
title - title;
d - input array

P0I

public P0I(java.lang.String title,
           boolean shallow,
           P0I P0I)
Construct a copy from a P0I. If the last argument is true, a shallow copy of a collection. In this case a new collection contains references to same objects as the source collection. Data are not cloned

Parameters:
title - new title
shallow - if true, a shallow copy of a collection.
P0I - input data in form of P0I

P0I

public P0I()
Construct an empty container with a title


P0I

public P0I(java.lang.String title,
           java.lang.String sfile)
Construct a P0I from a file. Use "#" or "*" for comments. each number should be written in separate line.

Parameters:
title - Title of the container
sfile - File name with input
Method Detail

setTitle

public void setTitle(java.lang.String title)
Set a new title

Parameters:
title - New Title

getTitle

public java.lang.String getTitle()
Get a new title

Returns:
Title

read

public int read(java.lang.String sfile)
Read one dimensional data from uncompressed ASCII file. Use "#" or "*" for comments. Each number should be written in separate line.

Parameters:
sfile - File name with input
Returns:
error: 0 in case of success. 3: parse error. 1-2: file not found.

readGZip

public int readGZip(java.lang.String sfile)
Read one dimensional data from GZIP ASCII file. Use "#" or "*" for comments. Each number should be written in separate line.

Parameters:
sfile - Gziped file name with input (file extension .gz)
Returns:
error: 0 in case of success. 3: parse error. 1-2: file not found.

readZip

public int readZip(java.lang.String sfile)
Read one dimensional data from ZIP ASCII file. Use "#" or "*" for comments. Each number should be written in separate line.

Parameters:
sfile - Zipped file name with input (file extension .zip)
Returns:
error (int): 0 in case of success. 3: parse error. 1-2: file not found.

toFile

public void toFile(java.lang.String name)
Write a P0I to an external file.

Parameters:
name - File name with output

writeBinary

public void writeBinary(java.lang.String name)
Write a P0I to a binary file (big endian by default).

Parameters:
name - Binary file name for the output.

writeSerialized

public int writeSerialized(java.lang.String name)
Write a P0I object to a serialized file

Parameters:
name - serialized file name for output.
Returns:
zero if no errors

readSerialized

public P0I readSerialized(java.lang.String name)
Read a P0I object from a serialized file

Parameters:
name - serialized file name for input.
Returns:
new P0I object

readBinary

public int readBinary(java.lang.String name)
Read a P0I from a binary file (big endian by default). Old elements will be removed. Only read files created by the method writeBinary().

Parameters:
name - Binary file name for input.
Returns:
0 in case of no problems

toString

public java.lang.String toString()
Get a P0I as a string.

Overrides:
toString in class java.lang.Object
Returns:
Output String. Each value separated by new line.

randomNormal

public void randomNormal(int TotNumber,
                         double mu,
                         double sigma)
Fill with random numbers distributed using the normal (gaussian) distribution. Previous content will be lost.

Parameters:
TotNumber - total number of random values
mu - mean value
sigma - Standard deviation of the random variable.

fill

public void fill(int TotNumber,
                 java.lang.Integer min,
                 java.lang.Integer max)
Fill with a sequence of numbers between min and max. min and max are included to the range, If non-empty, previous content will be lost.

The step is evaluated as (max-min) / (TotNumber -1). For example, fill(11,0,10) will fill with 11 number: 0,1,2,3,4,5,6,7,8,9,10

Parameters:
TotNumber - total number of values.
min - min value
max - max value

randomUniform

public void randomUniform(int TotNumber,
                          java.lang.Integer min,
                          java.lang.Integer max)
Fill with with uniform random numbers between min and max. Previous content will be lost.

Parameters:
TotNumber - of random values
min - min random value
max - max random value

random

public void random(int TotNumber,
                   AbstractDistribution dist)
Fill array with random numbers

Parameters:
TotNumber - Total number in array
dist - A custom random distribution

getH1D

public H1D getH1D(int bins)
Return H1D histogram with P0I content. Histogram range is defined by Min and Max values.

Parameters:
bins - Number of bins for the histogram.
Returns:
H2D histogram filled with P0I.

getH1D

public H1D getH1D(int bins,
                  java.lang.Integer min,
                  java.lang.Integer max)
Return H1D histogram with P0I content. Histogram range is defined by Min and Max values.

Parameters:
min - Min value of histogram
max - Max value of histogram
bins - Number of bins for the histogram.
Returns:
H2D histogram filled with P0I.

print

public void print()
Print a P0I container.


merge

public P0I merge(P0I a)
Merge two P0I containers

Parameters:
a - Container to be merged
Returns:
merged P0I container

add

public void add(java.lang.Integer value)
Adds (appends) the specified element to the end of this list.

Parameters:
value - value to be added.

add

public void add(int value)
Adds (appends) the specified element to the end of this list. Note: you can add integer, but it will be transformed to Integer.

Parameters:
value - value to be added.

fill

public void fill(java.lang.Integer[] values)
Fill a P0I container from an array. If it is not empty, add values will be appended.

Parameters:
values - array with Integer values

fill

public void fill(int[] values)
Fill a P0I container from an array. If it is not empty, add values will be appended. Integers will be converted to Integer.

Parameters:
values - array with Integer values

set

public void set(int i,
                java.lang.Integer value)
Sets a value at the specified position. Old value will be replaced.

Parameters:
i - position
value - value to be inserted

remove

public void remove(int i)
Remove a value at the specified position. Old value will be replaced.

Parameters:
i - position of a value to be removed

size

public int size()
Return the P10 data length.

Returns:
length of the PlotPoint vector

copy

public P0I copy()
Get a copy of the current holder

Returns:
a new copy

getArrayList

public java.util.ArrayList<java.lang.Integer> getArrayList()
Get data in form of ArrayList

Returns:
data in form of ArrayList

getIntArrayList

public IntArrayList getIntArrayList()
Get data in form of IntArrayList from cern.colt package

Returns:
data in form of IntegerArrayList

getIntegerArrayList

public DoubleArrayList getIntegerArrayList()
Get data in form of DoubleArrayList from cern.colt package

Returns:
data in form of DoubleArrayList

setArrayList

public void setArrayList(java.util.ArrayList<java.lang.Integer> array)
Set the data in form of ArrayList

Parameters:
array - ArrayList to be set.

setArray

public void setArray(java.lang.Integer[] array)
Set a Integer array. Old content will be lost.

Parameters:
array - array used to fill P0I

setArray

public void setArray(int[] array)
Set an integer array. Old content will be lost. It will be automatically transformed to the Integer.

Parameters:
array - array used to fill P0I

copy

public P0I copy(java.lang.String newtitle)
Create an exact copy of the current P0I.

Parameters:
newtitle - new title

get

public P0I get(int d,
               java.lang.String opi)
Get P0I with values below, above or equal a specified value. Specify in the input string "<,> or =".

Parameters:
d - input values
opi - if "=", take equal values;
if ">", take above values;
if "<", take below values;

contains

public boolean contains(java.lang.Integer d)
Returns true if value exists

Parameters:
d - Integer value

find

public int find(java.lang.Integer d)
Returns the index of first occurrence of the specified element

Parameters:
d - input value

getArray

public int[] getArray()
Get integer array with P0I values.

Returns:
Integer array with values

getArrayDouble

public double[] getArrayDouble()
Get a double array with P0I values.

Returns:
Double array with values

get

public java.lang.Integer get(int i)
Return a specific value at ith position.

Parameters:
i - index of the array
Returns:
the value of x at index i

search

public int search(java.lang.Integer value)
Search for the first occurrence of the given argument

Parameters:
value - value for searching
Returns:
first occurrence of the given argument

getMax

public java.lang.Integer getMax()
Returns the maximum value.

Returns:
the maximum value.

getMaxIndex

public int getMaxIndex()
Returns index corresponding to maximum value.

Returns:
index of maximum value.

getMinIndex

public int getMinIndex()
Returns index corresponding to minimum value.

Returns:
index of minimum value.

getMin

public java.lang.Integer getMin()
Returns the minimum value.

Returns:
the minimum value.

getSum

public java.lang.Integer getSum()
Returns the sum of all values.

Returns:
sum of all values

range

public P0I range(int min,
                 int max)
Get range between min and max

Parameters:
min - index
max - index
Returns:
same P0I with removed range

oper

public P0I oper(P0I P0I,
                java.lang.String what)
Operations on P0I containers: add, subtract, multiply, divide. Keep the same graphical attributes and the title.

Parameters:
P0I - Input P0I container for operation
what - String representing the operation: "+" add a P0I container to the original; "-" subtract a P0I from the original; "*" multiply; "/" divide by P0I
Returns:
original P0I after the operation.

operScale

public P0I operScale(java.lang.Integer scale)
Scale P0I with a factor scale. X(i)=scale*X(i)

Parameters:
scale - Scale factor
Returns:
P0I after the operation.

operShift

public P0I operShift(java.lang.Integer shift)
Shift all values in the array by a constant. X(i)=X(i)+shift.

Parameters:
shift - constants used to add
Returns:
P0I after shift.

operShiftAndScale

public P0I operShiftAndScale(java.lang.Integer shift,
                             java.lang.Integer scale)
Shift all values by a constant "shift", then scale it. X(i)=(X(i)+shift)*scale.

Parameters:
shift - constants used to add to all values
scale - constant used to scale after shifting.
Returns:
P0I after shift and scale.

oper

public P0I oper(P0I P0I,
                java.lang.String title,
                java.lang.String what)
Operations on P0I containers: add, subtract, multiply, divide. Keep the same graphical attributes

Parameters:
P0I - Input P0I container for operation
title - New title
what - String representing the operation: "+" add a P0I container to the original; "-" subtract a P0I from the original; "*" multiply; "/" divide by P0I
Returns:
original P0I after the operation.

mean

public double mean()
Returns the mean value.

Returns:
Mean value

kurtosis

public double kurtosis()
Returns the kurtosis. Run getStat() to update or evaluate the sampling

Returns:
kurtosis

median

public double median()
Returns the median. First run getStat() to evaluate or update.

Returns:
median

getStat

public java.lang.String getStat()
Print all statistics of the container

Returns:
string representing all statistics

moment

public double moment(int k,
                     java.lang.Integer c)
Returns the moment of k-th order with value c, which is Sum( (x[i]-c)k ) / size(). First run getStat() for evaluation

Parameters:
k - k-th order
c - c
Returns:
moment

standardError

public double standardError()
Returns the sample standard error, which is Math.sqrt(variance() / size()). Run getStat(0) before.

Returns:
sample standard error

skew

public double skew()
Returns the skew, which is moment(3,mean()) / standardDeviation() Run getStat(0 for evaluation

Returns:
skewness

variance

public double variance()
Returns the variance. Run getStat() first to update or evaluate

Returns:
variance

stddeviation

public double stddeviation()
Returns the standard deviation (square root of variance)

Returns:
variance

covariance

public double covariance(P0I P0I)
Returns the covariance

Parameters:
P0I - P0I object for covariance calculations
Returns:
covariance value

correlation

public double correlation(P0I P0I)
Returns the correlation coefficient. Values between 0 (no correlation) and 1 (full linear correlation)

Parameters:
P0I - P0I object for correlation calculation.
Returns:
correlation coefficient.

clear

public void clear()
Clear the container


func

public P0I func(F1D f1d)
Transform P0I array to array with values given by a function. The function may have up to 3 independent variables in it (x,y,z).

This class is not fool proof. If the answer is wrong then use the parenthesis to force the order of evaluation. The most likely place this will be needed is in the use of the power command. The exponent is not evaluated correctly if it begins with a unary operator.

List of commands

Parameters:
f1d - function for transformation
Returns:
transformed P0I

func

public P0I func(java.lang.String title,
                F1D f1d)
Make transformation of P0I using a function.

Parameters:
title - new title
f1d - function for transformation
Returns:
transformed P0I

sort

public P0I sort()
Sort into ascending order

Returns:
same P0I but with sorted numbers

reverse

public P0I reverse()
Reverse the order of elements

Returns:
same P0I but with reverse order

toTable

public void toTable()
Print the P0I container to a Table in a separate Frame. The numbers are formatted to scientific format. One can sort and search the data in this table (but not modify)


toTable

public void toTable(boolean format)
Print the P0I array to a Table in a separate Frame. One can sort and search the data in this table (but not modify)

Parameters:
format - if false, numbers will not be formatted to scientific format ##.#####E00

main

public static void main(java.lang.String[] args)
Test

Parameters:
args -

doc

public void doc()
Show online documentation.



jHepWork 2.1 (C) S.Chekanov