MCPcopy Create free account
hub / github.com/Kitware/VTK / var

Function var

Wrapping/Python/vtkmodules/numpy_interface/numpy_algorithms.py:333–358  ·  view source on GitHub ↗

Returns the variance of all values along a particular axis (dimension). Given an array of m tuples and n components: * Default is to return the variance of all values in an array. * axis=0: Return the variance values of all components and return a one tuple, n-component array.

(array, axis=None, controller=None)

Source from the content-addressed store, hash-verified

331
332@dsa._override_numpy(numpy.var)
333def var(array, axis=None, controller=None):
334 """Returns the variance of all values along a particular axis (dimension).
335 Given an array of m tuples and n components:
336 * Default is to return the variance of all values in an array.
337 * axis=0: Return the variance values of all components and return a one
338 tuple, n-component array.
339 * axis=1: Return the variance values of all components of each tuple and
340 return an m-tuple, 1-component array.
341
342 When called in parallel, this function will compute the variance across
343 processes when a controller argument is passed or the global controller
344 is defined. To disable parallel summing when running in parallel, pass a
345 dummy controller as follows:
346
347 var(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).
348 """
349 from .algorithms import array_count
350 if axis is None or axis == 0:
351 size = array_count(array, axis, controller)
352 tmp = array - mean(array, axis, controller, size)
353 return sum(tmp*tmp, axis, controller) / size
354 else:
355 if type(array) == dsa.VTKCompositeDataArray:
356 return apply_ufunc(algs.var, array, (axis,))
357 else:
358 return algs.var(array, axis)
359
360@dsa._override_numpy(numpy.std)
361def std(array, axis=None, controller=None):

Callers 1

stdFunction · 0.70

Calls 5

array_countFunction · 0.85
apply_ufuncFunction · 0.85
meanFunction · 0.70
sumFunction · 0.70
typeEnum · 0.50

Tested by

no test coverage detected