/** * Adds the values in the array <tt>vals</tt> to the end of the * list, in order. * * @param vals an <code>double[]</code> value */ public void add(double[] vals) { add(vals, 0, vals.length); }
/** * Creates a new <code>TDoubleArrayList</code> instance whose * capacity is the greater of the length of <tt>values</tt> and * DEFAULT_CAPACITY and whose initial contents are the specified * values. * * @param values an <code>double[]</code> value */ public TDoubleArrayList(double[] values) { this(Math.max(values.length, DEFAULT_CAPACITY)); add(values); }
public EvolutionReguliereTFixe(final double[] _t) { super(); t_ = _t; val_.ensureCapacity(_t.length); val_.add(new double[t_.length]); }
protected void decodeResults(String inputFile, IIndex index, short catID, ClassificationResult res) throws Exception { BufferedReader in = new BufferedReader(new FileReader(inputFile), 4096); String line = in.readLine(); assert (line != null); assert (!line.equals("")); double score = Double.parseDouble(line); res.categoryID.add(catID); res.score.add(score); in.close(); }
protected void decodeResults(String inputFile, IIndex index, short catID, ClassificationResult res) throws Exception { BufferedReader in = new BufferedReader(new FileReader(inputFile), 4096); String line = in.readLine(); assert (line != null); assert (!line.equals("")); double score = Double.parseDouble(line); res.categoryID.add(catID); res.score.add(score); in.close(); }
private final static double[] decodeArrayDouble(final String _tab) { // System.err.println("appel de decodeArrayDouble"); final StringTokenizer stk = new StringTokenizer(_tab," "); TDoubleArrayList liste = new TDoubleArrayList(_tab.length()/5); while(stk.hasMoreElements()) { liste.add(Double.parseDouble(stk.nextToken())); } return liste.toNativeArray(); }
private final static double[] decodeArrayDouble(final String _tab) { // System.err.println("appel de decodeArrayDouble"); final StringTokenizer stk = new StringTokenizer(_tab," "); TDoubleArrayList liste = new TDoubleArrayList(_tab.length()/5); while(stk.hasMoreElements()) { liste.add(Double.parseDouble(stk.nextToken())); } return liste.toNativeArray(); }
protected void initWith(final EvolutionReguliereAbstract _evol) { if (_evol == null) { return; } used_ = _evol.used_; nom_ = _evol.nom_; unite_ = _evol.unite_; xVal_ = _evol.xVal_; yVal_ = _evol.yVal_; listener_ = _evol.listener_; val_.clear(); val_.add(_evol.val_.toNativeArray()); }
public static double[] parseStringDouble(final String _s, final String _sepChar) { if ((_s == null) || (_sepChar == null)) { return null; } final List l = (parseStringList(_s, _sepChar)); final TDoubleArrayList res = new TDoubleArrayList(); for (int i = 0; i < l.size(); i++) { try { res.add(CtuluDoubleParser.parseValue((String) l.get(i))); } catch (final NumberFormatException _evt) { FuLog.error(_evt); } } return res.toNativeArray(); }
private SparseMatrixn make3dMatrix () { int[] sizes = new int[]{2, 3, 4}; TIntArrayList idxs = new TIntArrayList (); TDoubleArrayList vals = new TDoubleArrayList (); for (int i = 0; i < 24; i++) { if (i % 3 != 0) { idxs.add (i); vals.add (2.0 * i); } } SparseMatrixn a = new SparseMatrixn (sizes, idxs.toNativeArray (), vals.toNativeArray ()); return a; }
private SparseMatrixn make3dMatrix () { int[] sizes = new int[]{2, 3, 4}; TIntArrayList idxs = new TIntArrayList (); TDoubleArrayList vals = new TDoubleArrayList (); for (int i = 0; i < 24; i++) { if (i % 3 != 0) { idxs.add (i); vals.add (2.0 * i); } } SparseMatrixn a = new SparseMatrixn (sizes, idxs.toNativeArray (), vals.toNativeArray ()); return a; }
private SparseMatrixn make3dMatrix () { int[] sizes = new int[]{2, 3, 4}; TIntArrayList idxs = new TIntArrayList (); TDoubleArrayList vals = new TDoubleArrayList (); for (int i = 0; i < 24; i++) { if (i % 3 != 0) { idxs.add (i); vals.add (2.0 * i); } } SparseMatrixn a = new SparseMatrixn (sizes, idxs.toNativeArray (), vals.toNativeArray ()); return a; }
public void testSample () { Variable var = new Variable (Variable.CONTINUOUS); Randoms r = new Randoms (2343); Factor f = new UniNormalFactor (var, -1.0, 2.0); TDoubleArrayList lst = new TDoubleArrayList (); for (int i = 0; i < 10000; i++) { Assignment assn = f.sample (r); lst.add (assn.getDouble (var)); } double[] vals = lst.toNativeArray (); double mean = MatrixOps.mean (vals); double std = MatrixOps.stddev (vals); assertEquals (-1.0, mean, 0.025); assertEquals (Math.sqrt(2.0), std, 0.01); }
public void testSample2 () { Variable var = new Variable (Variable.CONTINUOUS); Randoms r = new Randoms (2343); Factor f = new BetaFactor (var, 0.7, 0.5, 3.0, 8.0); TDoubleArrayList lst = new TDoubleArrayList (); for (int i = 0; i < 100000; i++) { Assignment assn = f.sample (r); lst.add (assn.getDouble (var)); } double[] vals = lst.toNativeArray (); double mean = MatrixOps.mean (vals); assertEquals (5.92, mean, 0.01); }
public void testSample () { Variable var = new Variable (Variable.CONTINUOUS); Randoms r = new Randoms (2343); Factor f = new UniformFactor (var, -1.0, 1.5); TDoubleArrayList lst = new TDoubleArrayList (); for (int i = 0; i < 10000; i++) { Assignment assn = f.sample (r); lst.add (assn.getDouble (var)); } double[] vals = lst.toNativeArray (); double mean = MatrixOps.mean (vals); assertEquals (0.25, mean, 0.01); }
public void testSample () { Variable var = new Variable (Variable.CONTINUOUS); Randoms r = new Randoms (2343); Factor f = new BetaFactor (var, 0.7, 0.5); TDoubleArrayList lst = new TDoubleArrayList (); for (int i = 0; i < 100000; i++) { Assignment assn = f.sample (r); lst.add (assn.getDouble (var)); } double[] vals = lst.toNativeArray (); double mean = MatrixOps.mean (vals); assertEquals (0.7 / (0.5 + 0.7), mean, 0.01); }
public void testSample () { Variable var = new Variable (Variable.CONTINUOUS); Randoms r = new Randoms (2343); Factor f = new BetaFactor (var, 0.7, 0.5); TDoubleArrayList lst = new TDoubleArrayList (); for (int i = 0; i < 100000; i++) { Assignment assn = f.sample (r); lst.add (assn.getDouble (var)); } double[] vals = lst.toNativeArray (); double mean = MatrixOps.mean (vals); assertEquals (0.7 / (0.5 + 0.7), mean, 0.01); }
public void testSample2 () { Variable var = new Variable (Variable.CONTINUOUS); Randoms r = new Randoms (2343); Factor f = new BetaFactor (var, 0.7, 0.5, 3.0, 8.0); TDoubleArrayList lst = new TDoubleArrayList (); for (int i = 0; i < 100000; i++) { Assignment assn = f.sample (r); lst.add (assn.getDouble (var)); } double[] vals = lst.toNativeArray (); double mean = MatrixOps.mean (vals); assertEquals (5.92, mean, 0.01); }
public void testSample () { Variable var = new Variable (Variable.CONTINUOUS); Randoms r = new Randoms (2343); Factor f = new UniformFactor (var, -1.0, 1.5); TDoubleArrayList lst = new TDoubleArrayList (); for (int i = 0; i < 10000; i++) { Assignment assn = f.sample (r); lst.add (assn.getDouble (var)); } double[] vals = lst.toNativeArray (); double mean = MatrixOps.mean (vals); assertEquals (0.25, mean, 0.01); }