1,154 reputation
217
bio website
location
age
visits member for 1 year, 4 months
seen yesterday

Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
Well, you can try this ps={{0, 0}, {Sqrt[2], 0}, {0, Sqrt[2]}, {Sqrt[2], Sqrt[2]}}. Very odd,.but it's true, offset is necessary.
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
Thank you for your answer! I am testing now, and I also found the EuclideanDistance problem, so I use N and add small offset 0.0000001 to it, I found this small offset is necessary, see my answer.
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
Thank you for your method! I also posted mine :)
Dec
10
answered efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
Dec
10
revised efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
added 67 characters in body
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
@Silvia No, You didn't use my code properly:). You should set coolist={{1, 2}, {1, 0}, {2, 2}, {2, 1}} and Do[p[i] = coolist[[i]], {i, 1, 4}]
Dec
10
revised efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
added 21 characters in body
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
@Silvia Oh, my god! I made a mistake, I am so sorry. I have corrected it. But the code I write is right, I think.
Dec
10
revised efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
deleted 3 characters in body
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
@RahulNarain I'm glad I made myself clear and thank you for your interest in this question. But I don't have a fixed third nearest distance, it varies from point to point.
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
@Silvia I want two list, one list contain nearest point labels, the other list contains next nearest point labels. Since p[2] is the "next nearest point" to p[3], so it should not be contained in the nearestlist
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
OK, return to my 4 point toy example. Let nnn = Nearest[{p[1], p[2], p[3], p[4]}] . Then nnn[p[1], 1] gives{{0, 0}}, nnn[p[1], 2] gives {{0, 0}, {0, 1}}, and nnn[p[1], 3] gives {{0, 0}, {0, 1}, {1, 0}}. But actually {0,1} and {1,0} has the same distance to p[1], so in this case p[1] has two nearest point. But if you see p[4], it only has one nearest point.
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
@RahulNarain but the environment of every point is different. I can't set a fixed n?
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
@RahulNarain I lookup in the doc. I found that NearestFunction may not be working well in this case. because the number of nearest point is not fixed, maybe one and maybe two, even three....
Dec
10
comment efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
@RahulNarain Oh, thank you. NearestFunction! Let me see it.
Dec
10
asked efficient way to give nearest neighbour and next nearest neighbour of every point in a point set
Dec
8
revised How to constrain memory usage on HPC?
added 1635 characters in body
Dec
8
comment How to constrain memory usage on HPC?
@OleksandrR. Though the pmem option should suffice for ordinary usage, I must say to constrain memory inside mathematica is much more adaptive. First, there are some small clusters which are not equipped with a job management system. Second, the way to use the HPC is variable. Very often we can use mathemaica interactively on HPC by submitting an interactive PBS job, and if the pmem is set at the beginning, then all the calculations doing in this interactive job is restricted per process, while we should have been able to use more memory if we didn't set the pmem when submit the job.
Dec
8
comment How to constrain memory usage on HPC?
@OleksandrR. Thank you so much! You're right.Generally, an HPC has job management system. For example, the PBSpro provide pmem option to constrain memory per process. I actually forgot this before, thank you for reminding me this.
Dec
7
revised How to parallel the computation tasks according to machines instead of kernels
added 97 characters in body