## Simple Python implementation of the Weiszfeld algorithm

##### March 14, 2021
machine_learning python weiszfeld_algorithm

Following is a simple implementation of the Weiszfeld algortihm that was discussed in a previous post in python.

import numpy as np
import math
from numpy import array

def weiszfeld(points):

max_error = 0.0000000001

x=np.array([point for point in  points])
y=np.array([point for point in  points])

ext_condition = True

start_x = np.average(x)
start_y = np.average(y)

while ext_condition:

sod = (((x - start_x)**2) + ((y - start_y)**2))**0.5

new_x = sum(x/sod) / sum(1/sod)
new_y = sum(y/sod) / sum(1/sod)

ext_condition = (abs(new_x - start_x) > max_error) or
(abs(new_y - start_y) > max_error)

start_y = new_y
start_x = new_x

print(new_x, new_y)

if __name__=="__main__":
weiszfeld([(2,1), (12,2), (3,9), (13,11)])


#### Type2Fuzzy Library Implementation: Mendel, Jerry M., and RI Bob John. 'Type-2 fuzzy sets made simple.'

##### October 27, 2021
type2_fuzzy type2_fuzzy_library fuzzy python

#### Mathematical prerequisites for some Clustering techniques

##### October 14, 2021
maths machine_learning

#### Notes on Monte Carlo Simulation

##### March 14, 2021
machine_learning python random_walk