I have a data-set of 6000 thousands 3D coordinates that I store in a list I named allcoord. I find all the near neighbours of a given point using that function :
def nearNeighbors(allcoord, idself, radius):
xc, yc, zc = allcoord[idself][0:3]
neighbors = []
for i in range(len(allcoord)):
if i != idself:
x, y, z = allcoord[i][0:3]
if (x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc) <= radius*radius:
neighbors.append(i)
return neighbors
As you can see I look in a sphere to find all the neighbours of the given point. Now I would like to calculate the probability of the connection knowing that closer the neighbours is, higher is the probability of connection. The model is like a Gaussian but with 3D coordinates.
Then for example :
import math
import numpy as np
a = np.asarray([1,1,3])
b = np.asarray([1.5,0.8,2.4])
sygma = 1
gaussianweight = math.exp(-(a-b)*(a-b)/2*sygma)
But I have the following error :
Traceback (most recent call last):
File "<ipython-input-39-96dd84161692>", line 9, in <module>
gaussianweight = math.exp(-(a-b)*(a-b)/2*sygma)
TypeError: only length-1 arrays can be converted to Python scalars
I have two questions :
1) How to determine a good value for sigma ?
2) How to perform that operation on 3D coordinates ?
I need this parameter to determine a minimum value of the Gaussian weight to consider there is a connection between 2 points.
Thank you for the help !