/* From: "A SURVEY OF COMPUTATIONAL PHYSICS" by RH Landau, MJ Paez, and CC Bordeianu Copyright Princeton University Press, Princeton, 2007. Electronic Materials copyright: R Landau, Oregon State Univ, 2007; MJ Paez, Univ Antioquia, 2007; & CC Bordeianu, Univ Bucharest, 2007 Support by National Science Foundation */ // NoiseMP2.java: Power spectrum of function + noise import java.io.*; import ptolemy.plot.*; public class Noise1MP{ static final int max =1000; static double array[] = new double[max], ps[]=new double[max]; static double Autocorr[]=new double[max], twopi=2*Math.PI; static double step= 4*Math.PI/1000; public static void main(String[] argv){ double dftreal[]=new double[max], dftimag[]=new double[max]; discrete(array,max); autocorr(array); fourier(dftreal,dftimag); filter1(); } public static void fourier(double dftreal[],double dftimag[]){ double real, imag; Plot powerspec = new Plot(); int n, k; for (n = 0; n