std::vector<std::vector<float>>
signatureWindows(arma::mat &path, int logSigDepth, int windowSize) {
  std::vector<std::vector<float>> sW(path.n_rows);
  std::vector<float> repPath;
  for (int i = 0; i < path.n_rows; ++i) {
    repPath.push_back(i);
    repPath.push_back(path(i, 0));
    repPath.push_back(path(i, 1));
  }
  for (int i = 0; i < path.size(); ++i) {
    sW[i].resize(logsigdim(3, logSigDepth));
    int first = std::max(0, i - windowSize);
    int last = std::min((int)path.size() - 1, i + windowSize);
    logSignature(&repPath[3 * first], last - first + 1, 3, logSigDepth,
                 &sW[i][0]);
  }
  return sW;
}
Beispiel #2
0
void Gaussian::fit(const arma::mat& data)
{
    if(data.size() > 0){
        D = data.n_rows;
        Mean = arma::mean(data);
        Covariance  = arma::cov(data);
        A    = arma::chol(Covariance);
        det  = arma::det(Covariance);
    }
}
Beispiel #3
0
/**
 *
 * @param vector1 first individual
 * @param vector2 second individual
 * @return recombination sites
 */
arma::mat twoVecHetDet(const arma::mat &vector1, const arma::mat & vector2)
{
	arma::mat sum2vec(1, vector1.size());
	sum2vec.zeros();
	sum2vec = vector1 + vector2;

	arma::mat result(1, vector1.size());
	result.zeros();

	int previous = 0, previousLocation = 0;
	for (uint i = 0; i < vector1.size(); i++)
	{
		if (sum2vec[i] == 0 || sum2vec[i] == 2 || sum2vec[i] == 4)
		{
			previous = sum2vec[i];
			previousLocation = i;
			break;
		}
	}
	for (uint i = previousLocation; i < vector1.size(); i++)
	{
		if (sum2vec[i] == 0 || sum2vec[i] == 2 || sum2vec[i] == 4)
		{
			if (abs(previous - sum2vec[i]) == 2)
			{
				for (uint j = previousLocation; j < i; j++)
					result[j] = 1;
				previous = sum2vec[i];
				previousLocation = i;
			}
			else if (sum2vec[i] == 0 || sum2vec[i] == 2 || sum2vec[i] == 4)
			{
				previous = sum2vec[i];
				previousLocation = i;
			}

		}

	}

	return (result);
}
Beispiel #4
0
arma::vec mat2vec(arma::mat y)
{
arma::vec b(y.begin(), y.size(), /*copy_aux_mem*/false, /*strict*/true);
return b;
}