<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I randomly select a number of point features and retain their attributes? in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299585#M17150</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I see what you're getting at. I was thinking of replacement within the initial sample, and you're talking about other parallel samples. It's possible that what I'm describing has a different term.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Jun 2016 18:57:51 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2016-06-01T18:57:51Z</dc:date>
    <item>
      <title>How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299569#M17134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have &amp;gt;1m points in California and I want to randomly select ~10% and retain their attributes. "Create random points" doesn't work because it is creating, not selecting. I found a python script but can't make it work. Does anyone know a way using existing tools?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 15:55:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299569#M17134</guid>
      <dc:creator>DarinJensen</dc:creator>
      <dc:date>2016-06-01T15:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299570#M17135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about adding a field and calculating a random number to it, then sorting by the new field and selecting the first 10%?&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 16:02:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299570#M17135</guid>
      <dc:creator>BillDaigle</dc:creator>
      <dc:date>2016-06-01T16:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299571#M17136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/geostatistical-analyst-toolbox/subset-features.htm"&gt;SubsetFeatures&lt;/A&gt;, however, it requires a Geostatistical Analyst license&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 16:12:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299571#M17136</guid>
      <dc:creator>SteveLynch</dc:creator>
      <dc:date>2016-06-01T16:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299572#M17137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;add a numeric integer field....&lt;/P&gt;&lt;P&gt;I prefer to use a small code block, something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import numpy as np
def rand_int():
&amp;nbsp;&amp;nbsp;&amp;nbsp; return np.random.randint(0, 10)

expression box --- &amp;gt; rand_int()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the above processes row by row, returning a random integer in the form of&lt;/P&gt;&lt;P&gt;"""&lt;/P&gt;&lt;P&gt;Return random integers from `low` (inclusive) to `high` (exclusive).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return random integers from the "discrete uniform" distribution in the&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "half-open" interval [`low`, `high`). If `high` is None (the default),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; then results are from [0, `low`).&lt;/P&gt;&lt;P&gt;"""&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = np.random.randint(0, 10, 1000000)
&amp;gt;&amp;gt;&amp;gt; b = a[a==5]
&amp;gt;&amp;gt;&amp;gt; len(b)
100247
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;which is pretty good, you get about 100,000 plus change (it will never exact) out of 1 million of the values equal to 5.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:22:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299572#M17137</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T14:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299573#M17138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have the license, using Geostatistical Analyst is definitely the most robust and statistically sound method of working with random subsets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 16:58:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299573#M17138</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-06-01T16:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299574#M17139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So easy! Made even easier by just limiting the random numbers to 10 and then selecting by attribute for one of the numbers. This is definitely a case of me overthinking when such a simple and elegant solution became obvious as soon as Bill set me on it. Thank you, sir!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:06:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299574#M17139</guid>
      <dc:creator>DarinJensen</dc:creator>
      <dc:date>2016-06-01T17:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299575#M17140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure there are some gotchas with this, but quick &amp;amp; dirty, here's how you can do it without adding a new field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; import random
... fc = 'bc_geoname' # your feature class
... arcpy.SelectLayerByAttribute_management(fc,"CLEAR_SELECTION") # clear selection to consider all features
... feature_count = int(arcpy.GetCount_management(fc).getOutput(0)) # count features
... percent = 0.10 # enter your desired percentage
... rnd_set = set([]) # create a set
... while len(rnd_set) &amp;lt; (feature_count * percent): # do until your set is full
...&amp;nbsp;&amp;nbsp;&amp;nbsp; rnd_set.add(random.randint(0,feature_count-1)) # make a random integer and try to add it to the set
... where = '"FID" in ({0})'.format(','.join(map(str,rnd_set))) # include set in SQL where clause
... arcpy.SelectLayerByAttribute_management(fc,"NEW_SELECTION",where) # select the FIDs in the set&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This runs instantly on 40,000 features, so I assume it will work for you, unless it hits some memory limit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299575#M17140</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T14:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299576#M17141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May fail depending on the location of your data.&amp;nbsp; Oracle has a limit of 1000 items inside an "IN" clause.&amp;nbsp; I'm not sure what the limits are for file gdbs or other databases.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:13:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299576#M17141</guid>
      <dc:creator>BillDaigle</dc:creator>
      <dc:date>2016-06-01T17:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299577#M17142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shapefile, ftw. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:16:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299577#M17142</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-01T17:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299578#M17143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Darren has a good point and raises another important distinction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One advantage of adding a field, is that you have 10 (in this case) samples which don't overlap and will never choose the same record, if you had to pull out several samples of about 10%.&amp;nbsp; This is sampling without replacement, for doing things like t-tests, Darren's approach should be used if you need sampling with replacement and those associated tests.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both methods have their ups and downs and one should know both.&lt;/P&gt;&lt;P&gt;It is also important to note that the random.randint, randominteger are but 2 of a bunch of a bunch of distributions you can draw from ie (beta, binomial, chisquare, f, gamma, geometric, gumbel, hypergeometric, laplace, logistic, lognormal,.... poisson, Cauchy, exponential, gamma, standard_t, uniform Weibull)&amp;nbsp; Allowing one to pull samples out for distribution testing.&lt;/P&gt;&lt;P&gt;explore&lt;/P&gt;&lt;P&gt;import numpy as np&lt;/P&gt;&lt;P&gt;dir(np.random)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:21:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299578#M17143</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-01T17:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299579#M17144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe using a set (vs. list) ensures that this is &lt;EM&gt;essentially&lt;/EM&gt; sampling without replacement, without the performance benefit of ignoring pre-selected values. Using a list would be sampling with replacement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:27:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299579#M17144</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-01T17:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299580#M17145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;set reduces sample size however, so it depends upon the sample size needed and the set that is drawn, plus the record is permanent.&lt;/P&gt;&lt;P&gt;Another way is to produce the array (potentially larger) and save the array to disk (*.npy or .npz) then draw from than by appending to a featureclass.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299580#M17145</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-01T17:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299581#M17146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not sure how that applies to my example. I'm not making 10% number of choices, I'm growing the set until it reaches 10% of the size of the feature count. The sample size has not been reduced by the set.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:36:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299581#M17146</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-01T17:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299582#M17147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In brief...amongst other things, there is sampling with replacement, sampling without replacement, producing samples, producing separate samples that can be replicated, sampling within samples and sampling from know distributions in those cases.&amp;nbsp; Too much detail for here, but &lt;A href="http://stats.stackexchange.com/" title="http://stats.stackexchange.com/"&gt;Cross Validated&lt;/A&gt; has some great threads and Bill Huber (whuber&amp;nbsp; for those that know him from the GIS days) has some quite insightful information in his threads if you are interested in statistics and its applications in GIS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 17:48:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299582#M17147</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-01T17:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299583#M17148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not trying to be too confrontational, but none of that relates to my example fitting under "sampling with replacement". Even if you technically replace the possible choices (like using random does), but ignore duplicates (like using a set does), that is still sampling without replacement (you can ignore the probability of selecting a duplicate). Maybe I'm wrong, but I'd like an explanation rather than a link to an entire stats forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe the point you're missing and I need to be explicit about is that this only works using the FID field, which is guaranteed to be unique.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 18:01:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299583#M17148</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-01T18:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299584#M17149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Darren, by producing your framework once, you can ensure that you can draw from multiple samples in a variety of ways.&amp;nbsp; That is the only point I was making.&amp;nbsp; In the case of ensuring that you don't have duplication of a record, you divide your sample into almost equal sizes (there are exact ones, but we will go with an easy one).&lt;/P&gt;&lt;P&gt;Simple case&lt;/P&gt;&lt;P&gt;I just need 10% of the sample&amp;nbsp; .. just do it once&lt;/P&gt;&lt;P&gt;I need to do it again duplicate observations doesn't matter ... use either of the two proposed methods&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need a 10%, but no duplicate observations... Your proposal requires checking that a record hasn't been selected... no biggy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's set up some scenarios:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = np.random.randint(0, 10, 1000)
&amp;gt;&amp;gt;&amp;gt; size = np.array([len(a[a==i]) for i in range(10)])
&amp;gt;&amp;gt;&amp;gt; size
array([ 93,&amp;nbsp; 99, 100, 115, 108, 115,&amp;nbsp; 86,&amp;nbsp; 93,&amp;nbsp; 94,&amp;nbsp; 97])
&amp;gt;&amp;gt;&amp;gt; size.mean()
100.0&lt;/PRE&gt;&lt;P&gt;10% sample, draw 50% from 1 of our 10 samples and 50% from another of our samples...this ensures no duplicates&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; d = np.concatenate((a[a==1][:50], a[a==3][:50]))&amp;nbsp;&amp;nbsp; # draw 50 from a==1 and a==3 or
&amp;gt;&amp;gt;&amp;gt; d
array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 3, 3, 3, 3, 3, 3, 3])&lt;/PRE&gt;&lt;P&gt;or any combination of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;np.concatenate((a[a==X][:50], a[a==Y][:50]))&amp;nbsp; # where X !=Y&amp;nbsp; lots of combinations, absolutely no duplication&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you could vary the proportions if you want as well, here is an example 3 proportions are used&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; #pull 30,60,10 out of a == 1, 3, 5 proportionally
&amp;gt;&amp;gt;&amp;gt; np.vstack((a[a==1][:30], a[a==3][60], a[a==5][10]))
9
&amp;gt;&amp;gt;&amp;gt; np.concatenate((a[a==1][:30], a[a==3][:60], a[a==5][:10]))
array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5, 5, 5, 5, 5, 5, 5, 5])
&amp;gt;&amp;gt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;Now if you want replacement, you can just replace the == with either &amp;gt;=, &amp;lt;= or combinations thereof and you can vary your proportions in both cases by changing your slices.&amp;nbsp; All of these have been for a uniform distribution, the principles also apply to other distributions as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:22:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299584#M17149</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T14:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299585#M17150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I see what you're getting at. I was thinking of replacement within the initial sample, and you're talking about other parallel samples. It's possible that what I'm describing has a different term.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 18:57:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299585#M17150</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-01T18:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299586#M17151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The terminology is not consistent among disciplines.&lt;/P&gt;&lt;P&gt;Sampling without replacement, generally means, once an observation is pulled, it is out of the selection pool and not replaced either with an other record... or if the records (aka population) is fixed, it is outta there.&amp;nbsp; So if you want to do another sample, that record is gone and you have to pull from the remainder.&lt;/P&gt;&lt;P&gt;Sampling with replacement basically means (for a finite population) a record can be selected more than once or not at all, if you draw many samples from the same number of records (population). &lt;/P&gt;&lt;P&gt;This introduces tricky stuff, if you want to compare the samples drawn from the same population and compare them... you don't want a record selected twice since it would appear in two (or more) samples.&amp;nbsp; You just want to see if randomly drawn samples (since the assigning of the 1 to 10 is the only random part) share the same characteristics.&amp;nbsp; If the samples don't have the same characteristics, then the population cannot be adequately described by a sample.&amp;nbsp; In which case, you have to draw more samples from the population, increase your population size and/or find out what is causing the differentiation in the primary variable in the first place.&amp;nbsp; Classic case... let's say precipitation in BC.&amp;nbsp; I am sure you wouldn't just take a random number of locations (say 10%) and away you go... I would venture that even taking 50% of the stations would be dicey.&amp;nbsp; So in a case like that, you might want to stratify your sample based on elevation and/or proximity to the coast and/or ad nauseum and then if you still had too many, you might want to sample from the stratified sample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So in short, the approach one takes depends on what you have to do after.&amp;nbsp; All approaches are valid, but some sampling strategies can be interesting like the varying proportions from a 10% random sample,&amp;nbsp; You can really play around with the numbers in an quasi-automated to help determine appropriate sample size, whether the population is uniform etc etc.&lt;/P&gt;&lt;P&gt;I guess we should have branched this off to a discussion :&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2016 19:16:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299586#M17151</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-06-01T19:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299587#M17152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually the Create Random Points tool does work. Just do a spatial join with your existing data and the new random points. Make sure you use your existing layer as a "Constraining Feature Class" in the creating random points tool. You could also use select by location instead of spatial join.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jun 2016 15:59:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299587#M17152</guid>
      <dc:creator>TimothyStoebner</dc:creator>
      <dc:date>2016-06-02T15:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: How can I randomly select a number of point features and retain their attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299588#M17153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe you'd never be guaranteed to get 10% of the points using this method because some of the new random points would be closest to duplicate original points, or vice versa. But perhaps you could provide an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: fitting to the previous discussion, &lt;EM&gt;this&lt;/EM&gt; would be an example of sampling with replacement. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jun 2016 16:09:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-randomly-select-a-number-of-point/m-p/299588#M17153</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-06-02T16:09:14Z</dc:date>
    </item>
  </channel>
</rss>

