dongsu3654 2014-12-08 08:21
浏览 240

比较两个图表并获得相似性百分比

question:How to compare two chart ranges, and get percentage as a result.

I want to compare two chart parts, (range of 60 values), and as a result get percentage of difference. So i can find very similar chart curves. (Example:Get all charts that are 90% similar to this one)

For every range, data is stored in 60 number array. Every range starts with 0 and all next numbers represent chart value from that moment.("+" chart goes up and "-" chart goes down)

$range1 = array(0.00,-0.90,2.10,0.10,-3.40,-4.30,-1.90,-0.30,0.00,0.10,-0.60,-0.20,-0.30,-0.30,1.00,-0.90,-0.50,1.00,2.80,5.00,5.50,5.20,6.70,5.50,5.70,7.30,6.00,5.10,5.30,11.10,10.90,9.00,7.10,6.60,7.00,5.50,5.50,12.60,15.60,14.30,18.50,16.60,16.60,20.30,20.60,18.10,16.10,19.10,14.40,18.70,17.40,17.80,17.20,19.90,20.60,17.70,17.00,17.50,16.70,14.70);
$range2 = array(0.00,-2.90,-3.60,-3.10,-3.90,-5.90,-11.80,-8.40,-8.00,-8.40,-8.20,-7.00,-7.60,-7.30,-5.10,-7.20,-7.30,-7.40,-7.70,-8.90,-9.30,-9.30,-9.90,-7.50,-11.70,-12.20,-19.80,-19.60,-19.90,-19.00,-22.10,-19.10,-20.10,-18.90,-19.70,-19.90,-16.50,-23.70,-26.60,-24.20,-28.30,-27.00,-28.60,-28.90,-22.90,-24.00,-25.10,-24.30,-18.40,-31.70,-29.80,-29.00,-29.50,-28.30,-35.50,-27.60,-34.00,-32.80,-36.00,-34.40,);


$result = some_specific_manual_written_function($range1, $range2);

//as a result i want get percentage or something else from what i can how similar charts are

I will do it reading csv files and then storing it to db, so it can be done with php or python.

  • 写回答

2条回答 默认 最新

  • dsfsdf7852 2014-12-08 08:47
    关注

    Try this

    function some_specific_manual_written_function($range1, $range2)
    {
        $match = 0;
        for($i=0; count($range1); $i++)
        {
            if(in_array($range[$i],$range2))
            {
                $match++;               
            }
        }
    
        $percentage_match = (count($range1)/$match ) * 100;
    
        echo "Perncetage Match is : ".$percentage_match."%";
    
        return $percentage_match;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)