Hi everyone,
Something weird happened when I was trying to cluster some points
into to 2 classes based on their location. I kept on compiling and
executing the code, sometimes it reported error, but sometimes it run
sucessfully and gave me an answer(without modifying anything)!!!!!
Here is the code:
************************************************************ **************************
pro cluster_test
a= [ [558288.75d, 4609749.2d, 236.88000, 3.0000000],
$
[558285.49d, 4609729.9d, 236.77000, 3.0000000],
$
[558288.75d, 4609749.2d, 236.88000, 3.0000000],
$
[558286.91d, 4609749.5d, 236.79000, 3.0000000],
$
[558282.26d, 4609732.0d, 236.11000, 3.0000000],
$
[558285.20d, 4609730.7d, 236.41000, 3.0000000],
$
[558283.38d, 4609731.0d, 236.67000, 3.0000000],
$
[558281.54d, 4609731.3d, 236.83000, 3.0000000],
$
[558281.82d, 4609730.5d, 237.23000, 3.0000000],
$
[558283.67d, 4609730.2d, 237.05000, 3.0000000],
$
[558284.16d, 4609729.4d, 237.27000, 3.0000000],
$
[558282.31d, 4609729.7d, 237.36000,
3.0000000]]
b = a[0:1,*]
b[0,*] = b[0,*] - long(a[0,*]/100)*100
b[1,*] = b[1,*] - long(a[1,*]/100)*100
plot,b[0,*],b[1,*]
print,b
weights = CLUST_WTS(b, N_CLUSTERS = 2)
rst = CLUSTER(b,weights,n_clusters = 2)
sub = where(rst eq 0)
pa = a[*,sub]
print,pa
end
************************************************************ **************************
The first and second column of the array a is X,Y
coordinate,respectivly. Because the numbers are too huge, I tried to
make them relatively smaller by substracting a number, then I tried to
cluster the points using the new coordinates(array b). If you plot tha
array b you will find that the points can be clustered into 2 classes.
I'm sitting here waiting for your help, thanks a lot!
|