I need to generate random floating numbers between 0 and 1 in the field of attribute table for ArcGIS 10.3 version.


2 Answers 2

  1. In the field calculator, show Codeblock.

  2. In the pre-logic script code box:

    import random
    def randnum():
        return random.random()
  3. In the expression box:


enter image description here

Result in a new float field:

enter image description here

  • +1 Answers that show examples and screenshots are especially helpful.
    – Aaron
    Commented Jul 3, 2016 at 2:37
  • 2
    Just importing random in Pre-Logic Script and adding random.random() to the bottom input box yields the same result. One warning though, the field calculated should be a float or double type.
    – fatih_dur
    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")



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.