Here you can find the source of averagePt(double[][] ndPoints)
Parameter | Description |
---|---|
ndPoints | a bunch of n-d points |
public static double[] averagePt(double[][] ndPoints)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www . jav a2 s. c o m * Find the average n-d point in a collection of n-d points. * @param ndPoints a bunch of n-d points * @return the average nd point. Note this is just the actual average, * it may not be a real point resolve the input ndPoints. */ public static double[] averagePt(double[][] ndPoints) { int nDimensions = ndPoints[0].length; double[] avg = new double[nDimensions]; for (double[] ndPoint : ndPoints) { for (int n = 0; n < nDimensions; n++) { avg[n] += ndPoint[n]; } } for (int n = 0; n < nDimensions; n++) { avg[n] /= ndPoints.length; } return avg; } }