当前位置: 首页>>代码示例>>Java>>正文


Java DoubleArrayList类代码示例

本文整理汇总了Java中com.carrotsearch.hppc.DoubleArrayList的典型用法代码示例。如果您正苦于以下问题:Java DoubleArrayList类的具体用法?Java DoubleArrayList怎么用?Java DoubleArrayList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DoubleArrayList类属于com.carrotsearch.hppc包,在下文中一共展示了DoubleArrayList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readSampleSubsequence

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
public static TimeSeries readSampleSubsequence(File dataset) throws IOException {
  try (BufferedReader br = new BufferedReader(new FileReader(dataset))) {
    DoubleArrayList data = new DoubleArrayList();
    String line = null;
    while ((line = br.readLine()) != null) {
      line = line.trim();
      String[] values = line.split("[ \\t]");
      if (values.length > 0) {
        for (String value : values) {
          try {
            value = value.trim();
            if (isNonEmptyColumn(value)) {
              data.add(Double.parseDouble(value));
            }
          } catch (NumberFormatException nfe) {
            // Parse-Exception ignored
          }
        }
      }
    }
    return new TimeSeries(data.toArray());
  }
}
 
开发者ID:patrickzib,项目名称:SFA,代码行数:24,代码来源:TimeSeriesLoader.java

示例2: readSamplesQuerySeries

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
public static TimeSeries[] readSamplesQuerySeries(File dataset) throws IOException {
  List<TimeSeries> samples = new ArrayList<>();
  try (BufferedReader br = new BufferedReader(new FileReader(dataset))) {
    String line = null;
    while ((line = br.readLine()) != null) {
      DoubleArrayList data = new DoubleArrayList();
      line = line.trim();
      String[] values = line.split("[ \\t]");
      if (values.length > 0) {
        for (String value : values) {
          try {
            value = value.trim();
            if (isNonEmptyColumn(value)) {
              data.add(Double.parseDouble(value));
            }
          } catch (NumberFormatException nfe) {
            // Parse-Exception ignored
          }
        }
        samples.add(new TimeSeries(data.toArray()));
      }
    }
  }
  return samples.toArray(new TimeSeries[]{});
}
 
开发者ID:patrickzib,项目名称:SFA,代码行数:26,代码来源:TimeSeriesLoader.java

示例3: addAverages

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
protected void addAverages(EvaluationResultContainer subTaskResults, EvaluationResultContainer results) {
    Map<String, DoubleArrayList> mapping = createNameValueMapping(subTaskResults.getResults());
    DoubleArrayList values;
    int subTaskCount = subTaskResults.getResults().size();
    double sum;
    for (String name : mapping.keySet()) {
        values = mapping.get(name);
        if (values.elementsCount == subTaskCount) {
            sum = 0;
            for (int i = 0; i < values.elementsCount; ++i) {
                sum += values.buffer[i];
            }
            results.addResult(new DoubleEvaluationResult(name, sum / subTaskCount));
        }
    }
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:17,代码来源:SubTaskAverageCalculator.java

示例4: computeCPFs

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
private void computeCPFs ()
{
  isFactorsAdded = true;
  DoubleArrayList residTmp = new DoubleArrayList ();
  for (Iterator it = cliques.iterator(); it.hasNext();) {
    UnrolledVarSet clique = (UnrolledVarSet) it.next();
    AbstractTableFactor ptl = clique.tmpl.computeFactor (clique);
    addFactorInternal (clique, ptl);
    clique.tmpl.modifyPotential (this, clique, ptl);
    uvsMap.put (ptl, clique);
    
    // sigh
    LogTableFactor unif = new LogTableFactor (clique);
    residTmp.add (Factors.distLinf (unif, ptl));
  }

  lastResids = residTmp.toArray();
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:19,代码来源:ACRF.java

示例5: readSparseVector

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
private SparseVector readSparseVector (String str, Alphabet dict) throws IOException
{
  IntArrayList idxs = new IntArrayList ();
  DoubleArrayList vals = new DoubleArrayList ();
  String[] lines = str.split ("\n");
  for (int li = 0; li < lines.length; li++) {
    String line = lines[li];
    if (Pattern.matches ("^\\s*$", line)) continue;

    String[] fields = line.split ("\t");
    int idx;
    if (dict != null) {
      idx = dict.lookupIndex (fields[0]);
    } else {
      idx = Integer.parseInt (fields[0]);
    }

    double val = Double.parseDouble (fields[1]);
    idxs.add (idx);
    vals.add (val);
  }
  return new SparseVector (idxs.toArray (), vals.toArray ());
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:24,代码来源:ACRF.java

示例6: ignoretestSample

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
public void ignoretestSample ()
  {
    Variable v1 = new Variable (Variable.CONTINUOUS);
    Variable v2 = new Variable (Variable.CONTINUOUS);
    Randoms r = new Randoms (2343);

    Vector mu = new DenseVector (new double[] { 1.0, 2.0 });
    Matrix var = new DenseMatrix (new double[][] {{ 0.5, 2.0 }, { 0, 1 }});
//    Matrix var = new DenseMatrix (new double[][] {{ 0.5, 2.0 }, { 2.0, 0.75 }});

    VarSet vars = new HashVarSet (new Variable[] { v1, v2 });
    Factor f = new NormalFactor (vars, mu, var);

    DoubleArrayList v1lst = new DoubleArrayList ();
    DoubleArrayList v2lst = new DoubleArrayList ();
    for (int i = 0; i < 100000; i++) {
      Assignment assn = f.sample (r);
      v1lst.add (assn.getDouble (v1));
      v2lst.add (assn.getDouble (v2));
    }

    checkMeanStd (v1lst, 1.0, Math.sqrt (1/0.5));
    checkMeanStd (v2lst, 2.0, Math.sqrt (1/0.75));
  }
 
开发者ID:cmoen,项目名称:mallet,代码行数:25,代码来源:TestNormalFactor.java

示例7: ignoretestSample

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
public void ignoretestSample ()
{
  Variable var = new Variable (Variable.CONTINUOUS);
  Randoms r = new Randoms (2343);
  Factor f = new UniNormalFactor (var, -1.0, 2.0);
  DoubleArrayList lst = new DoubleArrayList ();
  for (int i = 0; i < 10000; i++) {
    Assignment assn = f.sample (r);
    lst.add (assn.getDouble (var));
  }

  double[] vals = lst.toArray ();
  double mean = MatrixOps.mean (vals);
  double std = MatrixOps.stddev (vals);
  assertEquals (-1.0, mean, 0.025);
  assertEquals (Math.sqrt(2.0), std, 0.01);
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:18,代码来源:TestUniNormalFactor.java

示例8: createDirectedModel

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
private DirectedModel createDirectedModel ()
{
  int NUM_OUTCOMES = 2;
  cc.mallet.util.Randoms random = new cc.mallet.util.Randoms (13413);

  Dirichlet dirichlet = new Dirichlet (NUM_OUTCOMES, 1.0);
  double[] pA = dirichlet.randomVector (random);
  double[] pB = dirichlet.randomVector (random);

  DoubleArrayList pC = new DoubleArrayList (NUM_OUTCOMES * NUM_OUTCOMES * NUM_OUTCOMES);
  for (int i = 0; i < (NUM_OUTCOMES * NUM_OUTCOMES); i++) {
    pC.add (dirichlet.randomVector (random));
  }

  Variable[] vars = new Variable[] { new Variable (NUM_OUTCOMES), new Variable (NUM_OUTCOMES),
          new Variable (NUM_OUTCOMES) };
  DirectedModel mdl = new DirectedModel ();
  mdl.addFactor (new CPT (new TableFactor (vars[0], pA), vars[0]));
  mdl.addFactor (new CPT (new TableFactor (vars[1], pB), vars[1]));
  mdl.addFactor (new CPT (new TableFactor (vars, pC.toArray ()), vars[2]));

  return mdl;
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:24,代码来源:TestInference.java

示例9: make3dMatrix

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
private SparseMatrixn make3dMatrix ()
{
  int[] sizes = new int[]{2, 3, 4};
  IntArrayList idxs = new IntArrayList ();
  DoubleArrayList vals = new DoubleArrayList ();

  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.toArray (), vals.toArray ());
  return a;
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:17,代码来源:TestSparseMatrixn.java

示例10: summarize

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
@Override
public double summarize(double[] values, double[] weights) {
    if (values.length == 0) {
        throw new IllegalArgumentException(
                "The given array has to have at least one element to determine the modus.");
    }
    DoubleArrayList weightedValues = new DoubleArrayList(values.length);
    for (int i = 0; i < values.length; ++i) {
        if (!Double.isNaN(values[i])) {
            weightedValues.add(weights[i] * values[i]);
        }
    }
    if (weightedValues.size() == 0) {
        return 0;
    }
    double weightedValuesAsArray[] = weightedValues.toArray();
    Arrays.sort(weightedValuesAsArray);
    if ((weightedValuesAsArray.length & 1) > 0) {
        return weightedValuesAsArray[weightedValuesAsArray.length / 2];
    } else {
        return (weightedValuesAsArray[weightedValuesAsArray.length / 2] + weightedValuesAsArray[(weightedValuesAsArray.length / 2) - 1]) / 2.0;
    }
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:24,代码来源:Median.java

示例11: writeArray

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
private void writeArray(DoubleArrayList numbers, File file) throws IOException {
  final ByteSink sink = GZIPByteSink.gzipCompress(Files.asByteSink(file));
  final PrintWriter out = new PrintWriter(sink.asCharSink(Charsets.UTF_8).openBufferedStream());
  for (final DoubleCursor cursor : numbers) {
    out.println(cursor.value);
  }
  out.close();
  ;
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:10,代码来源:EAScoringObserver.java

示例12: createNameValueMapping

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
private Map<String, DoubleArrayList> createNameValueMapping(List<EvaluationResult> results) {
    Map<String, DoubleArrayList> mapping = new HashMap<String, DoubleArrayList>();
    for (EvaluationResult result : results) {
        addToMapping(mapping, result);
    }
    return mapping;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:8,代码来源:SubTaskAverageCalculator.java

示例13: PairedIntDoubleArrayListPermutationProxy

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
private PairedIntDoubleArrayListPermutationProxy(final IntArrayList intArr,
    final DoubleArrayList doubleArr,
    final int startIdxInclusive, final int endIdxExclusive) {
  checkArgument(startIdxInclusive >= 0);
  checkArgument(startIdxInclusive <= endIdxExclusive);
  checkArgument(endIdxExclusive <= intArr.size());
  checkArgument(intArr.size() == doubleArr.size());
  this.intArr = checkNotNull(intArr);
  this.doubleArr = checkNotNull(doubleArr);
  this.bufferFilled = false;
  this.startIdx = startIdxInclusive;
  this.length = endIdxExclusive - startIdxInclusive;
}
 
开发者ID:BBN-E,项目名称:bue-common-open,代码行数:14,代码来源:PairedIntDoubleArrayListPermutationProxy.java

示例14: retainMass

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
public static TableFactor retainMass (DiscreteFactor ptl, double alpha)
{
  int[] idxs = new int [ptl.numLocations ()];
  double[] vals = new double [ptl.numLocations ()];
  for (int i = 0; i < idxs.length; i++) {
    idxs[i] = ptl.indexAtLocation (i);
    vals[i] = ptl.logValue (i);
  }

  RankedFeatureVector rfv = new RankedFeatureVector (new Alphabet(), idxs, vals);
  IntArrayList idxList = new IntArrayList ();
  DoubleArrayList valList = new DoubleArrayList ();

  double mass = Double.NEGATIVE_INFINITY;
  double logAlpha = Math.log (alpha);
  for (int rank = 0; rank < rfv.numLocations (); rank++) {
    int idx = rfv.getIndexAtRank (rank);
    double val = rfv.value (idx);
    mass = Maths.sumLogProb (mass, val);
    idxList.add (idx);
    valList.add (val);
    if (mass > logAlpha) {
      break;
    }
  }

  int[] szs = computeSizes (ptl);
  SparseMatrixn m = new SparseMatrixn (szs, idxList.toArray (), valList.toArray ());

  TableFactor result = new TableFactor (computeVars (ptl));
  result.setValues (m);

  return result;
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:35,代码来源:Factors.java

示例15: checkMeanStd

import com.carrotsearch.hppc.DoubleArrayList; //导入依赖的package包/类
void checkMeanStd (DoubleArrayList ell, double mu, double sigma)
{
  double[] vals = ell.toArray ();
  double mean1 = MatrixOps.mean (vals);
  double std1 = MatrixOps.stddev (vals);
  assertEquals (mu, mean1, 0.025);
  assertEquals (sigma, std1, 0.01);
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:9,代码来源:TestNormalFactor.java


注:本文中的com.carrotsearch.hppc.DoubleArrayList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。