I need to generate random floating numbers between 0 and 1 in the field of attribute table for ArcGIS 10.3 version.
2 Answers
In the field calculator, show Codeblock.
In the pre-logic script code box:
import random def randnum(): return random.random()
In the expression box:
randnum()
Result in a new float
field:
-
+1 Answers that show examples and screenshots are especially helpful.– Aaron ♦Commented Jul 3, 2016 at 2:37
-
2Just importing
random
in Pre-Logic Script and addingrandom.random()
to the bottom input box yields the same result. One warning though, the field calculated should be a float or double type. Commented Oct 12, 2017 at 5:09
You can vary parameter in expression below, depending on what distribution is required:
def aRand():
return arcgis.rand("Normal 2 2")
---------------------------------------
aRand()
rnd()
, even on different feature classes, different field types, the values are always the same