/*
 This is a proprietary part of DataMelt package.
 License: the Creative Commons Attribution-Share Alike License; either version 3.0 of the License, 
 or any later version.
 http://creativecommons.org/licenses/by-sa/3.0/
 

Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgment to the author, Dr Sergei Chekanov appears in all copies and associated documentation or publications.

Redistributions of the source code, or parts of the source codes, must retain the copyright notice, this list of conditions and the following disclaimer (all at the top of each source code) and requires the written permission of Sergei Chekanov

Redistribution in binary form of all or parts of a class must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution and requires the written permission of Sergei Chekanov

Details about license agreement or commercial use are: http://jwork.org/jhepwork/license.php */ package jhpro.stat; import jhplot.H1D; import jhplot.P1D; /** * A convenient class to keep data with error for an internal representation. * Can be filled from histograms or P1D. * * @author Sergei Chekanov * */ public class DataKeeper { private double[] values; private double[] errors; private int size; private String title; public DataKeeper(int size) { this.size = size; values = new double[size]; errors = new double[size]; title = "None"; } /** * Initialize from a P1D * * @param p1d * input P1D */ public DataKeeper(P1D p1d) { size = p1d.size(); values = new double[size]; errors = new double[size]; for (int i = 0; i < size; i++) values[i] = p1d.getY(i); for (int i = 0; i < size; i++) errors[i] = p1d.getYupper(i); title = p1d.getTitle(); } /** * Initialize from a histogram * * @param h1d */ public DataKeeper(H1D h1d) { size = h1d.getBins(); values = new double[size]; errors = new double[size]; for (int i = 0; i < h1d.getBins(); i++) values[i] = h1d.binHeight(i); for (int i = 0; i < h1d.getBins(); i++) errors[i] = h1d.binError(i); title = h1d.getTitle(); } public void setTitle(String title) { this.title = title; } public String getTitle() { return title; } public void setErrors(double[] errors) { this.errors = errors; } public void setValues(double[] values) { this.values = values; } /** * Scale values and errors by a factor * @param index index of the value * @param factor factor to scale */ public void scale(int index, double factor) { values[index] = factor* values[index]; errors[index] = factor* errors[index]; } /** * Scale all values and errors by a factor * @param factor factor to scale */ public void scale(double factor) { for (int i=0; i

Ads help maintain this website.