Generating random numbers that keep a minimum distanceSimple algorithm to find cycles in edge listHow to Gather a list with some elements considered uniqueFinding Local Minima / Maxima in Noisy DataGarbage collection for memoized functions on subkernelsIssue with very large lists in MathematicaGenerating random symmetric matrixNeed Help Writing code to find Capparelli PartitionsDoes Mathematica have a functional programming idiom to loop over a list till a condition is met?Toroidal metric in a random geometric graphLooking up one additional array element increases runtime by three orders of magnitude

How to md5 a list of filepaths contained in a file?

What is the job of the acoustic cavities inside the main combustion chamber?

Received a dinner invitation through my employer's email, is it ok to attend?

Integer Lists of Noah

Has anyone in space seen or photographed a simple laser pointer from Earth?

Print the last, middle and first character of your code

Cops: The Hidden OEIS Substring

Credit score and financing new car

Referring to different instances of the same character in time travel

What is a solution?

Can fluent English speakers distinguish “steel”, “still” and “steal”?

Changing trains in the Netherlands

Why did Harry Potter get a bedroom?

Constructive proof of existence of free algebras for infinitary equational theories

Machine learning and operations research projects

Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?

How to loop for 3 times in bash script when docker push fails?

During copyediting, journal disagrees about spelling of paper's main topic

If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?

How do you glue a text to a point?

Why can a destructor change the state of a constant object?

US Civil War story: man hanged from a bridge

Does Lufthansa weigh your carry on luggage?

definition of "percentile"



Generating random numbers that keep a minimum distance


Simple algorithm to find cycles in edge listHow to Gather a list with some elements considered uniqueFinding Local Minima / Maxima in Noisy DataGarbage collection for memoized functions on subkernelsIssue with very large lists in MathematicaGenerating random symmetric matrixNeed Help Writing code to find Capparelli PartitionsDoes Mathematica have a functional programming idiom to loop over a list till a condition is met?Toroidal metric in a random geometric graphLooking up one additional array element increases runtime by three orders of magnitude






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3












$begingroup$


I want to create a list of n random integers from 1 to m, where all integers have to be at least a certain distance min apart (i.e. 3 integers out of Range[10], keeping a minimum distance of 2)



This is the module I created to fullfill that purpose:



StartGen[MinimalDistance_] := 
Module[nCells, min,test,i,j,r,
min = MinimalDistance;

(*Just create a Random Sample from Range[m] if min=0
is chosen*)
If[min == 0,
nCells = Sort[RandomSample[Range[m], n]];
Return[nCells]
,
nCells = Table[0, n];
nCells[[1]] = RandomInteger[m];
i = 1; j = 1;

(*Only execute if n integers out of m actually can
keep a minimum distance of min*)
If[m/(n (min + 1)) >= 1,

While[i <= n,
(*Generate random integers from Range[m] until one
fits with the already assigned Integers*)
r = RandomInteger[m];
test = True;
Do[If[Abs[nCells[[j]] - r] <= min,
test = False; Break[],
test = True], j, i
];
If[test == True, nCells[[i]] = r; i++, Null];
];

nCells = Sort[nCells];
Return[nCells];
,
Print["Impossible figuration for m n and min"];
];
];
];


Now the performance problem this creates is quite obvious: If the number of possible integers m and the minimum distance min are too big, as the While loop goes on fewer and fewer generated integers will fit the requirements and it gets harder and harder to hit those few integers through generating random numbers out of Range[m]. (For me this module couldn't produce lists for n=100,m=1000,min=8.)



I think the solution to this problem lies in reducing the number of Integers to choose from as the calculation go on, i.e. eliminate integers that dont fit the requirements anymore.



I tried implementing this with some variants of the DeleteCases[] function but I always ended up just creating more iterative calculations that would worsen the performance once again.

Is there an elegant way to do this?










share|improve this question







New contributor



Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$











  • $begingroup$
    Your problem is that Length[Range[8, 1000, 2 8 - 1]] equals 67 which is less than 100. So that's just not always possible with n=100, m=1000, and min=8.
    $endgroup$
    – Henrik Schumacher
    8 hours ago

















3












$begingroup$


I want to create a list of n random integers from 1 to m, where all integers have to be at least a certain distance min apart (i.e. 3 integers out of Range[10], keeping a minimum distance of 2)



This is the module I created to fullfill that purpose:



StartGen[MinimalDistance_] := 
Module[nCells, min,test,i,j,r,
min = MinimalDistance;

(*Just create a Random Sample from Range[m] if min=0
is chosen*)
If[min == 0,
nCells = Sort[RandomSample[Range[m], n]];
Return[nCells]
,
nCells = Table[0, n];
nCells[[1]] = RandomInteger[m];
i = 1; j = 1;

(*Only execute if n integers out of m actually can
keep a minimum distance of min*)
If[m/(n (min + 1)) >= 1,

While[i <= n,
(*Generate random integers from Range[m] until one
fits with the already assigned Integers*)
r = RandomInteger[m];
test = True;
Do[If[Abs[nCells[[j]] - r] <= min,
test = False; Break[],
test = True], j, i
];
If[test == True, nCells[[i]] = r; i++, Null];
];

nCells = Sort[nCells];
Return[nCells];
,
Print["Impossible figuration for m n and min"];
];
];
];


Now the performance problem this creates is quite obvious: If the number of possible integers m and the minimum distance min are too big, as the While loop goes on fewer and fewer generated integers will fit the requirements and it gets harder and harder to hit those few integers through generating random numbers out of Range[m]. (For me this module couldn't produce lists for n=100,m=1000,min=8.)



I think the solution to this problem lies in reducing the number of Integers to choose from as the calculation go on, i.e. eliminate integers that dont fit the requirements anymore.



I tried implementing this with some variants of the DeleteCases[] function but I always ended up just creating more iterative calculations that would worsen the performance once again.

Is there an elegant way to do this?










share|improve this question







New contributor



Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$











  • $begingroup$
    Your problem is that Length[Range[8, 1000, 2 8 - 1]] equals 67 which is less than 100. So that's just not always possible with n=100, m=1000, and min=8.
    $endgroup$
    – Henrik Schumacher
    8 hours ago













3












3








3


1



$begingroup$


I want to create a list of n random integers from 1 to m, where all integers have to be at least a certain distance min apart (i.e. 3 integers out of Range[10], keeping a minimum distance of 2)



This is the module I created to fullfill that purpose:



StartGen[MinimalDistance_] := 
Module[nCells, min,test,i,j,r,
min = MinimalDistance;

(*Just create a Random Sample from Range[m] if min=0
is chosen*)
If[min == 0,
nCells = Sort[RandomSample[Range[m], n]];
Return[nCells]
,
nCells = Table[0, n];
nCells[[1]] = RandomInteger[m];
i = 1; j = 1;

(*Only execute if n integers out of m actually can
keep a minimum distance of min*)
If[m/(n (min + 1)) >= 1,

While[i <= n,
(*Generate random integers from Range[m] until one
fits with the already assigned Integers*)
r = RandomInteger[m];
test = True;
Do[If[Abs[nCells[[j]] - r] <= min,
test = False; Break[],
test = True], j, i
];
If[test == True, nCells[[i]] = r; i++, Null];
];

nCells = Sort[nCells];
Return[nCells];
,
Print["Impossible figuration for m n and min"];
];
];
];


Now the performance problem this creates is quite obvious: If the number of possible integers m and the minimum distance min are too big, as the While loop goes on fewer and fewer generated integers will fit the requirements and it gets harder and harder to hit those few integers through generating random numbers out of Range[m]. (For me this module couldn't produce lists for n=100,m=1000,min=8.)



I think the solution to this problem lies in reducing the number of Integers to choose from as the calculation go on, i.e. eliminate integers that dont fit the requirements anymore.



I tried implementing this with some variants of the DeleteCases[] function but I always ended up just creating more iterative calculations that would worsen the performance once again.

Is there an elegant way to do this?










share|improve this question







New contributor



Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$




I want to create a list of n random integers from 1 to m, where all integers have to be at least a certain distance min apart (i.e. 3 integers out of Range[10], keeping a minimum distance of 2)



This is the module I created to fullfill that purpose:



StartGen[MinimalDistance_] := 
Module[nCells, min,test,i,j,r,
min = MinimalDistance;

(*Just create a Random Sample from Range[m] if min=0
is chosen*)
If[min == 0,
nCells = Sort[RandomSample[Range[m], n]];
Return[nCells]
,
nCells = Table[0, n];
nCells[[1]] = RandomInteger[m];
i = 1; j = 1;

(*Only execute if n integers out of m actually can
keep a minimum distance of min*)
If[m/(n (min + 1)) >= 1,

While[i <= n,
(*Generate random integers from Range[m] until one
fits with the already assigned Integers*)
r = RandomInteger[m];
test = True;
Do[If[Abs[nCells[[j]] - r] <= min,
test = False; Break[],
test = True], j, i
];
If[test == True, nCells[[i]] = r; i++, Null];
];

nCells = Sort[nCells];
Return[nCells];
,
Print["Impossible figuration for m n and min"];
];
];
];


Now the performance problem this creates is quite obvious: If the number of possible integers m and the minimum distance min are too big, as the While loop goes on fewer and fewer generated integers will fit the requirements and it gets harder and harder to hit those few integers through generating random numbers out of Range[m]. (For me this module couldn't produce lists for n=100,m=1000,min=8.)



I think the solution to this problem lies in reducing the number of Integers to choose from as the calculation go on, i.e. eliminate integers that dont fit the requirements anymore.



I tried implementing this with some variants of the DeleteCases[] function but I always ended up just creating more iterative calculations that would worsen the performance once again.

Is there an elegant way to do this?







list-manipulation performance-tuning






share|improve this question







New contributor



Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 9 hours ago









Maxim HanselowskiMaxim Hanselowski

161 bronze badge




161 bronze badge




New contributor



Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Maxim Hanselowski is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • $begingroup$
    Your problem is that Length[Range[8, 1000, 2 8 - 1]] equals 67 which is less than 100. So that's just not always possible with n=100, m=1000, and min=8.
    $endgroup$
    – Henrik Schumacher
    8 hours ago
















  • $begingroup$
    Your problem is that Length[Range[8, 1000, 2 8 - 1]] equals 67 which is less than 100. So that's just not always possible with n=100, m=1000, and min=8.
    $endgroup$
    – Henrik Schumacher
    8 hours ago















$begingroup$
Your problem is that Length[Range[8, 1000, 2 8 - 1]] equals 67 which is less than 100. So that's just not always possible with n=100, m=1000, and min=8.
$endgroup$
– Henrik Schumacher
8 hours ago




$begingroup$
Your problem is that Length[Range[8, 1000, 2 8 - 1]] equals 67 which is less than 100. So that's just not always possible with n=100, m=1000, and min=8.
$endgroup$
– Henrik Schumacher
8 hours ago










2 Answers
2






active

oldest

votes


















3












$begingroup$

  1. Construct a random sample from Range[m] satisfying the minimum
    distance requirements taking into account the fact that if $x_k$ is
    selected at step $k$, the choices in step $k+1$ are restricted to
    the range from $x_k + d$ to $m - (n-k)d$ to be able to get $n-k$
    additional elements in remaining steps satisfying the minimum distance constraint.

  2. Shuffle the list obtained in the first step



ClearAll[f]
f[m_, n_, d_] /; n d <= m := RandomSample @ Rest @
FoldList[RandomChoice[Range[# + Boole[#2 > 1] d, m - (n - #2) d]] &, 1, Range[n]]


Examples:



Table[f[10, 3, 2], 5]



8, 3, 6, 6, 10, 8, 8, 5, 10, 8, 10, 6, 10, 1, 4




Min[Differences@Sort@#] & /@ %



2, 2, 2, 2, 3




f[10, 4, 3]



f[10, 4, 3] (* impossible *)




f[1000, 100, 8]



848, 808, 189, 776, 680, 824, 472, 728, 352, 976, 736, 544, 504,
936, 904, 408, 720, 400, 816, 448, 856, 560, 279, 336, 312, 512, 888,
928, 424, 944, 584, 480, 238, 552, 920, 568, 528, 600, 952, 304, 536,
688, 632, 712, 992, 592, 616, 221, 896, 456, 864, 344, 792, 744, 392,
624, 320, 984, 576, 206, 648, 960, 368, 840, 872, 376, 328, 752, 832,
24, 288, 640, 416, 1000, 760, 696, 520, 488, 672, 464, 249, 800, 968,
768, 664, 432, 384, 784, 271, 912, 296, 656, 704, 496, 608, 230, 880,
360, 257, 440




Min @ Differences@ Sort @ %



8




res = f[10000000, 10000, 800]; // AbsoluteTiming // First



0.105936




Min @ Differences @ Sort @ res



800




Update: An alternative implementation using NestList:



ClearAll[f2]
f2[m_, n_, d_] /; n d <= m := Module[k = 1, RandomSample @ Rest @
NestList[RandomChoice[Range[# + Boole[k++ > 1] d, m - (n - k) d]] &, 1, n]]





share|improve this answer











$endgroup$




















    2












    $begingroup$

    How about something like this - rather than picking random numbers until one satisfies the minimum distance criteria, pick the random number from a set that excludes disallowed values.



    gen2[m_, n_, min_] := Module[nCells, set,
    set = Range[m];
    nCells = RandomSample[set, 1];
    While[Length[nCells] < n && Length[set] > 0,
    set = Complement[set,
    Range[nCells[[-1]] - min + 1, nCells[[-1]] + min - 1]];
    If[Length[set] < 1, Print["Couldn't pick ", n],
    nCells = Join[nCells, RandomSample[set, 1]]];
    ];
    nCells]


    Table[gen2[10, 3, 2], 10] // Column
    (*
    4,7,10
    8,3,6
    2,6,9
    5,8,3
    7,10,1
    3,10,6
    3,7,10
    3,9,6
    1,10,5
    9,2,6 *)


    As noted by Henrik Schumacher in the comments, n=100, m=1000, min=8 doesn't work most of the time (you get an empty set before you pick 100 numbers):



    gen2[1000, 100, 8]
    (*
    Couldn't pick 100
    599, 14, 526, 475, 52, 448, 791, 576, 196, 711, 941, 35, 211, 483,
    371, 401, 827, 354, 757, 547, 858, 86, 222, 336, 696, 913, 419, 386,
    812, 363, 982, 974, 563, 966, 665, 279, 955, 494, 243, 675, 151, 994,
    742, 5, 298, 438, 901, 316, 24, 627, 636, 873, 411, 684, 261, 516,
    107, 586, 138, 768, 508, 290, 650, 253, 850, 116, 73, 464, 173, 163,
    129, 94, 428, 346, 842, 609, 888, 306, 619, 181, 922, 44, 555, 931,
    231, 539, 327, 731, 776, 456, 799, 64, 722, 271 *)



    But 7 is fine:



    test = gen2[1000, 100, 7]
    (*
    556, 966, 917, 863, 425, 155, 414, 504, 43, 82, 395, 196, 765, 701,
    55, 330, 935, 626, 337, 843, 511, 885, 441, 834, 756, 117, 572, 285,
    519, 17, 189, 658, 563, 817, 266, 727, 28, 854, 805, 747, 775, 210,
    997, 546, 138, 303, 608, 295, 900, 145, 718, 355, 176, 666, 130, 946,
    259, 102, 405, 795, 452, 649, 480, 591, 240, 363, 63, 641, 95, 694,
    493, 221, 536, 978, 633, 784, 739, 387, 871, 827, 675, 465, 10, 954,
    580, 599, 686, 878, 36, 1, 926, 373, 320, 529, 348, 248, 708, 893,
    311, 273 *)


    Test the minimum distance between numbers:



    stest = Sort[test];
    Min[Table[stest[[i]] - stest[[i - 1]], i, 2, Length[test]]]
    (* 7 *)
    ```





    share|improve this answer









    $endgroup$















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Maxim Hanselowski is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201889%2fgenerating-random-numbers-that-keep-a-minimum-distance%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3












      $begingroup$

      1. Construct a random sample from Range[m] satisfying the minimum
        distance requirements taking into account the fact that if $x_k$ is
        selected at step $k$, the choices in step $k+1$ are restricted to
        the range from $x_k + d$ to $m - (n-k)d$ to be able to get $n-k$
        additional elements in remaining steps satisfying the minimum distance constraint.

      2. Shuffle the list obtained in the first step



      ClearAll[f]
      f[m_, n_, d_] /; n d <= m := RandomSample @ Rest @
      FoldList[RandomChoice[Range[# + Boole[#2 > 1] d, m - (n - #2) d]] &, 1, Range[n]]


      Examples:



      Table[f[10, 3, 2], 5]



      8, 3, 6, 6, 10, 8, 8, 5, 10, 8, 10, 6, 10, 1, 4




      Min[Differences@Sort@#] & /@ %



      2, 2, 2, 2, 3




      f[10, 4, 3]



      f[10, 4, 3] (* impossible *)




      f[1000, 100, 8]



      848, 808, 189, 776, 680, 824, 472, 728, 352, 976, 736, 544, 504,
      936, 904, 408, 720, 400, 816, 448, 856, 560, 279, 336, 312, 512, 888,
      928, 424, 944, 584, 480, 238, 552, 920, 568, 528, 600, 952, 304, 536,
      688, 632, 712, 992, 592, 616, 221, 896, 456, 864, 344, 792, 744, 392,
      624, 320, 984, 576, 206, 648, 960, 368, 840, 872, 376, 328, 752, 832,
      24, 288, 640, 416, 1000, 760, 696, 520, 488, 672, 464, 249, 800, 968,
      768, 664, 432, 384, 784, 271, 912, 296, 656, 704, 496, 608, 230, 880,
      360, 257, 440




      Min @ Differences@ Sort @ %



      8




      res = f[10000000, 10000, 800]; // AbsoluteTiming // First



      0.105936




      Min @ Differences @ Sort @ res



      800




      Update: An alternative implementation using NestList:



      ClearAll[f2]
      f2[m_, n_, d_] /; n d <= m := Module[k = 1, RandomSample @ Rest @
      NestList[RandomChoice[Range[# + Boole[k++ > 1] d, m - (n - k) d]] &, 1, n]]





      share|improve this answer











      $endgroup$

















        3












        $begingroup$

        1. Construct a random sample from Range[m] satisfying the minimum
          distance requirements taking into account the fact that if $x_k$ is
          selected at step $k$, the choices in step $k+1$ are restricted to
          the range from $x_k + d$ to $m - (n-k)d$ to be able to get $n-k$
          additional elements in remaining steps satisfying the minimum distance constraint.

        2. Shuffle the list obtained in the first step



        ClearAll[f]
        f[m_, n_, d_] /; n d <= m := RandomSample @ Rest @
        FoldList[RandomChoice[Range[# + Boole[#2 > 1] d, m - (n - #2) d]] &, 1, Range[n]]


        Examples:



        Table[f[10, 3, 2], 5]



        8, 3, 6, 6, 10, 8, 8, 5, 10, 8, 10, 6, 10, 1, 4




        Min[Differences@Sort@#] & /@ %



        2, 2, 2, 2, 3




        f[10, 4, 3]



        f[10, 4, 3] (* impossible *)




        f[1000, 100, 8]



        848, 808, 189, 776, 680, 824, 472, 728, 352, 976, 736, 544, 504,
        936, 904, 408, 720, 400, 816, 448, 856, 560, 279, 336, 312, 512, 888,
        928, 424, 944, 584, 480, 238, 552, 920, 568, 528, 600, 952, 304, 536,
        688, 632, 712, 992, 592, 616, 221, 896, 456, 864, 344, 792, 744, 392,
        624, 320, 984, 576, 206, 648, 960, 368, 840, 872, 376, 328, 752, 832,
        24, 288, 640, 416, 1000, 760, 696, 520, 488, 672, 464, 249, 800, 968,
        768, 664, 432, 384, 784, 271, 912, 296, 656, 704, 496, 608, 230, 880,
        360, 257, 440




        Min @ Differences@ Sort @ %



        8




        res = f[10000000, 10000, 800]; // AbsoluteTiming // First



        0.105936




        Min @ Differences @ Sort @ res



        800




        Update: An alternative implementation using NestList:



        ClearAll[f2]
        f2[m_, n_, d_] /; n d <= m := Module[k = 1, RandomSample @ Rest @
        NestList[RandomChoice[Range[# + Boole[k++ > 1] d, m - (n - k) d]] &, 1, n]]





        share|improve this answer











        $endgroup$















          3












          3








          3





          $begingroup$

          1. Construct a random sample from Range[m] satisfying the minimum
            distance requirements taking into account the fact that if $x_k$ is
            selected at step $k$, the choices in step $k+1$ are restricted to
            the range from $x_k + d$ to $m - (n-k)d$ to be able to get $n-k$
            additional elements in remaining steps satisfying the minimum distance constraint.

          2. Shuffle the list obtained in the first step



          ClearAll[f]
          f[m_, n_, d_] /; n d <= m := RandomSample @ Rest @
          FoldList[RandomChoice[Range[# + Boole[#2 > 1] d, m - (n - #2) d]] &, 1, Range[n]]


          Examples:



          Table[f[10, 3, 2], 5]



          8, 3, 6, 6, 10, 8, 8, 5, 10, 8, 10, 6, 10, 1, 4




          Min[Differences@Sort@#] & /@ %



          2, 2, 2, 2, 3




          f[10, 4, 3]



          f[10, 4, 3] (* impossible *)




          f[1000, 100, 8]



          848, 808, 189, 776, 680, 824, 472, 728, 352, 976, 736, 544, 504,
          936, 904, 408, 720, 400, 816, 448, 856, 560, 279, 336, 312, 512, 888,
          928, 424, 944, 584, 480, 238, 552, 920, 568, 528, 600, 952, 304, 536,
          688, 632, 712, 992, 592, 616, 221, 896, 456, 864, 344, 792, 744, 392,
          624, 320, 984, 576, 206, 648, 960, 368, 840, 872, 376, 328, 752, 832,
          24, 288, 640, 416, 1000, 760, 696, 520, 488, 672, 464, 249, 800, 968,
          768, 664, 432, 384, 784, 271, 912, 296, 656, 704, 496, 608, 230, 880,
          360, 257, 440




          Min @ Differences@ Sort @ %



          8




          res = f[10000000, 10000, 800]; // AbsoluteTiming // First



          0.105936




          Min @ Differences @ Sort @ res



          800




          Update: An alternative implementation using NestList:



          ClearAll[f2]
          f2[m_, n_, d_] /; n d <= m := Module[k = 1, RandomSample @ Rest @
          NestList[RandomChoice[Range[# + Boole[k++ > 1] d, m - (n - k) d]] &, 1, n]]





          share|improve this answer











          $endgroup$



          1. Construct a random sample from Range[m] satisfying the minimum
            distance requirements taking into account the fact that if $x_k$ is
            selected at step $k$, the choices in step $k+1$ are restricted to
            the range from $x_k + d$ to $m - (n-k)d$ to be able to get $n-k$
            additional elements in remaining steps satisfying the minimum distance constraint.

          2. Shuffle the list obtained in the first step



          ClearAll[f]
          f[m_, n_, d_] /; n d <= m := RandomSample @ Rest @
          FoldList[RandomChoice[Range[# + Boole[#2 > 1] d, m - (n - #2) d]] &, 1, Range[n]]


          Examples:



          Table[f[10, 3, 2], 5]



          8, 3, 6, 6, 10, 8, 8, 5, 10, 8, 10, 6, 10, 1, 4




          Min[Differences@Sort@#] & /@ %



          2, 2, 2, 2, 3




          f[10, 4, 3]



          f[10, 4, 3] (* impossible *)




          f[1000, 100, 8]



          848, 808, 189, 776, 680, 824, 472, 728, 352, 976, 736, 544, 504,
          936, 904, 408, 720, 400, 816, 448, 856, 560, 279, 336, 312, 512, 888,
          928, 424, 944, 584, 480, 238, 552, 920, 568, 528, 600, 952, 304, 536,
          688, 632, 712, 992, 592, 616, 221, 896, 456, 864, 344, 792, 744, 392,
          624, 320, 984, 576, 206, 648, 960, 368, 840, 872, 376, 328, 752, 832,
          24, 288, 640, 416, 1000, 760, 696, 520, 488, 672, 464, 249, 800, 968,
          768, 664, 432, 384, 784, 271, 912, 296, 656, 704, 496, 608, 230, 880,
          360, 257, 440




          Min @ Differences@ Sort @ %



          8




          res = f[10000000, 10000, 800]; // AbsoluteTiming // First



          0.105936




          Min @ Differences @ Sort @ res



          800




          Update: An alternative implementation using NestList:



          ClearAll[f2]
          f2[m_, n_, d_] /; n d <= m := Module[k = 1, RandomSample @ Rest @
          NestList[RandomChoice[Range[# + Boole[k++ > 1] d, m - (n - k) d]] &, 1, n]]






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered 7 hours ago









          kglrkglr

          204k10 gold badges233 silver badges463 bronze badges




          204k10 gold badges233 silver badges463 bronze badges























              2












              $begingroup$

              How about something like this - rather than picking random numbers until one satisfies the minimum distance criteria, pick the random number from a set that excludes disallowed values.



              gen2[m_, n_, min_] := Module[nCells, set,
              set = Range[m];
              nCells = RandomSample[set, 1];
              While[Length[nCells] < n && Length[set] > 0,
              set = Complement[set,
              Range[nCells[[-1]] - min + 1, nCells[[-1]] + min - 1]];
              If[Length[set] < 1, Print["Couldn't pick ", n],
              nCells = Join[nCells, RandomSample[set, 1]]];
              ];
              nCells]


              Table[gen2[10, 3, 2], 10] // Column
              (*
              4,7,10
              8,3,6
              2,6,9
              5,8,3
              7,10,1
              3,10,6
              3,7,10
              3,9,6
              1,10,5
              9,2,6 *)


              As noted by Henrik Schumacher in the comments, n=100, m=1000, min=8 doesn't work most of the time (you get an empty set before you pick 100 numbers):



              gen2[1000, 100, 8]
              (*
              Couldn't pick 100
              599, 14, 526, 475, 52, 448, 791, 576, 196, 711, 941, 35, 211, 483,
              371, 401, 827, 354, 757, 547, 858, 86, 222, 336, 696, 913, 419, 386,
              812, 363, 982, 974, 563, 966, 665, 279, 955, 494, 243, 675, 151, 994,
              742, 5, 298, 438, 901, 316, 24, 627, 636, 873, 411, 684, 261, 516,
              107, 586, 138, 768, 508, 290, 650, 253, 850, 116, 73, 464, 173, 163,
              129, 94, 428, 346, 842, 609, 888, 306, 619, 181, 922, 44, 555, 931,
              231, 539, 327, 731, 776, 456, 799, 64, 722, 271 *)



              But 7 is fine:



              test = gen2[1000, 100, 7]
              (*
              556, 966, 917, 863, 425, 155, 414, 504, 43, 82, 395, 196, 765, 701,
              55, 330, 935, 626, 337, 843, 511, 885, 441, 834, 756, 117, 572, 285,
              519, 17, 189, 658, 563, 817, 266, 727, 28, 854, 805, 747, 775, 210,
              997, 546, 138, 303, 608, 295, 900, 145, 718, 355, 176, 666, 130, 946,
              259, 102, 405, 795, 452, 649, 480, 591, 240, 363, 63, 641, 95, 694,
              493, 221, 536, 978, 633, 784, 739, 387, 871, 827, 675, 465, 10, 954,
              580, 599, 686, 878, 36, 1, 926, 373, 320, 529, 348, 248, 708, 893,
              311, 273 *)


              Test the minimum distance between numbers:



              stest = Sort[test];
              Min[Table[stest[[i]] - stest[[i - 1]], i, 2, Length[test]]]
              (* 7 *)
              ```





              share|improve this answer









              $endgroup$

















                2












                $begingroup$

                How about something like this - rather than picking random numbers until one satisfies the minimum distance criteria, pick the random number from a set that excludes disallowed values.



                gen2[m_, n_, min_] := Module[nCells, set,
                set = Range[m];
                nCells = RandomSample[set, 1];
                While[Length[nCells] < n && Length[set] > 0,
                set = Complement[set,
                Range[nCells[[-1]] - min + 1, nCells[[-1]] + min - 1]];
                If[Length[set] < 1, Print["Couldn't pick ", n],
                nCells = Join[nCells, RandomSample[set, 1]]];
                ];
                nCells]


                Table[gen2[10, 3, 2], 10] // Column
                (*
                4,7,10
                8,3,6
                2,6,9
                5,8,3
                7,10,1
                3,10,6
                3,7,10
                3,9,6
                1,10,5
                9,2,6 *)


                As noted by Henrik Schumacher in the comments, n=100, m=1000, min=8 doesn't work most of the time (you get an empty set before you pick 100 numbers):



                gen2[1000, 100, 8]
                (*
                Couldn't pick 100
                599, 14, 526, 475, 52, 448, 791, 576, 196, 711, 941, 35, 211, 483,
                371, 401, 827, 354, 757, 547, 858, 86, 222, 336, 696, 913, 419, 386,
                812, 363, 982, 974, 563, 966, 665, 279, 955, 494, 243, 675, 151, 994,
                742, 5, 298, 438, 901, 316, 24, 627, 636, 873, 411, 684, 261, 516,
                107, 586, 138, 768, 508, 290, 650, 253, 850, 116, 73, 464, 173, 163,
                129, 94, 428, 346, 842, 609, 888, 306, 619, 181, 922, 44, 555, 931,
                231, 539, 327, 731, 776, 456, 799, 64, 722, 271 *)



                But 7 is fine:



                test = gen2[1000, 100, 7]
                (*
                556, 966, 917, 863, 425, 155, 414, 504, 43, 82, 395, 196, 765, 701,
                55, 330, 935, 626, 337, 843, 511, 885, 441, 834, 756, 117, 572, 285,
                519, 17, 189, 658, 563, 817, 266, 727, 28, 854, 805, 747, 775, 210,
                997, 546, 138, 303, 608, 295, 900, 145, 718, 355, 176, 666, 130, 946,
                259, 102, 405, 795, 452, 649, 480, 591, 240, 363, 63, 641, 95, 694,
                493, 221, 536, 978, 633, 784, 739, 387, 871, 827, 675, 465, 10, 954,
                580, 599, 686, 878, 36, 1, 926, 373, 320, 529, 348, 248, 708, 893,
                311, 273 *)


                Test the minimum distance between numbers:



                stest = Sort[test];
                Min[Table[stest[[i]] - stest[[i - 1]], i, 2, Length[test]]]
                (* 7 *)
                ```





                share|improve this answer









                $endgroup$















                  2












                  2








                  2





                  $begingroup$

                  How about something like this - rather than picking random numbers until one satisfies the minimum distance criteria, pick the random number from a set that excludes disallowed values.



                  gen2[m_, n_, min_] := Module[nCells, set,
                  set = Range[m];
                  nCells = RandomSample[set, 1];
                  While[Length[nCells] < n && Length[set] > 0,
                  set = Complement[set,
                  Range[nCells[[-1]] - min + 1, nCells[[-1]] + min - 1]];
                  If[Length[set] < 1, Print["Couldn't pick ", n],
                  nCells = Join[nCells, RandomSample[set, 1]]];
                  ];
                  nCells]


                  Table[gen2[10, 3, 2], 10] // Column
                  (*
                  4,7,10
                  8,3,6
                  2,6,9
                  5,8,3
                  7,10,1
                  3,10,6
                  3,7,10
                  3,9,6
                  1,10,5
                  9,2,6 *)


                  As noted by Henrik Schumacher in the comments, n=100, m=1000, min=8 doesn't work most of the time (you get an empty set before you pick 100 numbers):



                  gen2[1000, 100, 8]
                  (*
                  Couldn't pick 100
                  599, 14, 526, 475, 52, 448, 791, 576, 196, 711, 941, 35, 211, 483,
                  371, 401, 827, 354, 757, 547, 858, 86, 222, 336, 696, 913, 419, 386,
                  812, 363, 982, 974, 563, 966, 665, 279, 955, 494, 243, 675, 151, 994,
                  742, 5, 298, 438, 901, 316, 24, 627, 636, 873, 411, 684, 261, 516,
                  107, 586, 138, 768, 508, 290, 650, 253, 850, 116, 73, 464, 173, 163,
                  129, 94, 428, 346, 842, 609, 888, 306, 619, 181, 922, 44, 555, 931,
                  231, 539, 327, 731, 776, 456, 799, 64, 722, 271 *)



                  But 7 is fine:



                  test = gen2[1000, 100, 7]
                  (*
                  556, 966, 917, 863, 425, 155, 414, 504, 43, 82, 395, 196, 765, 701,
                  55, 330, 935, 626, 337, 843, 511, 885, 441, 834, 756, 117, 572, 285,
                  519, 17, 189, 658, 563, 817, 266, 727, 28, 854, 805, 747, 775, 210,
                  997, 546, 138, 303, 608, 295, 900, 145, 718, 355, 176, 666, 130, 946,
                  259, 102, 405, 795, 452, 649, 480, 591, 240, 363, 63, 641, 95, 694,
                  493, 221, 536, 978, 633, 784, 739, 387, 871, 827, 675, 465, 10, 954,
                  580, 599, 686, 878, 36, 1, 926, 373, 320, 529, 348, 248, 708, 893,
                  311, 273 *)


                  Test the minimum distance between numbers:



                  stest = Sort[test];
                  Min[Table[stest[[i]] - stest[[i - 1]], i, 2, Length[test]]]
                  (* 7 *)
                  ```





                  share|improve this answer









                  $endgroup$



                  How about something like this - rather than picking random numbers until one satisfies the minimum distance criteria, pick the random number from a set that excludes disallowed values.



                  gen2[m_, n_, min_] := Module[nCells, set,
                  set = Range[m];
                  nCells = RandomSample[set, 1];
                  While[Length[nCells] < n && Length[set] > 0,
                  set = Complement[set,
                  Range[nCells[[-1]] - min + 1, nCells[[-1]] + min - 1]];
                  If[Length[set] < 1, Print["Couldn't pick ", n],
                  nCells = Join[nCells, RandomSample[set, 1]]];
                  ];
                  nCells]


                  Table[gen2[10, 3, 2], 10] // Column
                  (*
                  4,7,10
                  8,3,6
                  2,6,9
                  5,8,3
                  7,10,1
                  3,10,6
                  3,7,10
                  3,9,6
                  1,10,5
                  9,2,6 *)


                  As noted by Henrik Schumacher in the comments, n=100, m=1000, min=8 doesn't work most of the time (you get an empty set before you pick 100 numbers):



                  gen2[1000, 100, 8]
                  (*
                  Couldn't pick 100
                  599, 14, 526, 475, 52, 448, 791, 576, 196, 711, 941, 35, 211, 483,
                  371, 401, 827, 354, 757, 547, 858, 86, 222, 336, 696, 913, 419, 386,
                  812, 363, 982, 974, 563, 966, 665, 279, 955, 494, 243, 675, 151, 994,
                  742, 5, 298, 438, 901, 316, 24, 627, 636, 873, 411, 684, 261, 516,
                  107, 586, 138, 768, 508, 290, 650, 253, 850, 116, 73, 464, 173, 163,
                  129, 94, 428, 346, 842, 609, 888, 306, 619, 181, 922, 44, 555, 931,
                  231, 539, 327, 731, 776, 456, 799, 64, 722, 271 *)



                  But 7 is fine:



                  test = gen2[1000, 100, 7]
                  (*
                  556, 966, 917, 863, 425, 155, 414, 504, 43, 82, 395, 196, 765, 701,
                  55, 330, 935, 626, 337, 843, 511, 885, 441, 834, 756, 117, 572, 285,
                  519, 17, 189, 658, 563, 817, 266, 727, 28, 854, 805, 747, 775, 210,
                  997, 546, 138, 303, 608, 295, 900, 145, 718, 355, 176, 666, 130, 946,
                  259, 102, 405, 795, 452, 649, 480, 591, 240, 363, 63, 641, 95, 694,
                  493, 221, 536, 978, 633, 784, 739, 387, 871, 827, 675, 465, 10, 954,
                  580, 599, 686, 878, 36, 1, 926, 373, 320, 529, 348, 248, 708, 893,
                  311, 273 *)


                  Test the minimum distance between numbers:



                  stest = Sort[test];
                  Min[Table[stest[[i]] - stest[[i - 1]], i, 2, Length[test]]]
                  (* 7 *)
                  ```






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 7 hours ago









                  MelaGoMelaGo

                  2,0361 gold badge1 silver badge7 bronze badges




                  2,0361 gold badge1 silver badge7 bronze badges




















                      Maxim Hanselowski is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      Maxim Hanselowski is a new contributor. Be nice, and check out our Code of Conduct.












                      Maxim Hanselowski is a new contributor. Be nice, and check out our Code of Conduct.











                      Maxim Hanselowski is a new contributor. Be nice, and check out our Code of Conduct.














                      Thanks for contributing an answer to Mathematica Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f201889%2fgenerating-random-numbers-that-keep-a-minimum-distance%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу

                      Israel Cuprins Etimologie | Istorie | Geografie | Politică | Demografie | Educație | Economie | Cultură | Note explicative | Note bibliografice | Bibliografie | Legături externe | Meniu de navigaresite web oficialfacebooktweeterGoogle+Instagramcanal YouTubeInstagramtextmodificaremodificarewww.technion.ac.ilnew.huji.ac.ilwww.weizmann.ac.ilwww1.biu.ac.ilenglish.tau.ac.ilwww.haifa.ac.ilin.bgu.ac.ilwww.openu.ac.ilwww.ariel.ac.ilCIA FactbookHarta Israelului"Negotiating Jerusalem," Palestine–Israel JournalThe Schizoid Nature of Modern Hebrew: A Slavic Language in Search of a Semitic Past„Arabic in Israel: an official language and a cultural bridge”„Latest Population Statistics for Israel”„Israel Population”„Tables”„Report for Selected Countries and Subjects”Human Development Report 2016: Human Development for Everyone„Distribution of family income - Gini index”The World FactbookJerusalem Law„Israel”„Israel”„Zionist Leaders: David Ben-Gurion 1886–1973”„The status of Jerusalem”„Analysis: Kadima's big plans”„Israel's Hard-Learned Lessons”„The Legacy of Undefined Borders, Tel Aviv Notes No. 40, 5 iunie 2002”„Israel Journal: A Land Without Borders”„Population”„Israel closes decade with population of 7.5 million”Time Series-DataBank„Selected Statistics on Jerusalem Day 2007 (Hebrew)”Golan belongs to Syria, Druze protestGlobal Survey 2006: Middle East Progress Amid Global Gains in FreedomWHO: Life expectancy in Israel among highest in the worldInternational Monetary Fund, World Economic Outlook Database, April 2011: Nominal GDP list of countries. Data for the year 2010.„Israel's accession to the OECD”Popular Opinion„On the Move”Hosea 12:5„Walking the Bible Timeline”„Palestine: History”„Return to Zion”An invention called 'the Jewish people' – Haaretz – Israel NewsoriginalJewish and Non-Jewish Population of Palestine-Israel (1517–2004)ImmigrationJewishvirtuallibrary.orgChapter One: The Heralders of Zionism„The birth of modern Israel: A scrap of paper that changed history”„League of Nations: The Mandate for Palestine, 24 iulie 1922”The Population of Palestine Prior to 1948originalBackground Paper No. 47 (ST/DPI/SER.A/47)History: Foreign DominationTwo Hundred and Seventh Plenary Meeting„Israel (Labor Zionism)”Population, by Religion and Population GroupThe Suez CrisisAdolf EichmannJustice Ministry Reply to Amnesty International Report„The Interregnum”Israel Ministry of Foreign Affairs – The Palestinian National Covenant- July 1968Research on terrorism: trends, achievements & failuresThe Routledge Atlas of the Arab–Israeli conflict: The Complete History of the Struggle and the Efforts to Resolve It"George Habash, Palestinian Terrorism Tactician, Dies at 82."„1973: Arab states attack Israeli forces”Agranat Commission„Has Israel Annexed East Jerusalem?”original„After 4 Years, Intifada Still Smolders”From the End of the Cold War to 2001originalThe Oslo Accords, 1993Israel-PLO Recognition – Exchange of Letters between PM Rabin and Chairman Arafat – Sept 9- 1993Foundation for Middle East PeaceSources of Population Growth: Total Israeli Population and Settler Population, 1991–2003original„Israel marks Rabin assassination”The Wye River Memorandumoriginal„West Bank barrier route disputed, Israeli missile kills 2”"Permanent Ceasefire to Be Based on Creation Of Buffer Zone Free of Armed Personnel Other than UN, Lebanese Forces"„Hezbollah kills 8 soldiers, kidnaps two in offensive on northern border”„Olmert confirms peace talks with Syria”„Battleground Gaza: Israeli ground forces invade the strip”„IDF begins Gaza troop withdrawal, hours after ending 3-week offensive”„THE LAND: Geography and Climate”„Area of districts, sub-districts, natural regions and lakes”„Israel - Geography”„Makhteshim Country”Israel and the Palestinian Territories„Makhtesh Ramon”„The Living Dead Sea”„Temperatures reach record high in Pakistan”„Climate Extremes In Israel”Israel in figures„Deuteronom”„JNF: 240 million trees planted since 1901”„Vegetation of Israel and Neighboring Countries”Environmental Law in Israel„Executive branch”„Israel's election process explained”„The Electoral System in Israel”„Constitution for Israel”„All 120 incoming Knesset members”„Statul ISRAEL”„The Judiciary: The Court System”„Israel's high court unique in region”„Israel and the International Criminal Court: A Legal Battlefield”„Localities and population, by population group, district, sub-district and natural region”„Israel: Districts, Major Cities, Urban Localities & Metropolitan Areas”„Israel-Egypt Relations: Background & Overview of Peace Treaty”„Solana to Haaretz: New Rules of War Needed for Age of Terror”„Israel's Announcement Regarding Settlements”„United Nations Security Council Resolution 497”„Security Council resolution 478 (1980) on the status of Jerusalem”„Arabs will ask U.N. to seek razing of Israeli wall”„Olmert: Willing to trade land for peace”„Mapping Peace between Syria and Israel”„Egypt: Israel must accept the land-for-peace formula”„Israel: Age structure from 2005 to 2015”„Global, regional, and national disability-adjusted life years (DALYs) for 306 diseases and injuries and healthy life expectancy (HALE) for 188 countries, 1990–2013: quantifying the epidemiological transition”10.1016/S0140-6736(15)61340-X„World Health Statistics 2014”„Life expectancy for Israeli men world's 4th highest”„Family Structure and Well-Being Across Israel's Diverse Population”„Fertility among Jewish and Muslim Women in Israel, by Level of Religiosity, 1979-2009”„Israel leaders in birth rate, but poverty major challenge”„Ethnic Groups”„Israel's population: Over 8.5 million”„Israel - Ethnic groups”„Jews, by country of origin and age”„Minority Communities in Israel: Background & Overview”„Israel”„Language in Israel”„Selected Data from the 2011 Social Survey on Mastery of the Hebrew Language and Usage of Languages”„Religions”„5 facts about Israeli Druze, a unique religious and ethnic group”„Israël”Israel Country Study Guide„Haredi city in Negev – blessing or curse?”„New town Harish harbors hopes of being more than another Pleasantville”„List of localities, in alphabetical order”„Muncitorii români, doriți în Israel”„Prietenia româno-israeliană la nevoie se cunoaște”„The Higher Education System in Israel”„Middle East”„Academic Ranking of World Universities 2016”„Israel”„Israel”„Jewish Nobel Prize Winners”„All Nobel Prizes in Literature”„All Nobel Peace Prizes”„All Prizes in Economic Sciences”„All Nobel Prizes in Chemistry”„List of Fields Medallists”„Sakharov Prize”„Țara care și-a sfidat "destinul" și se bate umăr la umăr cu Silicon Valley”„Apple's R&D center in Israel grew to about 800 employees”„Tim Cook: Apple's Herzliya R&D center second-largest in world”„Lecții de economie de la Israel”„Land use”Israel Investment and Business GuideA Country Study: IsraelCentral Bureau of StatisticsFlorin Diaconu, „Kadima: Flexibilitate și pragmatism, dar nici un compromis în chestiuni vitale", în Revista Institutului Diplomatic Român, anul I, numărul I, semestrul I, 2006, pp. 71-72Florin Diaconu, „Likud: Dreapta israeliană constant opusă retrocedării teritoriilor cureite prin luptă în 1967", în Revista Institutului Diplomatic Român, anul I, numărul I, semestrul I, 2006, pp. 73-74MassadaIsraelul a crescut in 50 de ani cât alte state intr-un mileniuIsrael Government PortalIsraelIsraelIsraelmmmmmXX451232cb118646298(data)4027808-634110000 0004 0372 0767n7900328503691455-bb46-37e3-91d2-cb064a35ffcc1003570400564274ge1294033523775214929302638955X146498911146498911

                      Кастелфранко ди Сопра Становништво Референце Спољашње везе Мени за навигацију43°37′18″ СГШ; 11°33′32″ ИГД / 43.62156° СГШ; 11.55885° ИГД / 43.62156; 11.5588543°37′18″ СГШ; 11°33′32″ ИГД / 43.62156° СГШ; 11.55885° ИГД / 43.62156; 11.558853179688„The GeoNames geographical database”„Istituto Nazionale di Statistica”проширитиууWorldCat156923403n850174324558639-1cb14643287r(подаци)