/** 供构造函数调用的 “初始函数”,负责 “参数校验”、“取行情数据” 和 “计算均值”。 */ private void init() { if (!consturctorParamValidate()) { return; } int range = (step + 5 * (step - 1)) + num; // 取值范围。 Double[] hvs = TechnoligyTools.getIStatisticsHistoryDatas(statistics, period, dataType, range); // 取得历史数据。 avgs = compute(hvs); // 计算出均值。 }
/** * 根据数据序列计算均值,返回的均值数列 “由近到远” 排列,同时对小数精度进行了处理。 * * @param vs 数组序列(该数列必须符合 “由远到近” 方式排序) * @return Double[] */ private Double[] compute(final Double[] vs) { Double[] temp = QuoteFunction.t3(vs, step, factor); return TechnoligyTools.reverseAndSubAndScaleDoubles( temp, 0, (temp.length > num ? num : temp.length), scale); }