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


Java DoubleArrayList.isEmpty方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.doubles.DoubleArrayList.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleArrayList.isEmpty方法的具体用法?Java DoubleArrayList.isEmpty怎么用?Java DoubleArrayList.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.doubles.DoubleArrayList的用法示例。


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

示例1: evaluate

import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入方法依赖的package包/类
@Override
public VaRCalculationResult evaluate(final EmpiricalDistributionVaRParameters parameters, final DoubleTimeSeries<?>... data) {
  ArgumentChecker.notNull(parameters, "parameters");
  ArgumentChecker.notNull(data, "data");
  final double var = _varCalculator.evaluate(parameters, data).getVaRValue();
  final DoubleArrayList excesses = new DoubleArrayList();
  for (final double portfolioReturn : data[0].valuesArrayFast()) {
    if (portfolioReturn < -var) {
      excesses.add(portfolioReturn);
    }
  }
  if (excesses.isEmpty()) {
    return new VaRCalculationResult(var, null);
  }
  return new VaRCalculationResult(-_meanCalculator.evaluate(excesses.toDoubleArray()), null);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:EmpiricalDistributionConditionalVaRCalculator.java

示例2: execute

import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入方法依赖的package包/类
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
  final ValueRequirement desiredValue = desiredValues.iterator().next();
  final String surfaceName = desiredValue.getConstraint(ValuePropertyNames.SURFACE);
  final String instrumentType = desiredValue.getConstraint(InstrumentTypeProperties.PROPERTY_SURFACE_INSTRUMENT_TYPE);
  final String leftXExtrapolatorName = desiredValue.getConstraint(InterpolatedDataProperties.LEFT_X_EXTRAPOLATOR_NAME);
  final String rightXExtrapolatorName = desiredValue.getConstraint(InterpolatedDataProperties.RIGHT_X_EXTRAPOLATOR_NAME);
  final String xInterpolatorName = desiredValue.getConstraint(InterpolatedDataProperties.X_INTERPOLATOR_NAME);
  final String leftYExtrapolatorName = desiredValue.getConstraint(InterpolatedDataProperties.LEFT_Y_EXTRAPOLATOR_NAME);
  final String rightYExtrapolatorName = desiredValue.getConstraint(InterpolatedDataProperties.RIGHT_Y_EXTRAPOLATOR_NAME);
  final String yInterpolatorName = desiredValue.getConstraint(InterpolatedDataProperties.Y_INTERPOLATOR_NAME);
  final ValueRequirement volatilityDataRequirement = getVolatilityDataRequirement(target, surfaceName, instrumentType);
  final Object volatilityDataObject = inputs.getValue(volatilityDataRequirement);
  if (volatilityDataObject == null) {
    throw new OpenGammaRuntimeException("Could not get " + volatilityDataRequirement);
  }
  @SuppressWarnings("unchecked")
  final VolatilitySurfaceData<Double, Double> volatilityData = (VolatilitySurfaceData<Double, Double>) volatilityDataObject;
  if (volatilityData.size() == 0) {
    throw new OpenGammaRuntimeException("Volatility surface data for requirement " + volatilityDataRequirement + " was empty");
  }
  final DoubleArrayList x = new DoubleArrayList();
  final DoubleArrayList y = new DoubleArrayList();
  final DoubleArrayList sigma = new DoubleArrayList();
  final Double[] xData = volatilityData.getXs();
  final Double[] yData = volatilityData.getYs();
  final int n = xData.length;
  for (int i = 0; i < n; i++) {
    final Double vol = volatilityData.getVolatility(xData[i], yData[i]);
    if (vol != null && !CompareUtils.closeEquals(vol, 0)) {
      x.add(xData[i]);
      y.add(yData[i]);
      sigma.add(vol);
    }
  }
  if (x.isEmpty()) {
    throw new OpenGammaRuntimeException("Could not get any data for " + volatilityDataRequirement);
  }
  final Interpolator1D xInterpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(xInterpolatorName, leftXExtrapolatorName, rightXExtrapolatorName);
  final Interpolator1D yInterpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(yInterpolatorName, leftYExtrapolatorName, rightYExtrapolatorName);
  final GridInterpolator2D interpolator = new GridInterpolator2D(xInterpolator, yInterpolator);
  final Surface<Double, Double, Double> surface = InterpolatedDoublesSurface.from(x.toDoubleArray(), y.toDoubleArray(), sigma.toDoubleArray(), interpolator);
  final VolatilitySurface volatilitySurface = new VolatilitySurface(surface);
  final ValueProperties properties = getResultProperties(surfaceName, instrumentType, leftXExtrapolatorName, rightXExtrapolatorName, xInterpolatorName, leftYExtrapolatorName,
      rightYExtrapolatorName, yInterpolatorName);
  final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.INTERPOLATED_VOLATILITY_SURFACE, target.toSpecification(), properties);
  return Collections.singleton(new ComputedValue(spec, volatilitySurface));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:49,代码来源:InterpolatedVolatilitySurfaceFunction.java


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