Results 1 to 2 of 2
  1. #1
    rootpi is offline Member
    Join Date
    Dec 2009
    Posts
    6
    Rep Power
    0

    Default Adjusting function

    Hey, we have to make a program that adjusts a given function. First of all, we have to generate many points uniformily distributed along the [0,1] interval.
    They give us as a hint to use the

    Java Code:
    Random.nextDouble()
    to do it, but it always give us an error.

    Which is the problem?

    By the moment we have:

    Java Code:
    for (int n = 3; n < 4; n++) { 
    
                double a = 1 + (2 * n); //function to adjust.
                double[] matriuX = new double[n]; 
                double[] matriuY = new double[n]; 
    
                for (int i = 0; i < matriuX.length; i++) { 
                    double b = (Random.nextGaussian()); 
                    matriuX[i] = b;
                    System.out.println(matriuX[i]);
    
                }
            }
    Thanks!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You're calling Random#nextDouble() and Random.nextGausian() as if they were static methods called off of the Random class. They aren't, and so you must first create a Random object, and then call the method off of this object.

    BTW, what is your exact error here(it's always a good idea to post it here)? Isn't it already telling you not to call the method as a static?

Similar Threads

  1. Replies: 4
    Last Post: 01-21-2010, 06:46 PM
  2. Replies: 3
    Last Post: 12-04-2009, 04:08 PM
  3. function
    By nanna in forum New To Java
    Replies: 1
    Last Post: 11-17-2008, 10:20 PM
  4. Need help with get function
    By calicocal in forum New To Java
    Replies: 10
    Last Post: 11-09-2008, 08:59 PM
  5. Need a little help with a function!
    By Nuluvius in forum New To Java
    Replies: 3
    Last Post: 02-08-2008, 12:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •