SSJ  3.3.1
Stochastic Simulation in Java
Static Public Member Functions | List of all members
Misc Class Reference

This class provides miscellaneous functions that are hard to classify. More...

Static Public Member Functions

static double quickSelect (double[] A, int n, int k)
 Returns the \(k^{th}\) smallest item of the array \(A\) of size \(n\). More...
 
static int quickSelect (int[] A, int n, int k)
 Returns the \(k^{th}\) smallest item of the array \(A\) of size \(n\). More...
 
static double getMedian (double[] A, int n)
 Returns the median of the first \(n\) elements of array \(A\). More...
 
static double getMedian (int[] A, int n)
 Returns the median of the first \(n\) elements of array \(A\). More...
 
static int getTimeInterval (double[] times, int start, int end, double t)
 Returns the index of the time interval corresponding to time t. More...
 
static void interpol (int n, double[] X, double[] Y, double[] C)
 Computes the Newton interpolating polynomial. More...
 
static double evalPoly (int n, double[] X, double[] C, double z)
 Given \(n\), \(X\) and \(C\) as described in interpol(n, X, Y, C), this function returns the value of the interpolating polynomial \(P(z)\) evaluated at \(z\) (see eq. More...
 
static double evalPoly (double[] C, int n, double x)
 Evaluates the polynomial \(P(x)\) of degree \(n\) with coefficients \(c_j =\) C[j] at \(x\): More...
 

Detailed Description

This class provides miscellaneous functions that are hard to classify.

Some may be moved to another class in the future.

Member Function Documentation

◆ evalPoly() [1/2]

static double evalPoly ( int  n,
double []  X,
double []  C,
double  z 
)
static

Given \(n\), \(X\) and \(C\) as described in interpol(n, X, Y, C), this function returns the value of the interpolating polynomial \(P(z)\) evaluated at \(z\) (see eq.

eq.newton.interpol ).

Parameters
ndegree of the interpolating polynomial
X\(x\)-coordinates of points
CCoefficients of the interpolating polynomial
zargument where polynomial is evaluated
Returns
Value of the interpolating polynomial \(P(z)\)

◆ evalPoly() [2/2]

static double evalPoly ( double []  C,
int  n,
double  x 
)
static

Evaluates the polynomial \(P(x)\) of degree \(n\) with coefficients \(c_j =\) C[j] at \(x\):

\[ \qquad P(x) = c_0 + c_1 x + c_2 x^2 + \cdots+ c_n x^n \tag{eq.horner} \]

Parameters
CCoefficients of the polynomial
ndegree of the polynomial
xargument where polynomial is evaluated
Returns
Value of the polynomial \(P(x)\)

◆ getMedian() [1/2]

static double getMedian ( double []  A,
int  n 
)
static

Returns the median of the first \(n\) elements of array \(A\).

Parameters
Athe array
nthe number of used elements
Returns
the median of \(A\)

◆ getMedian() [2/2]

static double getMedian ( int []  A,
int  n 
)
static

Returns the median of the first \(n\) elements of array \(A\).

Parameters
Athe array
nthe number of used elements
Returns
the median of \(A\)

◆ getTimeInterval()

static int getTimeInterval ( double []  times,
int  start,
int  end,
double  t 
)
static

Returns the index of the time interval corresponding to time t.

Let \(t_0\le\cdots\le t_n\) be simulation times stored in a subset of times. This method uses binary search to determine the smallest value \(i\) for which \(t_i\le t < t_{i+1}\), and returns \(i\). The value of \(t_i\) is stored in times[start+i] whereas \(n\) is defined as end - start. If \(t<t_0\), this returns \(-1\). If \(t\ge t_n\), this returns \(n\). Otherwise, the returned value is greater than or equal to 0, and smaller than or equal to \(n-1\). start and end are only used to set lower and upper limits of the search in the times array; the index space of the returned value always starts at 0. Note that if the elements of times with indices start, …, end are not sorted in non-decreasing order, the behavior of this method is undefined.

Parameters
timesan array of simulation times.
startthe first index in the array to consider.
endthe last index (inclusive) in the array to consider.
tthe queried simulation time.
Returns
the index of the interval.
Exceptions
NullPointerExceptionif times is null.
IllegalArgumentExceptionif start is negative, or if end is smaller than start.
ArrayIndexOutOfBoundsExceptionif start + end is greater than or equal to the length of times.

◆ interpol()

static void interpol ( int  n,
double []  X,
double []  Y,
double []  C 
)
static

Computes the Newton interpolating polynomial.

Given the \(n+1\) real distinct points \((x_0, y_0),\) \((x_1, y_1),…, (x_n, y_n)\), with X[i] \(= x_i\), Y[i] \(= y_i\), this function computes the \(n+1\) coefficients C[i] \(= c_i\) of the Newton interpolating polynomial \(P(x)\) of degree \(n\) passing through these points, i.e. such that \(y_i= P(x_i)\), given by

\[ \qquad P(x) = c_0 + c_1(x-x_0) + c_2(x-x_0)(x-x_1) + \cdots+ c_n(x-x_0)(x-x_1) \cdots(x-x_{n-1}). \tag{eq.newton.interpol} \]

Parameters
ndegree of the interpolating polynomial
X\(x\)-coordinates of points
Y\(y\)-coordinates of points
CCoefficients of the interpolating polynomial

◆ quickSelect() [1/2]

static double quickSelect ( double []  A,
int  n,
int  k 
)
static

Returns the \(k^{th}\) smallest item of the array \(A\) of size \(n\).

Array \(A\) is unchanged by the method. Restriction: \(1 \le k \le n\).

Parameters
Athe array which contain the items
nthe number of items in the array
kthe index of the smallest item
Returns
the kth smallest item of the array \(A\)

◆ quickSelect() [2/2]

static int quickSelect ( int []  A,
int  n,
int  k 
)
static

Returns the \(k^{th}\) smallest item of the array \(A\) of size \(n\).

Array \(A\) is unchanged by the method. Restriction: \(1 \le k \le n\).

Parameters
Athe array which contain the items
nthe number of items in the array
kthe index of the smallest item
Returns
the kth smallest item of the array \(A\)

The documentation for this class was generated from the following file: