Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Incremented version.
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLautenschlager committed Feb 26, 2016
1 parent 435395e commit 21867df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 59 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ allprojects {
}
}

version '0.3'
version '0.4'

group 'de.qaware.chronix'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import de.qaware.chronix.dt.IntList;
import de.qaware.chronix.dt.LongList;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -73,18 +74,10 @@ public void setDimensions(IntList newLabels) {
labels.addAll(newLabels);
}

public double getMeasurement(int pointIndex, int valueIndex) {
return values.get(pointIndex)[valueIndex];
}

public double[] getMeasurementVector(int pointIndex) {
return values.get(pointIndex);
}

public void setMeasurement(int pointIndex, int valueIndex, double newValue) {
values.get(pointIndex)[valueIndex] = newValue;
}

public void add(long time, double[] values) {
if (labels.size() != values.length + 1) // labels include a label for time
throw new InternalError("ERROR: The TSValues: " + values + " contains the wrong number of values. " + "expected: " + labels.size() + ", " + "found: " + values.length);
Expand All @@ -96,56 +89,12 @@ public void add(long time, double[] values) {
this.values.add(values);
}


public void normalize() {
// Calculate the mean of each FD.
final double[] mean = new double[this.numOfDimensions()];
for (int col = 0; col < numOfDimensions(); col++) {
double currentSum = 0.0;
for (int row = 0; row < this.size(); row++)
currentSum += this.getMeasurement(row, col);

mean[col] = currentSum / this.size();
} // end for loop

// Calculate the standard deviation of each FD.
final double[] stdDev = new double[numOfDimensions()];
for (int col = 0; col < numOfDimensions(); col++) {
double variance = 0.0;
for (int row = 0; row < this.size(); row++)
variance += Math.abs(getMeasurement(row, col) - mean[col]);

stdDev[col] = variance / this.size();
} // end for loop


// Normalize the values in the data using the mean and standard deviation
// for each FD. => Xrc = (Xrc-Mc)/SDc
for (int row = 0; row < this.size(); row++) {
for (int col = 0; col < numOfDimensions(); col++) {
// Normalize data point.
if (stdDev[col] == 0.0) // prevent divide by zero errors
setMeasurement(row, col, 0.0); // stdDev is zero means all pts identical
else // typical case
setMeasurement(row, col, (getMeasurement(row, col) - mean[col]) / stdDev[col]);
} // end for loop
} // end for loop
} // end normalize();


@Override
public String toString() {
final StringBuilder outStr = new StringBuilder();

// Write the data for each row.
for (int r = 0; r < times.size(); r++) {
// The rest of the value on the row.
final double[] values = this.values.get(r);
for (int c = 0; c < values.length; c++)
outStr.append(values[c]);

if (r < times.size() - 1)
outStr.append("\n");
}
return outStr.toString();
return new ToStringBuilder(this)
.append("labels", labels)
.append("times", times)
.append("values", values)
.toString();
}
}

0 comments on commit 21867df

Please sign in to comment.