NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package random;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.awt.Color;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

/**

/**
*
* @author lexmcdowell
*/
public class Random {

/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
int x = 1;
int y = 3;
int f = 1;
Date NewDate = new Date();
Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String s = formatter.format(NewDate);
////////////////////////////////////////////////////////////////////////////////
double Random;
double Random2;
double Random3;
int randMax = 1;
int randMax2 = 1;
int randMax3 = 1;
////////////////////////////////////////////////////////////////////////////////
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
DefaultCategoryDataset dataset3 = new DefaultCategoryDataset();
////////////////////////////////////////////////////////////////////////////////
LineNumberReader lnr = null;
try {
lnr = new LineNumberReader(new FileReader(new File("spectrum.txt")));
} catch (FileNotFoundException ex) {
Logger.getLogger(Random.class.getName()).log(Level.SEVERE, null, ex);
}
lnr.skip(Long.MAX_VALUE);
System.out.println(lnr.getLineNumber() + " lines");
//System.out.println("The Lines are: ");
System.out.println(" ");
lnr.close();

int i;
////////////////////////////////////////////////////////////////////////////////
PrintWriter writer = new PrintWriter("RandomFile.txt", "UTF-8");
writer.write(s);
writer.write(" n");
writer.close();
////////////////////////////////////////////////////////////////////////////////
PrintWriter writer2 = new PrintWriter("RandomFile2.txt", "UTF-8");
writer2.write(s);
writer2.write(" n");
writer2.close();
////////////////////////////////////////////////////////////////////////////////
PrintWriter writer3 = new PrintWriter("RandomFile3.txt", "UTF-8");
writer3.write(s);
writer3.write(" n");
writer3.close();
////////////////////////////////////////////////////////////////////////////////
try
{
String filename= "RandomFile.txt";
FileWriter fw = new FileWriter(filename,true); //the true will append the new data
BufferedReader in = new BufferedReader(new FileReader("spectrum.txt"));
for (i = 1; i <= lnr.getLineNumber(); i++) {
try {
////////////////////////////////////////////////////////////////////////////////
String str;
String pattern = "(.*)(t)";
String NewStr;
///////////////////////////////////////////////////////////////////////////////
while ((str = in.readLine()) != null) {
NewStr = str;
NewStr = NewStr.replaceFirst(pattern , "" );
System.out.println(NewStr);
fw.write(NewStr + " n");
double Str = Double.parseDouble(NewStr);
Random = ((Math.random() * Str) + 1);
dataset.setValue(Random, "Range", " " + randMax);
randMax++;
}
fw.close();
}
catch (IOException e) {
System.out.println("IOException: " + e.getMessage());
}
}
in.close();
}
catch(IOException ioe)
{
System.err.println("IOException: " + ioe.getMessage());
}

org.jfree.chart.JFreeChart chart = ChartFactory.createLineChart("Random Test 1: Spectrum", "Try", "Range", dataset, PlotOrientation.VERTICAL, false, true, false);
CategoryPlot p = chart.getCategoryPlot();
p.setRangeGridlinePaint(Color.black);
ChartFrame frame = new ChartFrame("Random Numbers Test 1", chart);
frame.setVisible(true);
frame.setSize(1000, 500);
////////////////////////////////////////////////////////////////////////////////
try
{
String filename= "RandomFile2.txt";
FileWriter fw2 = new FileWriter(filename,true); //the true will append the new data
BufferedReader in2 = new BufferedReader(new FileReader("auto.txt"));
for (i = 1; i <= lnr.getLineNumber(); i++) {
try {
////////////////////////////////////////////////////////////////////////////////
String str2;
String pattern2 = "(.*)(t)";
String NewStr2;
///////////////////////////////////////////////////////////////////////////////
while ((str2 = in2.readLine()) != null) {
NewStr2 = str2;
NewStr2 = NewStr2.replaceFirst(pattern2 , "" );
System.out.println(NewStr2);
fw2.write(NewStr2 + " n");
double IntStr2 = Double.parseDouble(NewStr2);
dataset2.setValue(IntStr2, "Range", " " + IntStr2);
randMax2++;
}
fw2.close();
}
catch (IOException e) {
}
}
in2.close();
}
catch(IOException ioe)
{
System.err.println("IOException: " + ioe.getMessage());
}
org.jfree.chart.JFreeChart chart2 = ChartFactory.createLineChart("Random Test 2: Autocorrelation", "Try", "Range", dataset2, PlotOrientation.VERTICAL, false, true, false);
CategoryPlot p2 = chart2.getCategoryPlot();
p2.setRangeGridlinePaint(Color.black);
ChartFrame frame2 = new ChartFrame("Random Numbers Test 2", chart2);
frame2.setVisible(true);
frame2.setSize(1000, 500);
////////////////////////////////////////////////////////////////////////////////
try
{
String filename= "RandomFile3.txt";
FileWriter fw3 = new FileWriter(filename,true); //the true will append the new data
BufferedReader in3 = new BufferedReader(new FileReader("cepstrum.txt"));
for (i = 1; i <= lnr.getLineNumber(); i++) {
try {
////////////////////////////////////////////////////////////////////////////////
String str3;
String pattern3 = "(.*)(t)";
String NewStr3;
////////////////////////////////////////////////////////////////////////////////
while ((str3 = in3.readLine()) != null) {
NewStr3 = str3;
NewStr3 = NewStr3.replaceFirst(pattern3 , "" );
System.out.println(NewStr3);
fw3.write(NewStr3 + " n");
double IntStr3 = Double.parseDouble(NewStr3);
Random3 = ((Math.random() * IntStr3) + 1);
dataset3.setValue(IntStr3, "Range", " " + IntStr3);
randMax3++;
}
fw3.close();
}
catch (IOException e) {
}
}
in3.close();
}
catch(IOException ioe)
{
System.err.println("IOException: " + ioe.getMessage());
}
org.jfree.chart.JFreeChart chart3 = ChartFactory.createLineChart("Random Test 3: Cepstrum", "Try", "Range", dataset3, PlotOrientation.VERTICAL, false, true, false);
CategoryPlot p3 = chart3.getCategoryPlot();
p3.setRangeGridlinePaint(Color.black);
ChartFrame frame3 = new ChartFrame("Random Numbers Test 3", chart3);
frame3.setVisible(true);
frame3.setSize(1000, 500);
////////////////////////////////////////////////////////////////////////////////
}


private static void process(String str) {
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.