检查功能点的位置


I have a points and I want to draw a best fit hyperbolic function for this points.
Now I want to make a Quality checker. Any ideas?
My idea was to check where is the point against the function. ( Like if the point is over / under or on the function )
prescription function is : fn(x)=A1+(A2/A3*(x+A4))
My first idea for this was:

function checkQuality($points,$m,$k,$A1,$A4){
    $over = 0;
    $under= 0;
    $on = 0;
    $radius = 3;

    foreach ($points as $point){
        $status = ($A1+($m/($k*($point['x']+$A4)))-$point['y']);
        if($status < $radius && $status > -$radius){
            $status = 0;
        }
        if($status > 0){
            $over++;
        }else if($status <1 && $status >= 0){
            $on++;
        }else if($status < 0){
            $under++;

        }
    }
    if($under < $over){
        $percentChange = ($under !== 0 ? ($under / $over) : 0) * 100;
    }else{
        $percentChange = ($over !== 0 ? ($over / $under) : 0) * 100;
    }

    return ['on'=>$on,'over'=>$over,'under'=>$under,'percent'=>$percentChange];
}

But the result is not so accurate.

Here I post how its look like. The green curve is manualy set and the blue one is generated ( Where I'm using the quality check for check how is good and if is bad try generate better curve ) -> the Green curve is better than the blue

Graph screen

(The values in the inputs are for green curve)


here is code where I'm using the Quality check for imagine why I want to have the most possible accurate checker:

  for($i = 0; $i < 10000 ; $i++){
        $new_m += 0.2;
        $actual = $this->checkQuality($points['points'],$new_m,$ob['k'],0,0);
        if($actual['percent'] > $prev['percent']){
            $prev['percent'] = $actual['percent'];
            $prev['m'] = $new_m;
            $newQuality = $actual;
        }else if($i>0 && $actual['percent'] < $prev['percent']){
            break;
        }
    }
dongyou6795
dongyou6795 一种常见的方法是测量f(x)的观测值与其估计值之间的(垂直)距离。但是在使用中有很多适合度的度量,选择一个不是编程问题。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问