Get regression equation (y = axᵇ) in format y = ax^b

@param array $params

@return string
429235
public static function getModelEquation(array $params): string
    {
        return sprintf('y = %fx^%f', $params[self::$A], $params[self::$B]);
    }
1038702
protected function makeSign(array $params):string
    {
        unset($params['sign']);
        kSortRecursive($params);
        $paramsString = $this->paramsToString($params);

        return md5($paramsString . md5($this->key . $this->secret));
    }
617737
public function queryValue($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetchColumn();
        $this->statement->closeCursor();

        return $rst;
    }
794021
protected function _constructPdoDsn(array $params)
    {
        $dsn = 'sqlite:';
        if (isset($params['path'])) {
            $dsn .= $params['path'];
        } elseif (isset($params['memory'])) {
            $dsn .= ':memory:';
        }

        return $dsn;
    }
440534
public function queryColumn($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetchAll(\PDO::FETCH_COLUMN);
        $this->statement->closeCursor();
        return $rst;
    }
1260811
public function RSquared($data = array(), $coefficients = array())
    {
        // Get average of Y-data.
        $Y_Average = 0.0;
        foreach ($data as $dataPoint) {
            $Y_Average += $dataPoint[1];
        }

        $Y_Average /= count($data);

        // Calculate R Squared.
        $Y_MeanSum = 0.0;
        $Y_ErrorSum = 0.0;
        foreach ($data as $dataPoint) {
            $x = $dataPoint[0];
            $y = $dataPoint[1];
            $error = $y;
            $error -= $this->interpolate($coefficients, $x);
            $Y_ErrorSum += $error * $error;

            $error = $y;
            $error -= $Y_Average;
            $Y_MeanSum += $error * $error;
        }

        $R_Squared = 1.0 - ( $Y_ErrorSum / $Y_MeanSum );

        return $R_Squared;
    }
203015
public function get_column($query, $params = []) {
		$statement = $this->get_statement($query, $params);
		$statement->execute();
		$result = $statement->fetch_assoc();

		$col = [];
		foreach ($result as $row) {
			$col[] = array_shift($row);
		}

		return $col;
	}
979913
protected function getQueryParams(array $params = []): string
    {
        if (empty($params)) {
            return '';
        }
        $query = $params['query'] ?? [];
        if (is_string($query)) {
            return $query;
        }
        return empty($query) ? '' : http_build_query($query);
    }
644652
public function getParam(string $param)
    {
        $result = $this->getConfig()->get($param);
        return $result ?? null;
    }
400438
protected function actionGet($params=array())
    {
        $response = array(
            'errors'=>array(),
            'data' => array(
                'count' => 0,
                'items' => array(),
            ),
        );
        $offset = isset($params['offset'])?(int)$params['offset']:0;
        if ($offset < 0) $offset = 0;
        $count = isset($params['count'])?(int)$params['count']:100;
        if ($count < 1) $count = 1;
        if ($count > 100) $count = 100;
        $filter = array(
            'fields' => array(),
            'offset' => $offset,
            'count' => $count,
        );
        $idsRaw = isset($params['ids'])?(string)$params['ids']:null;
        $idsRaw = preg_replace('/[^a-f0-9\,]/ui','',$idsRaw);
        $idsRaw = preg_replace('/^\,+|\,+$/ui','',$idsRaw);
        $idsRaw = preg_replace('/\,+/ui',',',$idsRaw);
        if (!empty($idsRaw)) {
            $ids = explode(',',$idsRaw);
            if (count($ids) > 1) {
                $filter['fields'][] = array(
                    'field' => 'id',
                    'compare' => 'in',
                    'value' => $ids,
                );
            } elseif (count($ids) == 1) {
                $filter['fields'][] = array(
                    'field' => 'id',
                    'compare' => '=',
                    'value' => $ids[0],
                );
            }
        }
        $street = isset($params['street'])?trim((string)$params['street']):null;
        $number = isset($params['number'])?trim((string)$params['number']):null;

        if ($street && !$number) {
            $filter['fields'][] = array(
                'field' => 'street',
                'compare' => '=',
                'value' => $street,
            );
        }
        if (!$street && $number) {
            $filter['fields'][] = array(
                'field' => 'number',
                'compare' => '=',
                'value' => $street,
            );
        }
        if ($street && $number) {
            $filter['fields'][] = array(
                'field' => 'id',
                'compare' => '=',
                'value' => $this->build->getId(array('street'=>$street,'number'=>$number)),
            );
        }
        $response['data']['count'] = $this->build->count($filter);
        $builds = $this->build->find($filter);
        $response['data']['items'] = $builds;
        return $response;
    }
873687
public function evaluate(array $params): Matrix
    {
        $m = $this->m;
        $n = $this->n;
        $R = [];
        for ($i = 0; $i < $m; $i++) {
            for ($j = 0; $j < $n; $j++) {
                $func = $this->A[$i][$j];
                $R[$i][$j] = $func($params);
            }
        }
        return MatrixFactory::create($R);
    }
1249147
protected function _parseApiParams($params)
  {
    $apiparams = [];
    if (count($params) === 0) {
      return $apiparams;
    }

    if (is_array($params[0])) {
      // given parameters are array
      $apiparams = $params[0];
      return $apiparams;
    }

    // user gave us query-style params
    parse_str($params[0], $apiparams);
    if (! is_array($apiparams)) {
      $apiparams = [];
    }

    return $apiparams;
  }
1267215
protected function prepareParams(array $params)
    {
        $result = $params;

        foreach ($result as $key => $val) {
            if (is_bool($val)) {
                $result[$key] = $val ? 1 : 0;
            }
        }

        return $result;
    }
1260290
protected function getArgumentsFromParams($params)
    {
        $args     = array();
        $excludes = array("name", "before", "separator", "after", "fields");

        if (is_array($params)) {
            foreach ($params as $key => $value) {
                if (!in_array($key, $excludes)) {
                    $args[$key] = $value;
                }
            }
        }

        return $args;
    }
40456
public function getDataTypeParams(array $params)
    {
        $type = $this->getEloquentDataMethod();
        if (in_array($type, ['char', 'string']) && isset($params[0]) && ($length = intval($params[0])) > 0) {
            return [$length];
        }

        if (in_array($type, ['decimal', 'double', 'float'])
            && isset($params[0]) && ($length = intval($params[0])) > 0 && isset($params[1]) && ($decimal = intval($params[1])) > 0) {
            return [$length, $decimal];
        }

        if ($type == 'enum') {
            return $params;
        }

        return [];
    }
1101403
public static function evaluateModel(float $x, array $params): float
    {
        $V = $params[self::$V];
        $K = $params[self::$K];

        return ($V * $x) / ($K + $x);
    }
1294939
public function transformParams(array $params): array
    {
        $newParams = [];
        foreach ($params as $key => $value) {
            $newParams['%' . $key . '%'] = $value;
        }

        return $newParams;
    }