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


C++ Noise::pvalue方法代码示例

本文整理汇总了C++中Noise::pvalue方法的典型用法代码示例。如果您正苦于以下问题:C++ Noise::pvalue方法的具体用法?C++ Noise::pvalue怎么用?C++ Noise::pvalue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Noise的用法示例。


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

示例1: findPeaks

void PeakFinder_SNR::findPeaks(const OrderedPairContainerRef& pairs,
                               vector<size_t>& resultIndices) const
{
    vector<OrderedPair> preprocessedData;
    if (config_.preprocessWithLogarithm)
        transform(pairs.begin(), pairs.end(), back_inserter(preprocessedData), ComputeLogarithm());  

    const OrderedPairContainerRef& data = config_.preprocessWithLogarithm ? preprocessedData : pairs;

    Noise noise = noiseCalculator_->calculateNoise(data); // TODO: investigate calculating noise on unprocessed data

    vector<double> pvalues;
    transform(data.begin(), data.end(), back_inserter(pvalues), CalculatePValue(noise));
    
    vector<double> rollingProducts = calculateRollingProducts(pvalues, config_.windowRadius);
    if (rollingProducts.size() != data.size()) 
        throw runtime_error("[PeakFinder_SNR::findPeaks()] This isn't happening"); 

    double thresholdValue = noise.mean + config_.zValueThreshold * noise.standardDeviation;
    double thresholdPValue = noise.pvalue(thresholdValue);
    double threshold = ((double(*)(double,int))std::pow)(thresholdPValue, 1+2*config_.windowRadius);

    // report local minima above the threshold
    for (size_t i=0; i<rollingProducts.size(); i++)
    {
        if ((i==0 || rollingProducts[i]<rollingProducts[i-1]) &&
            (i+1==rollingProducts.size() || rollingProducts[i]<rollingProducts[i+1]) &&
            rollingProducts[i] < threshold)
        { 
            resultIndices.push_back(i);
        }
    }

    if (config_.log) 
    {
        ostream& log = *config_.log;

        log << "[PeakFinder_SNR::findPeaks()]\n";

        log << "# noise: " << noise.mean << " " << noise.standardDeviation << endl;
        log << "# thresholdValue: " << thresholdValue << endl;
        log << "# thresholdPValue: " << thresholdPValue << endl;
        log << "# threshold: " << threshold << endl;
        log << "#\n";

        log << "# found data pvalue rollingProduct\n";
        for (size_t i=0; i<data.size(); ++i)
        {
            bool found = (find(resultIndices.begin(), resultIndices.end(), i) != resultIndices.end());
            log << (found?"* ":"  ") << fixed << setprecision(6) << data[i] << scientific << setw(15) << pvalues[i] << setw(15) << rollingProducts[i] << endl;
        }
        log << endl;

        log << "[PeakFinder_SNR::findPeaks()] end\n";
    }
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:56,代码来源:PeakFinder.cpp


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