Reg: Generate random integers:

Hi Experts,

Sorry to resurrect my old thread - https://forums.oracle.com/message/10928049

As Frank Kulash suggested (his last message to above thread):

As you have probably noticed, the results of discrimination 1 and 9. That's because the numbers were being rounded up or down to produce integers from 1 through 9 numbers, but none were being rounded to produce 1 and no figures have been rounded down to produce 9. A good way to use the TOWER would be

ROUND (dbms_random.value (.5, 9.5))

But surprisingly, I get even the values 1 and 9 to the query below:

SELECT ROUND (Dbms_Random.Value (1.9))

OF the double

CONNECT BY LEVEL < = 100;


Can any body please confirm the behavior?

-Nordine

(Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production)

In order to avoid discrimination against 1 and 9 as values.

If you have dbms_random.value (1.9) it can only generate 1.0000 to 8.9999 values.

The tour will convert 1.00000 - 1.49999 1 and will convert 1, 5 - 2.49999 2 and so on

until the conversion of 8.5 to 8.9999 to 9.

As you can easily see, there are more likely to get one than a one and more likely to get

a 8 to 9.

If you use 0.5 to 9.5 in your random value that stop the discrimination against 1 and 9, because now

you will get 0.5 to 1.49999 is converted to 1, etc.. The same range as 1, 5 - 2.49999 etc.

Tags: Database

Similar Questions

  • Generate random int with no recurrence

    Hi all

    I want to shuffle playlist and using random as possible to repeat some index of value as

    Generating random integers in the range 1..10.
    Generated : 9
    Generated : 3
    Generated : 3
    Generated : 9
    Generated : 4
    Generated : 1
    Generated : 3
    Generated : 9
    Generated : 10
    Generated : 10
    

    How to do it like this

    Generate random integers in the range 1.10.

    Generating random integers in the range 1..10.
    Generated : 9
    Generated : 1
    Generated : 3
    Generated : 8
    Generated : 4
    Generated : 2
    Generated : 5
    Generated : 7
    Generated : 10
    Generated : 6
    

    Please help me

    use http://www.blackberry.com/developers/docs/6.0.0api/net/rim/device/api/util/IntVector.html
    instead of vector.

    Remember that the numbers in the vector are the track numbers, you don't have to add anything unless you want to reset, you simply delete the number of the piece.

  • How to generate random numbers from 1 to 5

    How to generate random numbers from 1 to 5

    -1110340081

    Thank you I ended up

  • Creating a statue in gold that will generate random passwords for each deployment and how to recover passwords

    Hello

    New to 5.5 VDC and I hope that it is easy for you all the gurus.  After you create a statue in gold to say windows 2008 server and presentation in the public catalog how configure you to generate passwords random administrator when visitors in each of the ORG VDC wants to use it.  Now, I know you sysprep the OS in advance, and then when it starts, you can run the configuration wizard, or you can even define an answer file for things like the password key and administrator of the permit but y at - there a better way?  Having to go through the console and through a cloud of today technologies Assistant seems a bit old fashioned for me so I'm hoping its just something I missed narrowly in the configurations.

    The goal is simple... a customer deploys a VM and when it starts it is all ready to go so that no 2 VM This statue gold doesn't have the same credentials.  Somehow, they are provided with a generated random password to access the start new systems.  Amazon AWS for this using the keys if you deploy a virtual computer, you don't get invited to set a password... instead you can use your portal and get the password generated for you.  Their VM deployment and are ready to go without any additional configuration steps from the user at all.  How this is possible on a Director vcloud solution (or even at all).  I would like my customers to deploy from model, receive or access their new password and ready to go.  There may be a way to query the DB somehow and pull the password in this way?  And while I'm focused on windows operating system at the present time, it would be very happy to be able to do the same for root users on UNIX based as well as models.  Many big public cloud providers can provide their customers with this so I know there is a way but many also use things like openstack cloudstack or not vcloud Director.  Also I'm not familiar with the scripts so if you can get this kind of solution using scripts I'd appreciate some information or links that may describe step by step how to achieve and I will be happy to learn.  Thanks in advance

    UNIX systems are supposed to work.  And I know most the time they do.  (IE Redhat / Cent seems to work very well, however I have seen a few posts on this forum where a specific verion distribution may not work correctly.)

    Where to find the password.  Once the virtual machine boots (if the option to customize comments has been set at random) - the password will be on screen customization of comments; beside the selection of radio "Random."

    The API also has a way to get the password in case you need to expose in a different method.  (You can get it from section guestCustomize to a virtual computer in the restAPI thus).

  • Generate random numbers in BPEL

    I have a use case that requires I generate a random number of 2 digits, something similar to "math: random * 100. I noticed that this feature is not readily available in the SOA Composite Editor. Can anyone suggest how this can be done?

    [code]

    "targetNamespace ="http://xmlns.oracle.com/KIMServices/embedded_java/BPELProcess1"

    "xmlns ="http://schemas.xmlsoap.org/ws/2003/03/business-process/"

    "xmlns:client ="http://xmlns.oracle.com/KIMServices/embedded_java/BPELProcess1"

    "xmlns:ORA ="http://schemas.oracle.com/xpath/extension"

    "xmlns:bpelx ="http://schemas.oracle.com/bpel/extension"

    "xmlns:bpws ="http://schemas.xmlsoap.org/ws/2003/03/business-process/"

    "xmlns:bpel2 ="http://docs.oasis-open.org/wsbpel/2.0/process/executable"

    "container ="http://www.w3.org/2001/XMLSchema"

    "xmlns:XP20 ="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"

    "xmlns:oraext ="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"

    "xmlns:kimbpel ="http://xml.ibridge.nl/nl/rsg/kim/bpel"

    "xmlns:DVM ="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"

    "xmlns:HWF ="http://xmlns.oracle.com/bpel/workflow/xpath"

    "xmlns:IDS ="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"

    "xmlns:BPM ="http://xmlns.oracle.com/bpmn20/extensions"

    "xmlns:XDK ="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"

    "xmlns:XREF ="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"

    xmlns:LDAP ="http://schemas.oracle.com/xpath/extension/ldap" >. "

    Language = "java" >

    try {}

    Random random = new Random();

    int abc = random.nextInt (100);

    setVariableData ("NombrAl", abc);

    }

    end generate random number java

    [[catch (Exception e) {}]] >

    Query = "" / client: processResponse / client: result "/ >"

    [/ code]

    That should do it

  • Generating random numbers with format 18XX88YYYYY

    I've been tryig to generate random numbers with
    format 18xx88yyyyy
    here
    18, followed by two random number then 88 followed by five random number. Here 18 and 88 are set to place one, two, five and sixth position.

    but I am unable to get the logic.

    So please help


    Thanx

    Achyot

    Try this:

    SELECT    '18'
           || ROUND (DBMS_RANDOM.VALUE (1, 100))
           || '88'
           || ROUND (DBMS_RANDOM.VALUE (1, 100000))
      FROM DUAL
    

    - - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev a. (10g OCP)
    http://kamranagayev.WordPress.com

  • How to generate random curves under image control?

    Hello

    I'm still in the learning process LV my current objective is to have a circle drawn in the image optimization to move everything in the path of a curved line. The problem is that whenever I run the VI a new different trajectory is programatically created for my circle.

    I don't know how to approach this problem.

    A similar VI, I had the balls moving linearly, so I simply added a speed component to the component of the position of my balls. I initially use the same design here, but I can't devise a set of rules that would make the change in the result of the position on a trajectory of curved line. I think that generate a picture of the whole trajectory before each execution would probably work here, but I can't think a function do it either. Play with basic trig led sinusiodal or curved trajectory, but nothing really random out of period and amplitude.

    Ideally, I want as much possible variance in the path (ex: a function that could give me S, U-shaped, in the shape of spiral, loop, etc.) while maintaining control of certain parameters (length, position, max dX, etc..)

    Someone has an idea?

    Thank you!

    Looks like a random Walker.  One that I just did.  At each time point (0.1 seconds in this example), he took of the unit step in one direction, with the changing direction by a random amount within an angular range.  It can get pretty wild...

    Bob Schor

  • How LabVIEW can generate random numbers according to any pdf or histogram?

    I would like to know if there is a VI that generates a set of random numbers according to any probability density, the probability mass function or the graph histogram (this without explicitly knowing the function).

    Thank you.

    Acoustic wrote:

    I would like to know if there is a VI that generates a set of random numbers according to any probability density, the probability mass function or the graph histogram (this without explicitly knowing the function).

    If you have a given arbitrary distribution, you can simulate random data of thesholding mapping in the integral standard service with a simple random number 0... 1.

    This old post of mine should show you the General procedure and more details. (Is there even an former example). Of course, make sure that the desired function is all positive, of course.

  • Generate random data by using lookup tables

    I have 2 tables. Student_subject table contains the list of the students and they are enrolled in subjects.
    Table Subjent_mark contains valid degrees, a student can have for a topic.
    I want to generate data for all students with valid marks randomly.

    Examples of data include:


    with student_subject as
    (select '111' student_id
    'rea' subj_id
    of the double
    Union
    Select '111' student_id
    subj_id 'wri '.
    of the double
    UNION
    Select '111' student_id
    subj_id 'ss '.
    of the double
    Union
    Select '111' student_id
    "sci" subj_id
    of the double
    Union
    Select '222' student_id
    'rea' subj_id
    of the double
    Union
    Select '222' student_id
    subj_id 'wri '.
    of the double
    UNION
    Select '222' student_id
    subj_id 'ss '.
    of the double
    Union
    Select '222' student_id
    "sci" subj_id
    of the double
    Union
    Select '333' student_id
    'rea' subj_id
    of the double
    Union
    Select '333' student_id
    subj_id 'wri '.
    of the double
    UNION
    Select '333' student_id
    subj_id 'ss '.
    of the double
    Union
    Select '333' student_id
    'mus' subj_id
    of the double
    Union
    Select '444' student_id
    'rea' subj_id
    of the double
    Union
    Select '444' student_id
    subj_id 'wri '.
    of the double
    Union
    Select '444' student_id
    subj_id 'ss '.
    of the double
    Union
    Select '444' student_id
    'mus' subj_id
    of the double
    Union
    Select '444' student_id
    "sci" subj_id
    the double)
    subject_mark as
    (
    Select
    'rea' subj_id,
    ' O '
    of the double
    Union
    Select
    'rea' subj_id,
    THE OF '
    of the double
    Union
    Select
    'rea' subj_id,
    « N »
    of the double
    Union
    Select
    'rea' subj_id,
    « P »
    of the double
    Union
    Select
    subj_id "wri"
    ' O '
    of the double
    Union
    Select
    'rea' subj_id,
    THE OF '
    of the double
    Union
    Select
    'rea' subj_id,
    « N »
    of the double
    Union
    Select
    subj_id "ss."
    « A »
    of the double
    Union
    Select
    subj_id "ss."
    « B »
    of the double
    Union
    Select
    subj_id "ss."
    « C »
    of the double
    Union
    Select
    subj_id "ss."
    A '
    of the double
    Union
    Select
    subj_id "ss."
    « E »
    of the double
    Union
    Select
    "sci" subj_id,
    « A »
    of the double
    Union
    Select
    "sci" subj_id,
    « B »
    of the double
    Union
    Select
    "sci" subj_id,
    « C »
    of the double
    Union
    Select
    "sci" subj_id,
    A '
    of the double
    Union
    Select
    "sci" subj_id,
    « E »
    of the double
    Union
    Select
    'mus' subj_id,
    « A »
    of the double
    Union
    Select
    'mus' subj_id,
    « P »
    of the double
    Union
    Select
    'mus' subj_id,
    "NA".
    the double)
    SELECT * FROM subject_mark has.
    student_subject b
    where
    a.subj_id = b.subj_id

    Something like that...?

    SELECT student_id, SUBJ_ID, subj_mark
    from (
    SELECT b.student_id, b.SUBJ_ID, a.subj_mark
    , row_number() over(partition by b.student_id, b.subj_id order by dbms_random.value) as mark_num
    FROM subject_mark a, student_subject b
    WHERE a.subj_id = b.subj_id
    )
    where mark_num = 1
    order by student_id, subj_id
    ;
    STUDENT_ID SUBJ_ID SUBJ_MARK
    ---------- ------- ---------
    111        rea     O
    111        sci     A
    111        ss      D
    111        wri     O
    222        rea     P
    222        sci     D
    222        ss      B
    222        wri     O
    333        mus     A
    333        rea     P
    333        ss      C
    333        wri     O
    444        mus     A
    444        rea     N
    444        sci     B
    444        ss      E
    444        wri     O         
    
     17 rows selected 
    

    ... (assuming that you add subj_mark as an alias in your query of subject_mark)

    Kind regards
    Bob

  • Need help with a JavaScript to generate random number

    Hello

    First things first. I don't know the JavaScript J.

    When I thought about a ready to use solution to generate a random number in Captivate, I found this on a forum of LinkedIn.

    (1) add a user to your project variable, called "NombrAl". Its value can be zero.

    (2) add a text caption with ' $$randomNumber$ $"inside, to check if your script works.

    (3) add a button to the slide. Give him one on success Action to run JavaScript. Clear the check box 'continue playing the Project '.

    (4) add the following text in the button Script_Window:

    var objCP = document. Captivate;

    var rand = 1 + Math.floor (Math.random () * 10);

    onButtonClick() {} function

    objCP.cpEISetValue ('NombrAl', rand);

    }

    onButtonClick();

    However, it is (as the poster in the forum warned) for 7 Captivate does not. Can someone please help?

    I am open to all other methods to achieve the same result.

    Thanks in advance,

    Anthony

    Hi Anthony,.

    During the test, make sure that you are testing from a web server where the web address starts with http or https.  When you set the captivate variable "NombrAl" try this instead:

    objCP.cpEISetValue ('m_VarHandle.randomNumber', rand);

    This will work for the SWF output.  If you want to work for the release of HTML5 and SWF, try this code:

    window.onButtonClick = function(){
              var rand = generateRandomNumber(1, 10);
              setCpVariable('randomNumber', rand);
    
    };
    
    window.generateRandomNumber = function(min, max){
              var randomNum = 0;
    
              if(!isNaN(parseFloat(min)) && !isNaN(parseFloat(max))){
                        min = Number(min);
                        max = Number(max);
                  randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
              }
    
              return randomNum;
    };
    
    window.setCpVariable = function (cpUserVariableName, variableValue) {
              /* Check for HTML5 vs. SWF output */
              if (typeof window.cp === 'undefined') {
                        /* We have SWF output, so Get the Captivate Object */
                        var objCp = document.getElementById('Captivate');
    
                        if (objCp && objCp.cpEISetValue) {
                                  /* Set the Captivate User variable with the JavaScript variable, variableValue */
                                  objCp.cpEISetValue('m_VarHandle.' + cpUserVariableName, variableValue);
                        }
              } else {
                        /* We have HTML5 output */
                        /*If variable does not exist off of the window object, then use the variables manager*/
                        if (typeof window[cpUserVariableName] === 'undefined') {
                                  if (cp.vm && cp.vm.setVariableValue) {
                                            cp.vm.setVariableValue(cpUserVariableName, variableValue);
                                  }
                        } else {
                                  window[cpUserVariableName] = variableValue;
                        }
              }
    };
    
    window.onButtonClick();
    

    Don't forget to test this situation from a web server either local security prevents the javascript code for execution.

    Best,

    Jim Leichliter

  • Package to generate random values, based on a model

    I need to generate thousands of test strings based on a template (LLNNNNLL, where L stands for letter and N represents the numbers).
    I was able to create, on a table, any useful combination: the next step is to get that 'good' a few tickets.

    My problem is that using the following syntax I get tickets with "close to" number... just because I created using a sequence
    SELECT TICKET_CODE
    FROM TICKET_WELL SAMPLE (1) 
    WHERE OWNER = 'OWNER_NAME'
    AND rownum < 10;
    I mean: AB1001CD, AC1003CB, BB1002AD...
    while I need to get these tickets: AB1001CD, AC4667CD, SD8592GD etc...

    First question: is there a like DBMS_RANDOM package that accepts as input a boss so I can simply replace MY package to create the TICKET_WELL table?
    Second: Is there another way (right) to select a table trying to get the lines in a random order?
    Third: If both answers are not... is there a way to mix the rows of a table to another?

    Any suggestions are welcome.

    Thank you
    Marco

    Here's a function I hit upwards to generate a randon number, based on an input mask.

    create or replace
    function random_string( p_mask           in varchar2)
    return varchar2
    as
    v_random_number integer;
    v_random_letter varchar2(1);
    v_mask varchar2(20) := p_mask;
    v_character varchar2(1);
    v_random_string varchar2(20);
    begin
    for i in 1 .. length(v_mask)
    loop
    if substr(v_mask,i,1) = 'L'
    Then
        v_random_number :=  dbms_random.value(1,26);
        v_character := chr(64+v_random_number);
    elsif substr(v_mask,i,1) = 'N'
    then
       v_random_number := dbms_random.value(0,9);
       v_character     := v_random_number;
    end if;
    v_random_string := v_random_string||v_character;
    end loop;
    return v_random_string;
    end;
    

    To select lines in a random order, you need to store the random number with a column, for example rowno and create an index on rowno.

    create table random_rows
    (rowno number,
      random_string varchar2(20)
    );
    

    then to get a random line, you can use

    declare
    v_rowno integer; -- must be integer
    begin
    v_rowno := dbms_random.value(1, v_rows_in_table);
    select random_string
    into v_random_string
    from random_rows
    where rowno := v_rowno;
    end;
    

    You can also replace the random line of the next generated random_string.
    The only thing is that you can not guarantee that the random_string is unique,
    If you need a unique index on the column of random_string, and he tries to insert a duplicate, you should try to insert another random number;

  • slide show code generating random images with clickable links

    I make a slide show with images that occur randomly wch hav clickable links, OK it works but sometimes, the transition is very fast instead of the 8 s interval I expected, when I discovered the exit trace(), I noticed that sometimes the timer is triggered two times or more at the same time... my code is below... What perhaps may cause well u want to help

    I have 21 pictures with 21 images

    Import fl.transitions.Tween;

    Fl.transitions.easing import. *;

    Import fl.transitions.TweenEvent;

    import flash.events.MouseEvent;

    Stop();   slide stops

    var total_images:Number = 21;

    var my_playback_counter:Number = 0;

    showslide();     call to the showslide function

    defination function with the timer event

    function showslide (): void {}

    var myTimer:Timer = new Timer (8000);

    myTimer.addEventListener (TimerEvent.TIMER, timerListener);

    myTimer.start ();

    }

    / * function timelistener

    After 8 s, meter reading in increments of 1.

    Then reset to 0 playbckcounter if it is equal to total images

    */

    function timerListener (e:TimerEvent): void {}

    my_playback_counter = my_playback_counter + 1;

    If (my_playback_counter == total_images) {}

    my_playback_counter = 0;

    }

    trace ("Timer is triggered"); trace when the timer goes off

    NextImage();

    }

    function NextImage (): void {}

    var pic_number:Number = 21;

    var randomframe:Number = Math.ceil (Math.random () * pic_number) ;// randomly generates betwwen number 1 and 5

    trace (randomframe);

    gotoAndStop (randomframe); display a random image

    }

    Button1.addEventListener (MouseEvent.CLICK, onMouseClickB1);

    function onMouseClickB1(e:MouseEvent):void {}

    var request: URLRequest = new URLRequest ("http://www.aginternetwork.org/en/");

    navigateToURL (request, "_blank");

    }

    new Tween(btn1,"alpha",None.easeOut,0,1,1,true);

    Each time the playhead returns to frame where this code is another instance of Timer will be created.  Try to put a conditional on the showslide function call so that he will not repeat...

    var showStarted:Boolean; by assigning not it is null or false

    {if(!showStarted)}

    showslide()

    showStarted = true; but once they assign remains true

    }

  • Generate random numbers when the pdf file is opened

    I tried to write a script that generates a random 12-digit number when the PDF opens.  I need the number appears in a certain read only field on the pdf file.  I tried write the script in the script of the document and have failed.  (The number random and another part of the document will be used to extract information from it at a later date.)  Can someone help me with a script so that I can make this possible?

    Do you want a new random number whenever the file is opened? If Yes, enter

    Copy the following code as a script at the level of the document (not inside a function!):

    this.getField("fieldname").value =.

    Math.Floor (Math.Random () * Math.Pow (10,12));

  • Generate random number in a Numberic field

    Hello

    I wonder if there is a way to generate a random number in a number field or any other type?

    I am currently using LiveCycle Designer ES 8.2


    Thank you

    -Vargs

    You will need to use a javascript random function.

    For example

    var ran_number = Math.random () * 5;

    Jasmine

  • How to generate random keystrokes on AppleScript?

    I want to say my Mac to press random letters and delays at random.

    Here what I have so far:

    value validChars to {'a', 'b', 'c', '', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', "m", "n", "o", "p", "q", "r", "s", "t", "u", 'v', 'w', 'x', 'y', 'z'}

    the value randomChar to some point of validChars

    say application "TextEdit".

    activate

    end say

    delay 2.0

    say application "System events".

    strike randomChar

    strike randomChar

    delay of 2.5

    strike randomChar

    1.3 of the delay

    strike randomChar

    strike randomChar

    strike randomChar

    strike randomChar

    delay 5.0

    strike randomChar

    delay 0.5

    strike randomChar

    strike randomChar

    strike randomChar

    strike randomChar

    delay of 1.7

    strike randomChar

    strike randomChar

    strike randomChar

    strike randomChar

    3.2 the delay

    strike randomChar

    strike randomChar

    strike randomChar

    strike randomChar

    delay 7.0

    strike randomChar

    strike randomChar

    delay 1.2

    strike randomChar

    strike randomChar

    end say

    But that only raises the same randomness each keystroke, while I'm after a different character to each keystroke.

    Any help appreciated.


    You set only randomChar once. You would need to change this quickly on the key.

Maybe you are looking for