Search code examples
rdbscan

DBSCAN with R including periodic boundary condition


I am using the following statement in R programming langiuage for density based clustering in my 3D data analysis-

clusterstry <- dbscan(styrenexyz, 0.20, MinPts =20, method = "hybrid", showplot = 1, countmode = 1:10,100,1000)

However, this epsilon (=20) can not count the cases of periodic boundary condition.

Could someone please suggest how can I count the periodic boundary condition?


Solution

  • You can create your own distance function, instead of using Euclidean distance.

    Then you can easily implement your periodic boundary conditions. If you do a search there are examples of this with Python which may help you.

    Alternately you can add an extra dimension to enforce periodic boundary conditions.

    I would recommend doing the custom distance function instead the extra dimension to avoid any distortion. You can create a custom distance function in R by writing your own function then supplying the results the results to either dbscan() or optics().

    You'll notice that it accepts either a data matrix or a distance matrix. You can let R know that your object is a distance matrix with the function as.dist(). That's from the stats package.