package jas2.hist.test;
import java.util.Observable;
import jas2.hist.*;
import jas2.util.xml.*;
public class Gauss extends Observable implements Rebinnable1DHistogramData, HasStyle, HasStatistics, HasXMLRepresentation
{
public Gauss()
{
this("Gaussian",1000,1,0,0);
}
public void writeAsXML(XMLWriter pw)
{
pw.println("");
pw.println("");
pw.println("");
pw.println("");
pw.println("");
pw.println("");
pw.println(" ");
}
public Gauss(String name, int entries,double max,double offX,double offY)
{
if (entries > MAXSIZE) throw new IllegalArgumentException("Gauss: Size too big");
m_tuple = new double[MAXSIZE];
m_entries = entries;
m_min = offX;
m_max = offX + max;
m_offset = offY;
m_name = name;
for (int j=0; j MAXSIZE) throw new IllegalArgumentException("Gauss: Size too big");
m_entries = newSize;
synchronized (this) { notifyObservers(new HistogramUpdate(HistogramUpdate.DATA_UPDATE,true)); }
}
public double getData(int i)
{
return m_tuple[i];
}
public Statistics getStatistics()
{
return stats;
}
double m_tuple[];
int m_entries;
double m_max;
double m_min;
double m_offset;
String m_name;
protected final static int MAXSIZE = 10000;
private JASHist1DHistogramStyle style;
private Statistics stats = new GaussStatistics();
private Statistics paulstats = new PaulStatistics();
public void setStats() {
stats = paulstats;
}
private class GaussStatistics implements Statistics
{
public String[] getStatisticNames()
{
return statNames;
}
public double getStatistic(String name)
{
if (name == statNames[0]) return m_entries;
if (name == statNames[1]) return (m_max + m_min)/2;
if (name == statNames[2]) return (m_max - m_min);
return 0;
}
}
public class PaulStatistics implements Statistics
{
public String[] getStatisticNames()
{
return statNames2;
}
public double getStatistic(String name)
{
if (name == statNames2[0]) return m_entries;
if (name == statNames2[1]) return (m_max + m_min)/2;
if (name == statNames2[2]) return (m_max - m_min);
if (name == statNames2[3]) return (m_entries*10);
return 0;
}
}
private static final String[] statNames = {"Entries","Mean","RMS"};
private static final String[] statNames2 = {"Entries","Mean","RMS", "10Entries"};
}
Ads help maintain this website.