MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / computeAverage

Method computeAverage

src/org/opensourcephysics/numerics/Util.java:198–204  ·  view source on GitHub ↗

Computes the average value of a subset of an array. @param array the data to be averaged @param start the index of the first point to be averaged @param num the total number of points to be averaged @return

(double[] array, int start, int num)

Source from the content-addressed store, hash-verified

196 * @return
197 */
198 public static double computeAverage(double[] array, int start, int num) {
199 double sum = 0;
200 for(int i = start, stop = start+num; i<stop; i++) {
201 sum += array[i];
202 }
203 return sum/num;
204 }
205
206 /**
207 * Creates a function having a constant value.

Callers 2

initializeAnimationMethod · 0.80
stepIsingModelMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected