no.uib.cipr.matrix.Vector.dot()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中no.uib.cipr.matrix.Vector.dot()方法的一些代码示例,展示了Vector.dot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Vector.dot()方法的具体详情如下:
包路径:no.uib.cipr.matrix.Vector
类名称:Vector
方法名:dot

Vector.dot介绍

[英]xT*y
[中]xT*y

代码示例

代码示例来源:origin: algorithmfoundry/Foundry

/**
 * Inner Vector product between two Vectors
 *
 *
 * @param other
 *          the Vector with which to compute the dot product with this,
 *          must be the same dimension as this
 * @return dot product, (0,\infty)
 */
public double dotProduct(
  final AbstractMTJVector other)
{
  this.assertSameDimensionality(other);
  return this.internalVector.dot( other.internalVector );
}

代码示例来源:origin: openimaj/openimaj

private Vector project(Vector v, Vector u){
  return u.copy().scale((v.dot(u) / u.dot(u)));
}

代码示例来源:origin: algorithmfoundry/Foundry

/**
 * Inner Vector product between two Vectors
 *
 *
 * @param other
 *          the Vector with which to compute the dot product with this,
 *          must be the same dimension as this
 * @return dot product, (0,\infty)
 */
public double dotProduct(
  final AbstractMTJVector other)
{
  this.assertSameDimensionality(other);
  return this.internalVector.dot( other.internalVector );
}

代码示例来源:origin: gov.sandia.foundry/gov-sandia-cognition-common-core

/**
 * Inner Vector product between two Vectors
 *
 *
 * @param other
 *          the Vector with which to compute the dot product with this,
 *          must be the same dimension as this
 * @return dot product, (0,\infty)
 */
public double dotProduct(
  final AbstractMTJVector other)
{
  this.assertSameDimensionality(other);
  return this.internalVector.dot( other.internalVector );
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Computes standard deviation for given instance, without transforming target
 * back into original space.
 */
protected double computeStdDev(Instance inst, Vector k) throws Exception {
 double kappa = m_actualKernel.eval(-1, -1, inst) + m_deltaSquared;
 double s = m_L.mult(k, new DenseVector(k.size())).dot(k);
 double sigma = m_delta;
 if (kappa > s) {
  sigma = Math.sqrt(kappa - s);
 }
 return sigma;
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Computes standard deviation for given instance, without transforming target
 * back into original space.
 */
protected double computeStdDev(Instance inst, Vector k) throws Exception {
 double kappa = m_actualKernel.eval(-1, -1, inst) + m_deltaSquared;
 double s = m_L.mult(k, new DenseVector(k.size())).dot(k);
 double sigma = m_delta;
 if (kappa > s) {
  sigma = Math.sqrt(kappa - s);
 }
 return sigma;
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Returns natural logarithm of density estimate for given value based on
 * given instance.
 * 
 * @param inst the instance to make the prediction for.
 * @param value the value to make the prediction for.
 * @return the natural logarithm of the density estimate
 * @exception Exception if the density cannot be computed
 */
@Override
public double logDensity(Instance inst, double value) throws Exception {
 inst = filterInstance(inst);
 // Build K vector (and Kappa)
 Vector k = new DenseVector(m_NumTrain);
 for (int i = 0; i < m_NumTrain; i++) {
  k.set(i, m_weights[i] * m_actualKernel.eval(-1, i, inst));
 }
 double estimate = k.dot(m_t) + m_avg_target;
 double sigma = computeStdDev(inst, k);
 // transform to GP space
 value = value * m_Alin + m_Blin;
 // center around estimate
 value = value - estimate;
 double z = -Math.log(sigma * Math.sqrt(2 * Math.PI)) - value * value
  / (2.0 * sigma * sigma);
 return z + Math.log(m_Alin);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns natural logarithm of density estimate for given value based on
 * given instance.
 * 
 * @param inst the instance to make the prediction for.
 * @param value the value to make the prediction for.
 * @return the natural logarithm of the density estimate
 * @exception Exception if the density cannot be computed
 */
@Override
public double logDensity(Instance inst, double value) throws Exception {
 inst = filterInstance(inst);
 // Build K vector (and Kappa)
 Vector k = new DenseVector(m_NumTrain);
 for (int i = 0; i < m_NumTrain; i++) {
  k.set(i, m_weights[i] * m_actualKernel.eval(-1, i, inst));
 }
 double estimate = k.dot(m_t) + m_avg_target;
 double sigma = computeStdDev(inst, k);
 // transform to GP space
 value = value * m_Alin + m_Blin;
 // center around estimate
 value = value - estimate;
 double z = -Math.log(sigma * Math.sqrt(2 * Math.PI)) - value * value
  / (2.0 * sigma * sigma);
 return z + Math.log(m_Alin);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns the log of the density value for the given vector.
 *
 * @param valuePassed input vector
 * @return log density based on given distribution
 */
@Override
public double logDensity(double[] valuePassed) {
 // calculate mean subtractions
 Vector x = new DenseVector(valuePassed);
 return lnconstant - 0.5 * x.dot(covarianceInverse.mult(x.add(-1.0, mean), new DenseVector(x.size())));
}

代码示例来源:origin: openimaj/openimaj

@Override
public IndependentPair<double[], PerceptronClass> generate() {
  double decide = Math.signum(rng.nextDouble() - 0.5);
  if(decide == 0) decide = 1;
  PerceptronClass dec = PerceptronClass.fromSign(decide);
  while(true){			
    double[] randomPoint = new double[this.dims];
    
    for (int i = 0; i < randomPoint.length; i++) {
      randomPoint[i] = nextRandomValue(); 
    }
    
    Vector v = new DenseVector(randomPoint);
    v.add(-1, origin);
    Vector d = direction.copy();
    double dot = v.dot(d);
    double sgn = Math.signum(dot);
    if(sgn == 0) sgn = 1;
    if(rng.nextDouble() <this.error){
      sgn = -sgn; 
    }
    PerceptronClass sgnClass = PerceptronClass.fromSign(sgn);
    if(sgnClass.equals(dec)) {
      return IndependentPair.pair(randomPoint, sgnClass);
    }
  }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Returns the log of the density value for the given vector.
 *
 * @param valuePassed input vector
 * @return log density based on given distribution
 */
@Override
public double logDensity(double[] valuePassed) {
 // calculate mean subtractions
 Vector x = new DenseVector(valuePassed);
 return lnconstant - 0.5 * x.dot(covarianceInverse.mult(x.add(-1.0, mean), new DenseVector(x.size())));
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Classifies a given instance.
 * 
 * @param inst the instance to be classified
 * @return the classification
 * @throws Exception if instance could not be classified successfully
 */
@Override
public double classifyInstance(Instance inst) throws Exception {
 // Filter instance
 inst = filterInstance(inst);
 // Build K vector
 Vector k = new DenseVector(m_NumTrain);
 for (int i = 0; i < m_NumTrain; i++) {
  k.set(i, m_weights[i] * m_actualKernel.eval(-1, i, inst));
 }
 double result = (k.dot(m_t) + m_avg_target - m_Blin) / m_Alin;
 return result;
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Classifies a given instance.
 * 
 * @param inst the instance to be classified
 * @return the classification
 * @throws Exception if instance could not be classified successfully
 */
@Override
public double classifyInstance(Instance inst) throws Exception {
 // Filter instance
 inst = filterInstance(inst);
 // Build K vector
 Vector k = new DenseVector(m_NumTrain);
 for (int i = 0; i < m_NumTrain; i++) {
  k.set(i, m_weights[i] * m_actualKernel.eval(-1, i, inst));
 }
 double result = (k.dot(m_t) + m_avg_target - m_Blin) / m_Alin;
 return result;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/discriminantAnalysis

/**
 * Output class "probabilities". These need to be calibrated.
 */
public double[] distributionForInstance(Instance inst) throws Exception {
 
 // Filter instance
 m_RemoveUseless.input(inst);
 inst = m_RemoveUseless.output();
 
 // Convert instance to matrix
 Vector instM = new DenseVector(inst.numAttributes() - 1);
 int index = 0;
 for (int i = 0; i < inst.numAttributes(); i++) {
  if (i != m_Data.classIndex()) {
   instM.set(index++, inst.value(i));
  }
 }
 // Pipe output through sigmoid
 double[] dist = new double[2];
 dist[1] = 1/(1 + Math.exp(instM.dot(m_Weights) - m_Threshold));
 dist[0] = 1 - dist[1];
 return dist;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Computes a prediction interval for the given instance and confidence level.
 * 
 * @param inst the instance to make the prediction for
 * @param confidenceLevel the percentage of cases the interval should cover
 * @return a 1*2 array that contains the boundaries of the interval
 * @throws Exception if interval could not be estimated successfully
 */
@Override
public double[][] predictIntervals(Instance inst, double confidenceLevel)
 throws Exception {
 inst = filterInstance(inst);
 // Build K vector (and Kappa)
 Vector k = new DenseVector(m_NumTrain);
 for (int i = 0; i < m_NumTrain; i++) {
  k.set(i, m_weights[i] * m_actualKernel.eval(-1, i, inst));
 }
 double estimate = k.dot(m_t) + m_avg_target;
 double sigma = computeStdDev(inst, k);
 confidenceLevel = 1.0 - ((1.0 - confidenceLevel) / 2.0);
 double z = Statistics.normalInverse(confidenceLevel);
 double[][] interval = new double[1][2];
 interval[0][0] = estimate - z * sigma;
 interval[0][1] = estimate + z * sigma;
 interval[0][0] = (interval[0][0] - m_Blin) / m_Alin;
 interval[0][1] = (interval[0][1] - m_Blin) / m_Alin;
 return interval;
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Computes a prediction interval for the given instance and confidence level.
 * 
 * @param inst the instance to make the prediction for
 * @param confidenceLevel the percentage of cases the interval should cover
 * @return a 1*2 array that contains the boundaries of the interval
 * @throws Exception if interval could not be estimated successfully
 */
@Override
public double[][] predictIntervals(Instance inst, double confidenceLevel)
 throws Exception {
 inst = filterInstance(inst);
 // Build K vector (and Kappa)
 Vector k = new DenseVector(m_NumTrain);
 for (int i = 0; i < m_NumTrain; i++) {
  k.set(i, m_weights[i] * m_actualKernel.eval(-1, i, inst));
 }
 double estimate = k.dot(m_t) + m_avg_target;
 double sigma = computeStdDev(inst, k);
 confidenceLevel = 1.0 - ((1.0 - confidenceLevel) / 2.0);
 double z = Statistics.normalInverse(confidenceLevel);
 double[][] interval = new double[1][2];
 interval[0][0] = estimate - z * sigma;
 interval[0][1] = estimate + z * sigma;
 interval[0][0] = (interval[0][0] - m_Blin) / m_Alin;
 interval[0][1] = (interval[0][1] - m_Blin) / m_Alin;
 return interval;
}

代码示例来源:origin: fommil/matrix-toolkits-java

public Vector solve(Matrix A, Vector b, Vector x)
    throws IterativeSolverNotConvergedException {
  checkSizes(A, b, x);
  double alpha = 0, beta = 0, rho = 0, rho_1 = 0;
  A.multAdd(-1, x, r.set(b));
  for (iter.setFirst(); !iter.converged(r, x); iter.next()) {
    M.apply(r, z);
    rho = r.dot(z);
    if (iter.isFirst())
      p.set(z);
    else {
      beta = rho / rho_1;
      p.scale(beta).add(z);
    }
    A.mult(p, q);
    alpha = rho / p.dot(q);
    x.add(alpha, p);
    r.add(-alpha, q);
    rho_1 = rho;
  }
  return x;
}

代码示例来源:origin: com.googlecode.matrix-toolkits-java/mtj

public Vector solve(Matrix A, Vector b, Vector x)
    throws IterativeSolverNotConvergedException {
  checkSizes(A, b, x);
  double alpha = 0, beta = 0, rho = 0, rho_1 = 0;
  A.multAdd(-1, x, r.set(b));
  for (iter.setFirst(); !iter.converged(r, x); iter.next()) {
    M.apply(r, z);
    rho = r.dot(z);
    if (iter.isFirst())
      p.set(z);
    else {
      beta = rho / rho_1;
      p.scale(beta).add(z);
    }
    A.mult(p, q);
    alpha = rho / p.dot(q);
    x.add(alpha, p);
    r.add(-alpha, q);
    rho_1 = rho;
  }
  return x;
}

代码示例来源:origin: com.googlecode.matrix-toolkits-java/mtj

M.apply(r, z);
M.transApply(rtilde, ztilde);
rho_1 = z.dot(rtilde);
A.transMult(ptilde, qtilde);
alpha = rho_1 / ptilde.dot(q);
x.add(alpha, p);
r.add(-alpha, q);

代码示例来源:origin: fommil/matrix-toolkits-java

rho_1 = rtilde.dot(r);
alpha = rho_1 / rtilde.dot(vhat);
q.set(-alpha, vhat).add(u);

相关文章