How to generate random numbers with a known distribution of f(X)=(8X^2 + 1)*Exp( -X^2 )

Dear All,
I need to simulate a random number generator which can generate numbers X with the probability distribution of 
 f (X) = ( 8X^2 + 1)*Exp ( -X^2 ).
This distribution is not a common distribution.
I have searched a lot, but I still do not know how to realize it.
Any help on this topic would be highly appreciated.

Make a lookup table of the integral of your function (normalized to 1)
Use the rectangle random generator and pipe that value through the lookup table, scale it ... voila.
Greetings from Germany
Henrik
LV since v3.1
“ground” is a convenient fantasy
'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

Similar Messages

  • How to generate random numbers with a known distributi​on f(X)=(8X^2 + 1)*Exp( -X^2 ).

    I need to simulate a random number generator which can generate numbers X with the probability distribution of 
     f (X) = ( 8X^2 + 1)*Exp ( -X^2 ).
    This distribution is not a common distribution.
    I have searched a lot, but I still do not know how to realize it.
    Thanks a lot!
    Solved!
    Go to Solution.

    Don't forget to index back into the original X array for correctly scaled data. Here's a simple example (LV 8.0):
    Seems to work just fine.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    DistributionSimulation.png ‏25 KB
    DistributionSim4.vi ‏44 KB

  • How to generate random numbers from 1 to 5

    How to generate random numbers from 1 to 5   
    -1110340081
    Solved!
    Go to Solution.

    (You should not mark a post as solution unless it actually contains a solution to the original problem)
    Do you want to share your code? Did you test to make sure that all numbers equally probable?
    LabVIEW Champion . Do more with less code and in less time .

  • How to generate random numbers that doesnt contain characters?

    How do we generate random numbers in ESB ROuting Service/ XSL transformation that does not contain characters. I have been using "orcl:generate-guid()" , but it contains some characters, so, I substring it to get only numbers. I dont want to take this risk and in future, my substring itself may contain characters.
    Has anybdy tried this before?
    Thanks,

    If the goal is to have a pseudo random number then consider using the translate function to replace the occurances of the A - E characters with another digit. For example:
    translate(orcl:generate-guid(),'0123456789ABCDEF','0123456789123456')
    This will produce a 1 for A, 2 for B, etc. While not a valid hex to decimal conversion of the GUID value, it does get around the hex issue and might be sufficient for your purposes.
    I would perform a large sample test to see just how unique the values end up being.
    As for why hex is used, well GUID's are most commonly written in text as a sequence of hexadecimal digits such as: 3F2504E0-4F89-11D3-9A0C-0305E82C3301. i.e. 128 bits represented in 32 characters formatted into 5 sections.
    Hope this helps,
    Peter

  • How to generate random numbers in a range using random class?

    I know how to use Math.random for this, but how would I generate random numbers using the random class?
    Say I want a number between 40 and 50, inclusive--how would I do this?
    What i have in mind is:
    int randomNumber = random.nextInt(max) + min;
    where max is 50 and min is 40. Is this correct?

    Fredddir_Java wrote:
    I know how to use Math.random for this, but how would I generate random numbers using the random class?
    Say I want a number between 40 and 50, inclusive--how would I do this?
    What i have in mind is:
    int randomNumber = random.nextInt(max) + min;
    where max is 50 and min is 40. Is this correct?What happened when you generated a couple hundred numbers that way? Did you get all the ints in the range you wanted?

  • How to generate random objects with a click?

    Hi Guys,
    I am new to the forum so hello to you all!
    I start here with a question that doesn't leave me sleeping during the night.
    I am working on a interactive slideshow.
    That's all right, ultil now.
    Now things becomes blurry for me.
    In every page I would like to add a little animal in the lower right angle of the screen so, when u click on this animal, a baloon appears with a wroten sentence inside it.
    But, I wanto to make the sentences inside the baloon RANDOMLY different every time u click on the animal (using a selection, for example, of 30 sentences at all), but I don't really know what I have to do in order to realize my idea.
    I am not interested to create a preset cycle of sentences, but a random behavior with a click.
    any suggestion please?
    Thaks a lot and best regards!
    Theus

    As I imagined,
    I got some problems to do do that because I am new to the director use. So I can't made it working, if u cant be a little patient with me please, that's will be good!
    What I need is a more "steb by step" help if is not boring for you.
    I go to insert>control>field in order to create a field and then, after double ciking the field, I type four example sentences into the text editor that apperars, right?
    How I have to write the sentences inside the text editor in order to subdivide the text into first sentence, second sentences and so on? There is a special syntax to follow?
    I wrote these exaple sentences:
    "Triangle" "Square" "Circle" "Cube"..... As u see, I am not sure where and how I have to put the sentences in order to select them randomy
    About handlers.
    What I have to do to create an event handler?
    I created a button then i rename it ChooseRandomSentence but now I don't know what I need to do to proceed.
    Here have I to write this script?
    On ChooseRandomSentence
      global gSentenceList, gPreviousNR
      x = gSentenceList.count -- X = count sentences
      y =  random(x) -- Picks a random number from X
      repeat While y  =  gPreviousNR then -- check if number is used previous time player clicked button
          y =  random(x)
       end repeat
      put gSentenceList[y] into field "ShowSentence"  -- Shows random sentence in a field
      put y into gPreviousNR -- add number to next check
    end
    and this?
    on MouseUP
    ChooseRandomSentence
    end
    Some other questions:
    -What about letters X and Y into the exaples scripts u wrote? If I have 4 sentences, which numbers I need to use to replace X and Y?
    -I need to change sentences with  mouse clicking, and not simply moving the mouse over the sprite or the button, is MouseUP command a script about clicking or about moving over?
    As u see I am a very very beginner but I really want to learn, so hope I don't boring u with all those questions.
    Thanks again a lot
    and, If u came in Italy, there is a beer for you! cheers!!!
    Theus

  • How t generate random numbers at everytime of exceutuion of the program

    dear friends
    i am facing a problem that the random numbers generated at time of each exectuion of the program are not the same, i want to generate the same random numbers every time time i run the program. i need your help. i am giving the code in c++ if anybody can help in providing the solution so that i get the same random numbers at every run of the program. waiting for your help
    wit regards
    jaya shankar
    #include<iostream.h>
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #include<math.h>
    class density
    int s[150][150],parent[150][150],i,j,l,n,loop;
    public:
    void bd(void);
    void css(void);
    void density :: bd(void)
    cout<<"ENTER THE POPULATION SIZE = ";
    cin>>n;
    cout<<"\nENTER THE NO.OF LOOPS = ";
    cin>>loop;
    for(i=0;i<n;i++)
    for(j=0;j<80;j++)
    s[j]=rand()%2;
    cout<<"s:"<<s[j];
    void density :: css(void)
    int a,b;
    float c;
    for(i=0;i<n;i=i+2)
    b=rand()%100;
    cout<<"random b="<<b;
    main()
    density d;
    d.bd();
    d.css();

    This will help you I think.
    import java.io.*;
    import java.util.*;
    public class RandomTest
         public static void main( String arg[]) throws Exception
              Random number = new Random(100);
              for( int i = 0 ; i < 15; i++){
                   System.out.println( number.nextInt( 100 )) ;

  • How to generate random numbers in a range?

    Hello. i am having trouble finding out how to generate a random number in a certain range. For example i have an array of 100 elements and i want to access one of the elements between 50 and 60, however i cannot find how to generate a random number between these two values.
    Thanks in advance

    java.util.Random.nextInt(int)
    Note that you can get a number between 0 and (max -
    min), exclusive. Then add min, and you've got your
    number.Obviously you didn't read this. It says to get a number between 0 and (max - min) which is actually what you did. But after that you need to add min. The first step would get a number in between 0 and 5. When you add 20 you'd get a number between 0+20=20 and 5+20=25.

  • How to generate random numbers of the same at each time of execution of thm

    dear friends
    i am facing a problem that the random numbers generated at time of each exectuion of the program are not the same, i want to generate the same random numbers every time time i run the program. i need your help. i am giving the code in c++ if anybody can help in providing the solution so that i get the same random numbers at every run of the program. waiting for your help
    wit regards
    jaya shankar
    #include<iostream.h>
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #include<math.h>
    class density
    int s[150][150],parent[150][150],i,j,l,n,loop;
    public:
    void bd(void);
    void css(void);
    void density :: bd(void)
    cout<<"ENTER THE POPULATION SIZE = ";
    cin>>n;
    cout<<"\nENTER THE NO.OF LOOPS = ";
    cin>>loop;
    for(i=0;i<n;i++)
    for(j=0;j<80;j++)
    s[j]=rand()%2;
    cout<<"s:"<<s[j];
    void density :: css(void)
    int a,b;
    float c;
    for(i=0;i<n;i=i+2)
    b=rand()%100;
    cout<<"random b="<<b;
    main()
    density d;
    d.bd();
    d.css();

    Do not randomize the random number interface when you start your application. When the random number interface is not randomized when starting you get the same sequence of numbers each and every time you use it.

  • Random numbers with leading zeros

    Hi,
    I want to generate random numbers with leading zeros.
    My code so far:
    import java.util.Random;
      Random r = new Random();
      int randInt = r.nextInt(100);My aimed output is something like:
    0012 or 0123 ...
    Thanks
    Jonny

    Hi,
    sorry for not getting it with NumberFormat. I used DecmailFormat instead:
    DecimalFormat df = new DecimalFormat("0000");
    df.setMinimumIntegerDigits(4);
    df.format(r.nextInt(40)));This gave me the right output, like 0013 or 0123 ...
    Thanks
    Jonny

  • How to generate random letter?

    i know how to generate random numbers but is there anyway to generate random letters? or colors?
    thanks in advance..

    marufai wrote:
    -uj-
    as i'm new in java...can u show me how to make random number from array list?
    i tried but it seem long
    ArrayList ma = new ArrayList();
         ma.add("A");
         ma.add("B");
         ma.add("C");          
         ma.add("D");          
         ma.add("E");
         num = gen.nextInt(5);
         System.out.print("" + ma.get(num) );
    so if i wan generate btw A to Z am i suppose to type A to Z out?
    Edited by: marufai on Sep 24, 2007 12:32 PMI like uj's method since it's more extensible, even though it's a little more work up front.
    If you have a range, say A to Z, then loop over the characters in that range, adding them to the list.
            List<Character> list = new ArrayList<Character>();
            for (char index = 'A'; index <= 'Z'; index++) {
                list.add(index);
            }Do that for all of the ranges that you want to add to the possibilities, and then choose random numbers between 0 and the length of the list.

  • How to generate random sequence numbers

    Hello experts
    Iu2019m writing a custom program and pulling data from VBAK & VBAP. As per requirement I also need to generate a sequence number randomly and finally store all data in text file and upload at server. The hiccup is I donu2019t know how to generate sequence numbers. Can somebody please show me how I can accomplish it?
    Thanks a lot in advance

    Find the below code,
      data: lv_range type datatype-char0128.
      call function 'RANDOM_C'
        exporting
          len_min   = 20
          len_max   = 20
          char_min  = 1
          char_max  = 20
        importing
          rnd_value = lv_range.
    LV_RANGE param will have a random value..
    If you need number you can use the FM "RANDOM_I4"
    Thanks,
    Prathap

  • How To generate random activation code

    Hi Guys
    It might be a very simple question for most of you. I've seen many websites when you register, they send you an email with an activation code.
    It kind of looks like : XA432G2DGR343
    How do we generate something like this in Java. I know we can generate random numbers? Any tips on how to go about it.
    Thanks

    gubloo wrote:
    It might be a very simple question for most of you. I've seen many websites when you register, they send you an email with an activation code.
    How do we generate something like this in Java. So let me see if I have this straight. You are asking us to help you create a program, one that allows you randomly generate activation codes, and with these codes you will try to crack into websites where you haven't registered for or where you possibly haven't paid some entrance fee? Is this correct or am I missing some basic element of logic here? If I'm wrong, please correct my mistake. If I'm right, then you can go to h&#101;ll.

  • Need An Algorithm That Generates Random Numbers

    Hi, I understand that there is a built-in random number generator. But, I need an algorithm that generator random numbers. Is there one available? Thanks.

    Hi, is the "Seminumerical Algorithms" a book?What
    the numbers 3141592621 and 907633385 stand for?The first is PI without a decimal... the second I
    don't know, it may as well be randomly picked.As far as I know the numbers aren't randomly picked. You want the distribution to be good, and the length of the serie should also be long. Some numbers causes the cycle to be short, or the distribution to be bad. I think there are articles that lists 'good' numbers.
    /Kaj

  • Generating random numbers, while excluding some numbers

    I want to generate random numbers between 1 and 13 (including 1 and 13), while excluding numbers 6 and 9
    Please tell me theres an easy fix to this issue --

    lemme know if it compiles
    import java.util.*;
    public class RandomNumber {
    public static void main( String[] args) {
    int numWins = 0;
    for( int i = 1; i < 101; i++) {
    boolean x = true, y = true;
    int number = 0;
    while(!x && !y && number != 6 && number != 9)
    number = 1 + (int) (Math.random() % 13);
    x = number >= 1;
    y = number <= 13;
    int number2 = 0;
    while(!x && !y && number2 != 6 && number2 != 9)
    number2 = 1 + (int) (Math.random() % 13);
    x = number2 >= 1;
    y = number2 <= 13;
    int number3 = 0;
    while(!x && !y && number3 != 6 && number3 != 9)
    number3 = 1 + (int) (Math.random() % 13);
    x = number3 >= 1;
    y = number3 <= 13;
    int number4 = 0;
    while(!x && !y && number4 != 6 && number4 != 9)
    number4 = 1 + (int) (Math.random() % 13);
    x = number4 >= 1;
    y = number4 <= 13;
    int DrawAgain = 2;
    if (number == DrawAgain) {
    System.out.println( "A Random number between 1 and 10: " + number);
    System.out.println( "A second Random number between 1 and 10: " + number2);
    if (number2 == 8) {
    System.out.println( " Piece made it home successfully");
    numWins++;
    if (number2 == DrawAgain) {
    System.out.println( "A third Random number between 1 and 10: " + number3);
    if (number2 == 7) {
    System.out.println( " Piece made it home successfully");
    numWins++;
    if (number3 == DrawAgain) {
    if (number4 == 7)
    System.out.println( " Piece made it home successfully");
    numWins++;
    else {
    System.out.println( "A Random number between 1 and 10: " + number);
    if (number == 10) {
    System.out.println( " Piece made it home successfully");
    numWins++;
    System.out.println(" Number of times piece made it home successfully " + numWins);
    }

Maybe you are looking for

  • After installing 4.7 the dispatcher is getting stopped

    hi gurus, i am installing 4.7 after installation i got the message like successfully complted , when iam trying to start the MMC but the dispatcher is getting stopped please check this log - trc file: "dev_disp", trc level: 1, release: "620" Tue Jan

  • Installation of windows server 2008r2 on dell power edge 2850

    I just received an dell power edge 2850, can I install windows server 2008r2 on this unit

  • Preview in Browser - Temporary File Name

    When I preview a new form in a browser (after saving all) why does a temporary file name show in the address bar of the browser rather than the actual name?  For example instead of login.php the name displayed is TMP7zh4cs.php I haven't noticed a tem

  • Unable to import mts files

    i just updated my premiere to the latest version (cc 2014) and when i try to import mts files it gives me an error message that the file compression type is not supported. i have tried to rename the folder as well as deleting the media cache files, i

  • Moving averages

    I want to write a moving average line, in Java, consisting of a slow line and a fast line. A six-numeral address bar will be required. I don�t know which end of this beast to get hold of. Maybe some kindly soul will give me some strong clues. TIA clu