dqm7854 2017-03-30 10:52
浏览 448

在PHP中实现SM2算法

I am trying to implement SM2 algorithm in php using this link - http://www.blueraja.com/blog/477/a-better-spaced-repetition-learning-algorithm-sm2 .

My code is as below-

<table>
<tr>
<td>Fail </td>
<td>hard </td>
<td>good </td>
<td>easy </td>
</tr>
<tr>
<td>0 </td>
<td>1.5 </td>
<td>2.5 </td>
<td>5 </td>
</tr>

<tr>
<td>
<?php
$performanceRating1 =  0;
$consecutiveCorrectAnswers1 = 0;
echo $easy1 = -0.8 + (0.28 * $performanceRating1) + (0.02 * ($performanceRating1 * $performanceRating1));
?>
</td>
<td><?php
$performanceRating2 =  1.5;
$consecutiveCorrectAnswers2 = 1;
echo  $easy2 = -0.8 + (0.28 * $performanceRating2) + (0.02 * ($performanceRating2 * $performanceRating2));
echo "<br>";
echo  $nextDueDay2 = 6 * (pow($easy2,($consecutiveCorrectAnswers2 -1)));
//$nextDueDate
?>  </td>
<td><?php
$performanceRating3 =  2.5;
$consecutiveCorrectAnswers3 = 1;
echo $easy3 = -0.8 + (0.28 * $performanceRating3) + (0.02 * ($performanceRating3 * $performanceRating3));
echo "<br>";
echo  $nextDueDay3 = 6 * (pow($easy3,($consecutiveCorrectAnswers3 -1)));
?>  </td>
<td><?php
$performanceRating4 =  5;
$consecutiveCorrectAnswers4 = 1;
echo $easy4 = -0.8 + (0.28 * $performanceRating4) + (0.02 * ($performanceRating4 * $performanceRating4));
echo "<br>";
echo  $nextDueDay4 = 6 * (pow($easy4,($consecutiveCorrectAnswers4 -1)));

?>  </td>
</tr>
</table>

the output that I am getting is -

                      Fail    Hard      good          Easy
Performance rating    0       1.5       2.5           5
Easiness              -0.8    -0.335    0.025         1.1
Next Due Days         0       6         6             6

I am facing problem with calculating days value. In my code i am getting similar value for all performance rating, it should be like <1m <10m 4d for very first time.

You can get an idea of output from this existing app https://apps.ankiweb.net/

I hope i can get solution of my question.

Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
    • ¥15 fluent的在模拟压强时使用希望得到一些建议
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流