在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.

dongnao3990
dongnao3990 你有没有找到这个问题的答案/解决方案?我正在寻求开发SM2PHP实现。
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐