Results 1 to 8 of 8
  1. #1
    nvkuriseti is offline Member
    Join Date
    Jan 2015
    Posts
    7
    Rep Power
    0

    Default Java program to generate Data along with Outliers

    I am currently concentrating on Java programming skills. Right now developing a Energy usecase in Java with Spring framework. Have business requirement to generate data along with outliers. For example, have two parameters called as min and max (centigrates). Generate a file between min and max and store in a file. Atleast need to generate 10 outliers in each 100 records. Outliers should be < min and > max. Please suggest how to write a java class with this business condition. The file should be like,

    Java Code:
    Public class DataGeneration(int min, int max)
    
    where min = 30
    max = 50
    
    UNIX_TIME_STAMP<\t>DEGREES
    98938409384389384<\t>30
    39083048938409384<\t>49
    39583980398493840<\t>-30
    90853948093849383<\t>100
    from above sample data file, it will be generating two outliers. How to create such kind of data gereration in Java class? Please suggest for further step.

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    384
    Rep Power
    11

    Default Re: Java program to generate Data along with Outliers

    Are you looking for help with how to use JAVA to generate the file?

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java program to generate Data along with Outliers

    generate 10 outliers in each 100 records
    Or 1 in 10. Use a Random number generator in the range 1 to 10 and create an outlier when the value returned is one of the 1 in 10 numbers.
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    384
    Rep Power
    11

    Default Re: Java program to generate Data along with Outliers

    Quote Originally Posted by Norm View Post
    Or 1 in 10. Use a Random number generator in the range 1 to 10 and create an outlier when the value returned is one of the 1 in 10 numbers.
    If I read the description correctly, I don't think the outliers can be hardcoded (1 to 10), they have to be based on the min and max variables.

    I'm not sure if you can directly build a RNG to generate a number outside of a range.

    I would build 4 random number generators:

    -1st RNG generatates a value between (min) and (max)

    -2nd RNG generatates a value between (min value of integer) and (min-1)

    -3rd RNG generatates a value between (max+1) and (max value of integer)

    -4th RNG generates 0 or 1

    To generate 100 numbers with 10 outliers:

    Create an arraylist to hold values (call it x for example)

    loop 100 times:
    Use RNG 1 to generate random number(add value to x)
    loop 10 times:
    Use RNG 4 to generate a 0 or 1
    If 0, use RNG 2 to produce a LOW outlier (add value to x)
    If 1, use RNG 3 to produce a HIGH outlier (add value to x)

    Use the static collections method to shuffle the ArrayList.


    Write the values out to a file.
    Last edited by sehudson; 03-04-2015 at 09:49 PM.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java program to generate Data along with Outliers

    I don't think the outliers can be hardcoded (1 to 10),
    The use of Random was to tell the program WHEN to generate an outlier. It had nothing to do with its value.
    9 of 10 times gen a good number
    1 of 10 times gen an outlier.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    384
    Rep Power
    11

    Default Re: Java program to generate Data along with Outliers

    Quote Originally Posted by Norm View Post
    The use of Random was to tell the program WHEN to generate an outlier. It had nothing to do with its value.
    9 of 10 times gen a good number
    1 of 10 times gen an outlier.
    Ok, I misunderstood.

  7. #7
    nvkuriseti is offline Member
    Join Date
    Jan 2015
    Posts
    7
    Rep Power
    0

    Default Re: Java program to generate Data along with Outliers

    Hello sehudson and Norm, thanks for your reply. Yes, I am looking exactly what explained in your thread reply. This data generation is required to produce outlier data along with valid data for my Energy usecase. I will have to construct class to generate such data and write into a file. Have idea how to generate max and min range data but no idea how to generate outliers at least 10 rows in a file.

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Java program to generate Data along with Outliers

    how to generate outliers
    Are there two groups, one lower in value than min and one higher in value than max and is there a range of values to bound each of those groups. For example the lower group's values would be from -999999999 to the min value.
    Use an instance of Random to select which group and use another Random to select the value in that group.
    See post#4
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 25
    Last Post: 04-30-2012, 05:12 PM
  2. Replies: 0
    Last Post: 04-19-2010, 07:40 PM
  3. Replies: 2
    Last Post: 02-02-2010, 04:01 PM
  4. Replies: 10
    Last Post: 08-12-2009, 05:02 PM

Tags for this Thread

Posting Permissions

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