设为首页 加入收藏

TOP

2.2.1 串行版的Credit Review
2013-10-07 15:22:13 来源: 作者: 【 】 浏览:73
Tags:2.2.1 串行 Credit Review

2.2.1   串行版的Credit Review

下面是信用分析操作的串行化版本:

  1. void UpdatePredictionsSequential(AccountRepository& accounts)  
  2. {  
  3.     for_each(accounts.begin(), accounts.end(),  
  4.         [](AccountRepository::value_type& record)  
  5.     {  
  6.         Account& account = record.second;  
  7.         Trend trend = Fit(account.Balances());  
  8.         double prediction = PredictIntercept(trend,  
  9.             (account.Balances().size() + g_predictionWindow));  
  10.         account.SeqPrediction() = prediction;  
  11.         account.SeqWarning() = prediction < account.GetOverdraft();  
  12.     });  

在这个程序中,UpdatePredictionsSequential方法被用来处理账户库中的每一个账户。而其中的Fit方法是一个工具函数,它通过统计学中的最小二乘法根据一组(用户)数据绘制出趋势线。此外,Fit方法是一个纯函数过程即它不会改变任何东西的状态。注5

该值是根据趋势得出的三个月内的预测。如果预测值越过了负债限制(账户系统中的负债额是个负值),该账户就会被标志为审查状态。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2.3.3 小型循环体的特殊处理 下一篇2.1.1 并行版的for循环

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: