Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

support to calculate centroids from list of vectors#3298

Merged
colombod merged 8 commits into
dotnet:mainfrom
colombod:cookbook_support
Nov 7, 2023
Merged

support to calculate centroids from list of vectors#3298
colombod merged 8 commits into
dotnet:mainfrom
colombod:cookbook_support

Conversation

@colombod

@colombod colombod commented Nov 3, 2023

Copy link
Copy Markdown
Member

To go from

  var accumulated = vectors.Aggregate((Enumerable.Repeat(0f, 1536), 0), (acc, d) => (acc.Item1.Zip(d, (a, b) => a + b).ToArray(), acc.Item2 + 1));

  return accumulated.Item1.Select(e => e/ accumulated.Item2).ToArray();

To

 var data = new[]
 {
     new []{ 1f, 1f, 1f},
     new []{ 2f, 2f, 2f},
     new []{ 1f, 2f, 3f}
 };

 var centroid = data.Centroid();

@colombod colombod added the Area-Build & Infrastructure Relating to this repo's build and infrastructure label Nov 3, 2023
@colombod
colombod enabled auto-merge (rebase) November 3, 2023 20:12
@colombod
colombod merged commit f0654b0 into dotnet:main Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Area-Build & Infrastructure Relating to this repo's build and infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants