now[bot]: 
This pull request is being automatically deployed with ZEIT Now ([learn more](https://zeit.co/docs/v2/integrations/now-for-github?utm_source=automated&utm_medium=github&utm_campaign=now_bot)).
To see the status of your deployment, click on the icon next to each commit.
	
diff --git a/vg/core.py b/vg/core.py
index a0be949..0c3867b 100644
--- a/vg/core.py
+++ b/vg/core.py
@@ -28,6 +28,7 @@ __all__ = [
     "farthest",
     "basis",
     "within",
+    "average",
     "cross",
     "dot",
 ]
@@ -601,6 +602,33 @@ def within(points, radius, of_point, atol=1e-08, ret_indices=False):
         return points_within_radius
 
 
+def average(values, weights=None, ret_sum_of_weights=False):
+    """
+    Compute a weighted or unweighted average of the 3D input values. The
+    inputs could be points or vectors.
+
+    Args:
+        values (np.arraylike): A `kx3` stack of vectors.
+        weights (array-convertible): An optional `k` array of weights.
+        ret_sum_of_weights (bool): When `True`, the sum of the weights is
+            returned. When `weights` is `None`, this is the number of
+            elements over which the average is taken.
+
+    Returns:
+        np.ndarray: A `(3,)` vector with the weighted or unweighted average.
+    """
+    k = check(locals(), "values", (-1, 3))
+    if weights is not None:
+        weights = np.array(weights)
+        check(locals(), "weights", (k,))
+    result = np.average(values, axis=0, weights=weights)
+    if ret_sum_of_weights:
+        sum_of_weights = np.sum(weights)
+        return result, sum_of_weights
+    else:
+        return result
+
+
 def dot(v1, v2):
     """
     Compute individual or pairwise dot products.

Add `vg.mean` method
To replace code removed in lace/polliwog#96.
diff --git a/vg/test_average.py b/vg/test_average.py
new file mode 100644
index 0000000..9a39ab8
--- /dev/null
+++ b/vg/test_average.py
@@ -0,0 +1,22 @@
+import numpy as np
+from . import core as vg
+
+
+def test_average():
+    np.testing.assert_array_equal(
+        vg.average(np.array([[1.0, 2.0, 3.0], [-6.0, -9.0, -15.0]])),
+        np.array([-2.5, -3.5, -6.0]),
+    )
+    np.testing.assert_array_equal(
+        vg.average(np.array([[1.0, 2.0, 3.0], [-6.0, -9.0, -15.0]]), weights=(3, 5)),
+        np.array([-3.375, -4.875, -8.25]),
+    )
+    result, sum_of_weights = vg.average(
+        np.array([[1.0, 2.0, 3.0], [-6.0, -9.0, -15.0]]),
+        weights=(3, 5),
+        ret_sum_of_weights=True,
+    )
+    np.testing.assert_array_equal(
+        result, np.array([-3.375, -4.875, -8.25]),
+    )
+    assert sum_of_weights == 8.0

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
coverage==6.2
importlib-metadata==4.8.3
iniconfig==1.1.1
numpy==1.19.5
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
tomli==1.2.3
typing_extensions==4.1.1
-e git+https://github.com/lace/vg.git@eb29bab81fe17b0a66b262ae6f2b2d78d9186482#egg=vg
zipp==3.6.0

name: vg
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - coverage==6.2
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - numpy==1.19.5
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/vg

vg/test_average.py::test_average
vg/core.py
vg/core.py