/* * Created on Oct 15, 2007 by Nick * */ package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.didkovsky.portview.PVFrame; import com.softsynth.jmsl.*; import com.softsynth.jmsl.view.MusicShapeEditor; import com.softsynth.jmsl.view.PVFrameAdapter; public class GaussPlot { public static void main(String[] args) { MusicShape gaussBell = new MusicShape(16); int RESOLUTION = 100; int RANGE = 4; for (int i = 0; i < RESOLUTION * RANGE; i++) { double data[] = new double[gaussBell.dimension()]; gaussBell.add(data); } for (int j = 0; j < gaussBell.dimension(); j++) { double total = 0; double sigma = j * 0.01; gaussBell.setDimensionName(j, "sigma=" + sigma); for (int i = 0; i < 30000; i++) { double oneGauss = JMSLRandom.gauss(sigma, 0); total += oneGauss; // now scale to resolution and shift oneGauss = (oneGauss + RANGE / 2)* RESOLUTION; if (Limits.within((int)oneGauss, 0, gaussBell.size() - 1)) gaussBell.sumSet(1.0, (int) oneGauss, j); // increment the place where it hit } System.out.println("total gauss over 30000 iters " + total); } MusicShapeEditor se = new MusicShapeEditor("Gaussian Bells", 800, 400); se.addMusicShape(gaussBell); PVFrame f = new PVFrameAdapter("Close to Exit"); f.add(se.getComponent()); f.pack(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); } }