1 package org.simantics.history.test;
3 import org.simantics.databoard.Bindings;
4 import org.simantics.databoard.serialization.Serializer;
5 import org.simantics.history.util.ClassDistribution;
7 /*******************************************************************************
8 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
9 * All rights reserved. This program and the accompanying materials
10 * are made available under the terms of the Eclipse Public License v1.0
11 * which accompanies this distribution, and is available at
12 * http://www.eclipse.org/legal/epl-v10.html
15 * VTT Technical Research Centre of Finland - initial API and implementation
16 *******************************************************************************/
20 public class TestClassDistribution {
22 public static void main(String[] args) throws Exception {
24 ClassDistribution ib = new ClassDistribution(1.1);
26 System.out.println( ib.getClassIndex(0.001) );
27 System.out.println( ib.getClassIndex(0.01) );
28 System.out.println( ib.getClassIndex(0.1) );
29 System.out.println( ib.getClassIndex(1) );
30 System.out.println( ib.getClassIndex(10) );
31 System.out.println( ib.getClassIndex(100) );
34 ib.addValue(0.000015);
41 // ib.addInterval(10);
45 System.out.println(ib);
47 System.out.println("Largest Class = "+ ib.getClassAvg( ib.getLargestClassIndex() ) );
48 System.out.println("Median = "+ ib.getMedian() );
50 System.out.println( Math.log(2) );
51 System.out.println( Math.sqrt(0.5) );
53 System.out.println("Test Serializer");
54 Serializer s = Bindings.getSerializer( Bindings.getBinding( ClassDistribution.class ) );
55 byte[] data = s.serialize( ib );
56 ib = (ClassDistribution) s.deserialize(data);
59 System.out.println("Deserialized:");
60 System.out.println(ib);
61 System.out.println("Largest Class = "+ ib.getClassAvg( ib.getLargestClassIndex() ) );
62 System.out.println("Median = "+ ib.getMedian() );