當前位置: 首頁>>代碼示例>>Java>>正文


Java Doubles.asList方法代碼示例

本文整理匯總了Java中com.google.common.primitives.Doubles.asList方法的典型用法代碼示例。如果您正苦於以下問題:Java Doubles.asList方法的具體用法?Java Doubles.asList怎麽用?Java Doubles.asList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.primitives.Doubles的用法示例。


在下文中一共展示了Doubles.asList方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getValues

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
static
public List<?> getValues(Tensor tensor){
	DataType dataType = tensor.dataType();

	switch(dataType){
		case FLOAT:
			return Floats.asList(TensorUtil.toFloatArray(tensor));
		case DOUBLE:
			return Doubles.asList(TensorUtil.toDoubleArray(tensor));
		case INT32:
			return Ints.asList(TensorUtil.toIntArray(tensor));
		case INT64:
			return Longs.asList(TensorUtil.toLongArray(tensor));
		case STRING:
			return Arrays.asList(TensorUtil.toStringArray(tensor));
		case BOOL:
			return Booleans.asList(TensorUtil.toBooleanArray(tensor));
		default:
			throw new IllegalArgumentException();
	}
}
 
開發者ID:jpmml,項目名稱:jpmml-tensorflow,代碼行數:22,代碼來源:TensorUtil.java

示例2: plot

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Plot a time series, connecting the observation times to the measurements.
 *
 * @param timeSeries the series to plot.
 * @param title      the title of the plot.
 * @param seriesName the name of the series to display.
 */
public static void plot(final TimeSeries timeSeries, final String title, final String seriesName) {
    Thread plotThread = new Thread(() -> {
        final List<Date> xAxis = new ArrayList<>(timeSeries.observationTimes().size());
        for (OffsetDateTime dateTime : timeSeries.observationTimes()) {
            xAxis.add(Date.from(dateTime.toInstant()));
        }
        List<Double> seriesList = Doubles.asList(round(timeSeries.asArray(), 2));
        final XYChart chart = new XYChartBuilder().theme(Styler.ChartTheme.GGPlot2)
                                                  .height(600)
                                                  .width(800)
                                                  .title(title)
                                                  .build();
        XYSeries residualSeries = chart.addSeries(seriesName, xAxis, seriesList);
        residualSeries.setXYSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter);
        residualSeries.setMarker(new Circle()).setMarkerColor(Color.RED);

        JPanel panel = new XChartPanel<>(chart);
        JFrame frame = new JFrame(title);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.add(panel);
        frame.pack();
        frame.setVisible(true);
    });
    plotThread.start();
}
 
開發者ID:signaflo,項目名稱:java-timeseries,代碼行數:33,代碼來源:Plots.java

示例3: getBankLiabilitiesToCentralBank

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@RecorderSource(
   value = "bankLiabilitiesToCentralBank",
   collectionLengthMember="getNumberOfCommercialBanksForRecorderSampling()"
   )
public List<Double> getBankLiabilitiesToCentralBank() {
    final List<Double>
       ret = Doubles.asList(
          new double[getNumberOfCommercialBanksForRecorderSampling()]);
    int index = 0;
    for(final CommercialBank bank :
       population.getAgentsOfType(CommercialBank.class)) {
       double valueBorrowedFromCentralBank = 0.0;
       for (int i = 0; i < ((Bank) bank).getLiabilities().size(); i++) {
          if ( ((Bank) bank).getLiabilities().get(i) instanceof Loan )
             if( ((Loan)((Bank) bank).getLiabilities().get(i)).getLender() instanceof CentralBank )
                valueBorrowedFromCentralBank += ((Bank) bank).getLiabilities().get(i).getValue();
          if ( ((Bank) bank).getLiabilities().get(i) instanceof RepoLoan )
             if( ((RepoLoan)((Bank) bank).getLiabilities().get(i)).getLender() instanceof CentralBank )
                valueBorrowedFromCentralBank += ((Bank) bank).getLiabilities().get(i).getValue();
       }
       ret.set(index++, valueBorrowedFromCentralBank);
    }
    return ret;
}
 
開發者ID:crisis-economics,項目名稱:CRISIS,代碼行數:25,代碼來源:AbstractModel.java

示例4: getBankRiskWeightedAssetsOverTime

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@RecorderSource(
      value = "bankRiskWeightedAssets",
      collectionLengthMember="getNumberOfCommercialBanksForRecorderSampling()"
      )
public List<Double> getBankRiskWeightedAssetsOverTime() {
   final List<Double>
   ret = Doubles.asList(
         new double[getNumberOfCommercialBanksForRecorderSampling()]);
   int index = 0;
   for(final Bank bank : population.getAgentsOfType(CommercialBank.class)) {
      double RWA = bank.accept(new ComputeRiskWeightedAssetsOperation());
      ret.set(index++, RWA); 
   }

   return ret;
}
 
開發者ID:crisis-economics,項目名稱:CRISIS,代碼行數:17,代碼來源:AbstractModel.java

示例5: getBankDepositsOverTime

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@RecorderSource(
   value = "bankDepositAccountHoldings",
   collectionLengthMember="getNumberOfCommercialBanksForRecorderSampling()"
   )
public List<Double> getBankDepositsOverTime() {
    final List<Double>
       ret = Doubles.asList(
          new double[getNumberOfCommercialBanksForRecorderSampling()]);
    int index = 0;
    for(final Bank bank : population.getAgentsOfType(CommercialBank.class)) {
       double sumDepositValue = 0.0;
       for (final DepositAccount deposit : bank.getLiabilitiesDeposits())
          sumDepositValue += deposit.getValue();
       ret.set(index++, sumDepositValue); 
    }
    
    return ret;
}
 
開發者ID:crisis-economics,項目名稱:CRISIS,代碼行數:19,代碼來源:AbstractModel.java

示例6: testFuzzyEqualsZeroTolerance

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
public void testFuzzyEqualsZeroTolerance() {
  // make sure we test -0 tolerance
  for (double zero : Doubles.asList(0.0, -0.0)) {
    for (double a : ALL_DOUBLE_CANDIDATES) {
      for (double b : ALL_DOUBLE_CANDIDATES) {
        assertEquals(a == b || (Double.isNaN(a) && Double.isNaN(b)),
            DoubleMath.fuzzyEquals(a, b, zero));
      }
    }
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:12,代碼來源:DoubleMathTest.java

示例7: createExplicit

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Creates a {@code Distribution} with {@code ExplicitBuckets}.
 *
 * @param bounds initializes the bounds used to define the explicit buckets
 *
 * @return a {@code Distribution} with {@code ExplicitBuckets}
 * @throws IllegalArgumentException if a bad input prevents creation.
 */
public static Distribution createExplicit(double[] bounds) {
  List<Double> allBounds = Doubles.asList(bounds);
  Set<Double> uniqueBounds = Sets.newHashSet(allBounds);
  if (allBounds.size() != uniqueBounds.size()) {
    throw new IllegalArgumentException(MSG_SOME_BOUNDS_ARE_THE_SAME);
  }
  Collections.sort(allBounds);
  ExplicitBuckets buckets = ExplicitBuckets.newBuilder().addAllBounds(allBounds).build();
  Builder builder = Distribution.newBuilder().setExplicitBuckets(buckets);
  for (int i = 0; i < allBounds.size() + 1; i++) {
    builder.addBucketCounts(0L);
  }
  return builder.build();
}
 
開發者ID:cloudendpoints,項目名稱:endpoints-management-java,代碼行數:23,代碼來源:Distributions.java

示例8: toList

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
static
public List<Double> toList(Vector vector){
	DenseVector denseVector = vector.toDense();

	double[] values = denseVector.values();

	return Doubles.asList(values);
}
 
開發者ID:jpmml,項目名稱:jpmml-sparkml,代碼行數:9,代碼來源:VectorUtil.java

示例9: getDisplayAid

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Override
public ParameterDisplayAid getDisplayAid(double[] sourceX) {
	double minExpectedBandwidth;
	double bestGuess;
	double maxExpectedBandwidth;
	
	if(sourceX.length < 2)
	{
		minExpectedBandwidth = 0.01;
		bestGuess = 1;
		maxExpectedBandwidth = 100;
	}
	else {
		double maxDiff = 0;
		double minDiff = Double.POSITIVE_INFINITY;
		List<Double> sortedList = new ArrayList<>(Doubles.asList(sourceX));
		sortedList.sort(null);
		for(int i = 1; i < sortedList.size(); i++)
		{
			double diff = sortedList.get(i) - sortedList.get(i - 1);
			maxDiff = Math.max(maxDiff, diff);
			minDiff = Math.min(minDiff, diff);
		}
		bestGuess = Math.max(0.0001, maxDiff);
		minExpectedBandwidth = minDiff / 5;
		maxExpectedBandwidth = (sortedList.get(sortedList.size() - 1) - sortedList.get(0));					
	}	
	return new DisplayAid(bestGuess, minExpectedBandwidth, maxExpectedBandwidth);
}
 
開發者ID:cas-bioinf,項目名稱:cy-dataseries,代碼行數:30,代碼來源:LinearKernelSmoothingProvider.java

示例10: getCountUniqueObservations

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Number of different values
 * 
 * @return
 */
public int getCountUniqueObservations() {
	if (uniqueObservations == -1) {
		List<Double> list = Doubles.asList(getValues());
		@SuppressWarnings({ "rawtypes", "unchecked" })
		Set uniqueValues = new HashSet(list);
		uniqueObservations = uniqueValues.size();
	}
	return uniqueObservations;
}
 
開發者ID:TKnudsen,項目名稱:ComplexDataObject,代碼行數:15,代碼來源:StatisticsSupport.java

示例11: ClusteringGenomicHMM

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
public ClusteringGenomicHMM(final List<HIDDEN> hiddenStateValues, final List<Double> weights, final double memoryLength) {
    this.hiddenStateValues = new ArrayList<>(Utils.nonNull(hiddenStateValues));
    Utils.nonNull(weights);
    weights.forEach(w -> ParamUtils.isPositiveOrZero(w, "weights may not be negative."));
    Utils.nonEmpty(hiddenStateValues, "must have at least one hidden state");

    this.weights = Doubles.asList(MathUtils.normalizeFromRealSpace(weights.stream().mapToDouble(x->x).toArray()));
    this.memoryLength = ParamUtils.isPositive(memoryLength, "CNV memory length must be positive");
}
 
開發者ID:broadinstitute,項目名稱:gatk-protected,代碼行數:10,代碼來源:ClusteringGenomicHMM.java

示例12: CopyRatioSegmenter

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * @param initialNumStates  A liberal estimate of the number of hidden minor allele fraction values to
 *                          include in the model.  Hidden states are pruned as the model is learned.
 */
public CopyRatioSegmenter(final int initialNumStates, final ReadCountCollection rcc) {
    super(rcc.targets().stream().map(SimpleInterval::new).collect(Collectors.toList()), Doubles.asList(rcc.getColumn(0)),
            CONSTANT_LOG_2_COPY_RATIO_OF_1, initialNonConstantLog2CopyRatios(initialNumStates - 1));
    Utils.validateArg(rcc.columnNames().size() == 1, "Only single-sample ReadCountCollection is supported.");
    logCoverageCauchyWidth = DEFAULT_INITIAL_CAUCHY_WIDTH;
}
 
開發者ID:broadinstitute,項目名稱:gatk-protected,代碼行數:11,代碼來源:CopyRatioSegmenter.java

示例13: getFirmProductionOverTime

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@RecorderSource(
   value = "firmProduction",
   collectionLengthMember = "getNumberOfFirmsForRecorderSampling()"
   )                                                  // TODO: is this redundant?
public List<Double> getFirmProductionOverTime() {
    final List<Double>
       profit = Doubles.asList(new double[getNumberOfFirmsForRecorderSampling()]);
    int index = 0;
    for(final LoanStrategyFirm firm :
       population.getAgentsOfType(LoanStrategyFirm.class))
       profit.set(index++, firm.getProduction());
    return profit;
}
 
開發者ID:crisis-economics,項目名稱:CRISIS,代碼行數:14,代碼來源:AbstractModel.java

示例14: getHouseholdSavingsOverTime

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@RecorderSource(
   value = "householdSavings",
   collectionLengthMember = "getNumberOfHouseholdsForRecorderSampling()"
   )
public List<Double> getHouseholdSavingsOverTime() {
   final List<Double>
      ret = Doubles.asList(new double[getNumberOfHouseholdsForRecorderSampling()]);
   int index = 0;
   for(final DepositingHousehold household :
      population.getAgentsOfType(DepositingHousehold.class))
      ret.set(index++, household.getDepositValue() );
   return ret;
}
 
開發者ID:crisis-economics,項目名稱:CRISIS,代碼行數:14,代碼來源:AbstractModel.java

示例15: testTransitionProbabilities

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Test
public void testTransitionProbabilities() {
    final List<Double> weights = Doubles.asList(MathUtils.normalizeFromRealSpace(new double[] {0.2, 0.2, 0.6, 0.1, 0.9, 0.1}));
    final List<Double> minorAlleleFractions = Arrays.asList(0.1, 0.2, 0.3, 0.4, 0.23, 0.11);
    final double memoryLength = 5e6;
    final AlleleFractionHMM model = new AlleleFractionHMM(minorAlleleFractions, weights,
            memoryLength, AllelicPanelOfNormals.EMPTY_PON, NO_BIAS_OR_OUTLIERS_PARAMS);

    final int pos1 = 100;
    final int pos2 = (int) (pos1 + 100*memoryLength);  // really far!!!
    final int pos3 = (int) (pos1 + memoryLength/1000);  // really close!!!
    final SimpleInterval position1 = new SimpleInterval("chr1", pos1, pos1);
    final SimpleInterval position2 = new SimpleInterval("chr1", pos2, pos2);
    final SimpleInterval position3 = new SimpleInterval("chr1", pos3, pos3);

    for (int fromState = 0; fromState < weights.size(); fromState++) {
        for (int toState = 0; toState < weights.size(); toState++) {
            // long distances
            Assert.assertEquals(model.logTransitionProbability(fromState, position1, toState, position2),
                    model.logPriorProbability(toState, position2), 1e-3);

            //short distances
            if (toState == fromState) {
                Assert.assertEquals(model.logTransitionProbability(fromState, position1, toState, position3),
                        Math.log(1), 1e-3);
            } else {
                Assert.assertTrue(model.logTransitionProbability(fromState, position1, toState, position3) < Math.log(1e-3));
            }
        }
    }
}
 
開發者ID:broadinstitute,項目名稱:gatk-protected,代碼行數:32,代碼來源:AlleleFractionHMMUnitTest.java


注:本文中的com.google.common.primitives.Doubles.asList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。