import com.imsl.math.*; import com.imsl.stat.*; public class CsSmoothC2Ex1 { public static void main(String args[]) { // Set up a grid int n = 300; double x[] = new double[n]; double y[] = new double[n]; for (int k = 0; k < n; k++) { x[k] = 3. * ((double)(k)/(double)(n-1)); y[k] = 1./(.1 + Math.pow(3.*(x[k]-1.),4)); } // Seed the random number generator Random rn = new Random(); rn.setSeed(1234579); rn.setMultiplier(16807); // Contaminate the data for (int i = 0; i < n; i++) { y[i] = y[i] + 2. * rn.nextFloat() - 1.; } // Set the weights double sdev = 1./Math.sqrt(3.); double weights[] = new double[n]; for (int i = 0; i < n; i++) { weights[i] = sdev; } // Set the smoothing parameter double smpar = (double)n; // Smooth the data CsSmoothC2 cs = new CsSmoothC2(x, y, weights, smpar); double csv = cs.value(0.3010); System.out.println("The computed cubic spline value at point .3010 is " + csv); } }