• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
        • ABS Function
        • CMCode Function
        • CountNonSpecial Function
        • Exp Function
        • High Function
        • Inc Function
        • Int Function
        • Log Function
        • Low Function
        • Random Function
        • RandomIn Function
        • Round Function
        • Seed Function
        • Sqrt Function
        • Set Behavior SpecialValues Statement
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

RandomIn Function

Format
d = randomin(in_list);
Description
The randomin function returns a random number from a grouping of numeric values expressed as an in list. You can use the seed function to initialize the random number generation. A non-integer can appear as part of the in list, but if it is part of a range, both the low and high values of the range will be converted to integers and the function will return a uniformly distributed random integer in that range.
Return Value
The function returns a random value from the values of the in list. The function will return default if there were no applicable values to construct a group of valid numbers from which to pick a random number. If a value appears more than once in the in list, it will have a higher probability of being selected by the function.
Examples
errmsg("Random tribe code: %d", randomin(TRIBE_VS1));

errmsg("Non-continuous random number: %d", randomin(-100:-50, 50:100, 999));

errmsg("After many calls, 1.23 will be selected 75% of the time: %d", randomin(1.23, 1.23, 1.23, 8));

errmsg("Random month: %d", randomin(1:12)); // same as random(1, 12)
See also: Random Function, ValueSet.randomize Function, Seed Function