Skip to content

Instantly share code, notes, and snippets.

View MicahRCM's full-sized avatar

Micah Corning-Myers MicahRCM

  • spherical.studio
  • Chicago, IL
View GitHub Profile
// Function to compute the average of an array of vectors
const averageVector = (vectors) => {
// Just a cheeky safety function to check for vectors
if (vectors.length === 0) {
return [];
}
// start with the sum vector with 0's
let sumVector = new Array(vectors[0].length).fill(0);
// Iterate over all vectors
for(let vector of vectors) {
@MicahRCM
MicahRCM / geomedianplexus.js
Created May 18, 2023 04:36
Plexus Geometric Median Example
// Function to compute the geometric median of an array of points
const geometricMedian = (points) => {
// Initial guess is the first point
let guess = points[0];
// Tolerance for convergence
const tolerance = 1e-5;
// Iterate until convergence or maximum iterations
for(let i = 0; i < 1000; i++) {
// Initialize accumulators for weighted sum of points
let numerators = new Array(guess.length).fill(0);
@MicahRCM
MicahRCM / ts
Created May 5, 2023 15:50
Attempt to login
import { getAuth, signInWithEmailAndPassword } from "firebase/auth";
const auth = getAuth();
const email = "theexgenesis@gmail.com@gmail.com";
const password = "BROPASSWORDBRO";
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Authentication successful
})