Skip to content

Commit

Permalink
Make DiscreteQuantileMethod abstract methods protected
Browse files Browse the repository at this point in the history
  • Loading branch information
skitini committed Jul 10, 2024
1 parent 352723d commit eccbe2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,29 @@ protected QuantileResult expectedShortfall(double level, DoubleArray sample) {
//-------------------------------------------------------------------------

/**
* Internal method computing the index for a give quantile multiply by sample size.
* Computes the index for a given quantile multiplied by sample size.
* <p>
* The quantile size is given by quantile * sample size.
*
* @param quantileSize the quantile size
* @return the index in the sample
*/
abstract int index(double quantileSize);
protected abstract int index(double quantileSize);

/**
* Internal method returning the sample size correction for the specific implementation.
* Returns the sample size correction for the specific implementation.
*
* @param sampleSize the sample size
* @return the correction
*/
abstract int sampleCorrection(int sampleSize);
protected abstract int sampleCorrection(int sampleSize);

/**
* Shift added to/subtracted from index during intermediate steps in the expected shortfall computation.
*
* @return the index shift
*/
abstract double indexShift();
protected abstract double indexShift();

/**
* Generate an index of doubles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public final class IndexAboveQuantileMethod
public static final IndexAboveQuantileMethod DEFAULT = new IndexAboveQuantileMethod();

@Override
int index(double quantileSize) {
protected int index(double quantileSize) {
return (int) Math.ceil(quantileSize);
}

@Override
int sampleCorrection(int sampleSize) {
protected int sampleCorrection(int sampleSize) {
return sampleSize;
}

@Override
double indexShift() {
protected double indexShift() {
return 0d;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public final class NearestIndexQuantileMethod
public static final NearestIndexQuantileMethod DEFAULT = new NearestIndexQuantileMethod();

@Override
int index(double quantileSize) {
protected int index(double quantileSize) {
return (int) Math.round(quantileSize);
}

@Override
int sampleCorrection(int sampleSize) {
protected int sampleCorrection(int sampleSize) {
return sampleSize;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public final class SamplePlusOneNearestIndexQuantileMethod
public static final SamplePlusOneNearestIndexQuantileMethod DEFAULT = new SamplePlusOneNearestIndexQuantileMethod();

@Override
int index(double quantileSize) {
protected int index(double quantileSize) {
return (int) Math.round(quantileSize);
}

@Override
int sampleCorrection(int sampleSize) {
protected int sampleCorrection(int sampleSize) {
return sampleSize + 1;
}

Expand Down

0 comments on commit eccbe2d

Please sign in to comment.