时间预估 mathematica程序 [改]

[新的程序见:http://blog.youkuaiyun.com/barrypp/article/details/7969633]

[旧的程序见:http://blog.youkuaiyun.com/barrypp/article/details/7962401]

基于一次回归和二次回归进行时间预估。具体来讲,基于你之前看连续剧、漫画的时间位置信息,来预测之后第几集什么时候看完。

 

时间预估

基于一次、二次回归运算

说明:其中一次回归运算中,从使用全部数据到仅使用后几个(较新的)数据的计算都有。二次回归运算则使用全部数据。

Created By Barrypp At 20120909235258
Modified By Barrypp At 20120910184110
Modified By Barrypp At 20120910205741

In[343]:= TMfoF = 25; LSN = 24; Data = {{1, 0, 17, 46}, {1, 18, 18, 14}, {2, 0, 18, 
   20}, {2, 16, 18, 38}, {4, 3, 19, 8}, {6, 2, 19, 50}, {7, 2, 20, 12}, {8, 2,
    20, 33}, {9, 4, 20, 58}, {10, 2, 21, 17}, {11, 2, 21, 42}, {12, 2, 21, 
   56}, {13, 2, 22, 7}};
(*
Data的格式为,四个数字一组,示例 {当前集数,已播放时间的分钟数,时间的小时数 (24h),时间的分钟数};
TMfOF是Total Minutes for one File in a collection,每一集的分钟数;
LSN是Last Serial Number in a collection最后一集的集数。
*)
InData = {#1[[1]] + #1[[2]]/TMfoF, #1[[3]] + #1[[4]]/60} & /@ Data;

(*一次回归*)
Expected = 
  LinearModelFit[#1, {x}, x] & /@ NestList[Rest, InData, Length[InData] - 2];

Print["\!\(\*
StyleBox[\"一次回归曲线组:\",\nFontFamily->\"΢ÈíÑźÚ\"]\)"]
Show[ListPlot[InData, Mesh -> Full, Joined -> True, 
  PlotStyle -> Directive[Red, PointSize[Large]]], 
 Plot[Evaluate[Through[Expected[x]]], {x, InData[[1, 1]], LSN + 1}, 
  PlotStyle -> 
   Table[GrayLevel[1 - i/Length[Expected]], {i, 1, Length[Expected]}]], 
 PlotRange -> All, AxesLabel -> {"集数", "时间"}]

(*二次回归*)
Expected2 = LinearModelFit[InData, {x, x^2}, x];

Print["\!\(\*
StyleBox[\"二次回归信息及曲线:\",\nFontFamily->\"΢ÈíÑźÚ\"]\)"]
Expected2["ANOVATable"]
StringForm["\!\(\*SuperscriptBox[\"R\", \"2\"]\)==``", Expected2["RSquared"]]
Normal[Expected2]
Show[ListPlot[InData, Mesh -> Full, Joined -> True, PlotStyle -> Red], 
 Plot[Expected2[x], {x, InData[[1, 1]], LSN + 1}], PlotRange -> All, 
 AxesLabel -> {"集数", "时间"}]

(*时间预计表*)
OutputTable = 
  Table[Prepend[
    StringForm["``:``", IntegerPart[#1], 
       If[(TempX = IntegerPart[60 FractionalPart[#1]]) >= 10, TempX, 
        StringForm["0``", TempX]]] & /@ 
     Through[Append[Expected, Expected2][n]], 
    StringForm["第``集预计开始时间", n]], {n, IntegerPart[InData[[-1, 1]]] + 1, 
    LSN + 1}];
TableForm[PrependTo[OutputTable, 
  Join[{{}, "一次回归"}, 
   Table[StringForm["后``个", i], {i, Length[InData] - 1, 2, -1}], {"二次回归"}]]]

 

环境是  Wolfram Research Mathematica v7.0.1.0

输出结果示例:

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值