XbarS and SChart

The XbarS class plots the mean of each sample as well as control limits computed using the mean of the in-sample standard deviations. The positions of the control limits are determined by the equations

 

 

 

where  is the grand mean, the average of all the observations.

The factor of three in the above equations can be changed by setting the chart attribute ControlLimit. The attribute applies similarly to all of the control charts.

XbarS Example

The process of forging piston rings for automobile engines was monitored. The inside diameters of 25 samples, each containing 5 piston rings, were measured. The center line is at 74.001, the average diameter of all of the measured piston rings. The upper and lower control limits are determined by the average of the standard deviations of the 25 samples of 5 rings (Montgomery 215).

(Download Code)

 

import com.imsl.chart.*;

import com.imsl.chart.qc.*;

 

public class SampleXbarS extends JFrameChart {

    static final double diameter[][] = {

        {74.03, 74.002, 74.019, 73.992, 74.008},

        {73.995, 73.992, 74.001, 74.011, 74.004},

        {73.988, 74.024, 74.021, 74.005, 74.002},

        {74.002, 73.996, 73.993, 74.015, 74.009},

        {73.992, 74.007, 74.015, 73.989, 74.014},

        {74.009, 73.994, 73.997, 73.985, 73.993},

        {73.995, 74.006, 73.994, 74, 74.005},

        {73.985, 74.003, 73.993, 74.015, 73.988},

        {74.008, 73.995, 74.009, 74.005, 74.004},

        {73.998, 74, 73.99, 74.007, 73.995},

        {73.994, 73.998, 73.994, 73.995, 73.99},

        {74.004, 74, 74.007, 74, 73.996},

        {73.983, 74.002, 73.998, 73.997, 74.012},

        {74.006, 73.967, 73.994, 74, 73.984},

        {74.012, 74.014, 73.998, 73.999, 74.007},

        {74, 73.984, 74.005, 73.998, 73.996},

        {73.994, 74.012, 73.986, 74.005, 74.007},

        {74.006, 74.01, 74.018, 74.003, 74},

        {73.984, 74.002, 74.003, 74.005, 73.997},

        {74, 74.01, 74.013, 74.02, 74.003},

        {73.982, 74.001, 74.015, 74.005, 73.996},

        {74.004, 73.999, 73.99, 74.006, 74.009},

        {74.01, 73.989, 73.99, 74.009, 74.014},

        {74.015, 74.008, 73.993, 74, 74.01},

        {73.982, 73.984, 73.995, 74.017, 74.013}

    }; 

   

    public SampleXbarS() {

        Chart chart = getChart();

        AxisXY axis = new AxisXY(chart);

        XbarS xbars = new XbarS(axis, diameter);

 

        xbars.getUpperControlLimit().setTitle("ucl = {0,number,0.0000}");

       

        axis.getAxisX().getAxisTitle().setTitle("Sample Number");

        axis.getAxisX().getAxisLabel().setTextFormat("0");

        axis.getAxisY().getAxisTitle().setTitle("Piston Ring Diameter");

        axis.getAxisY().setAutoscaleInput(axis.AUTOSCALE_OFF);

        axis.getAxisY().setWindow(73.985, 74.015);

    }

   

   

    public static void main(String argv[]) {

        new SampleXbarS().setVisible(true);

    }

}

 

 

SampleXbarS

The SChart plots the in-sample standard deviations of the observations as well as control limits computed using

 

 

 

The factor  is such that  is an unbiased estimator of standard deviation.

SChart Example

This example uses the same piston ring data as was used in XbarS, but now the standard deviations of the samples are plotted. The center line is at 0.009, the average of the sample standard deviations.

(Download Code)

 

import com.imsl.chart.*;

import com.imsl.chart.qc.*;

import javax.swing.JFrame;

 

public class SampleSChart extends JFrameChart {   

    public SampleSChart() {

        Chart chart = getChart();

        AxisXY axis = new AxisXY(chart);

        SChart schart = new SChart(axis, SampleXbarS.diameter);

       

        schart.getUpperControlLimit().setTitle("ucl = {0,number,0.0000}");

       

        axis.getAxisX().getAxisTitle().setTitle("Sample Number");

        axis.getAxisX().getAxisLabel().setTextFormat("0");

        String title = "Standard Deviations of Piston Ring Diameters";

        axis.getAxisY().getAxisTitle().setTitle(title);

        axis.getAxisY().getAxisLabel().setTextFormat("0.000");

        axis.getAxisY().setAutoscaleInput(axis.AUTOSCALE_OFF);

        axis.getAxisY().setWindow(0.0, 0.02);

    }

   

    public static void main(String argv[]) {

        new SampleSChart().setVisible(true);

    }

}

 

SampleSChart

 

Often the XbarS and SChart are plotted together. The XbarS class contains the static method createCharts, which creates this pair of plots on a single chart.

XbarSCombo Example

This example combines the charts in XbarS and SChart. The Viewport attribute of each is set so that they can appear on the same chart.

(Download Code)

 

import com.imsl.chart.*;

import com.imsl.chart.qc.*;

 

public class SampleXbarSCombo extends JFrameChart {   

    public SampleXbarSCombo() {

        Chart chart = getChart();

        ShewhartControlChart charts[] =

            XbarS.createCharts(chart, SampleXbarS.diameter);

       

        AxisXY axis = (AxisXY)(charts[0].getAxis());

        axis.getAxisY().setAutoscaleInput(axis.AUTOSCALE_OFF);

        axis.getAxisY().setWindow(73.985, 74.015);

       

        axis = (AxisXY)(charts[1].getAxis());

        axis.getAxisY().getAxisLabel().setTextFormat("0.000");

        axis.getAxisY().setAutoscaleInput(axis.AUTOSCALE_OFF);

        axis.getAxisY().setWindow(0.0, 0.02);

        String title = "ucl = {0,number,0.0000}";

        ((SChart)charts[1]).getUpperControlLimit().setTitle(title);

    }

   

   

    public static void main(String argv[]) {

        new SampleXbarSCombo().setVisible(true);

    }

}

 

SampleXbarSCombo.png

XbarSUnequal Example

The example again uses the piston ring data, but now the sample size is not uni­form. The upper and lower control limits are now stair step lines. The control limits are farther apart for smaller samples.

It is also possible to plot just the XbarS or SChart with unequal sample sizes.

(Download Code)

 

import com.imsl.chart.*;

import com.imsl.chart.qc.*;

 

public class SampleXbarSUnequal extends JFrameChart {

 

    static final double diameter[][] = {

        {74.03, 74.002, 74.019, 73.992, 74.008},

        {73.995, 73.992, 74.001},

        {73.988, 74.024, 74.021, 74.005, 74.002},

        {74.002, 73.996, 73.993, 74.015, 74.009},

        {73.992, 74.007, 74.015, 73.989, 74.014},

        {74.009, 73.994, 73.997, 73.985},

        {73.995, 74.006, 73.994, 74},

        {73.985, 74.003, 73.993, 74.015, 73.988},

        {74.008, 73.995, 74.009, 74.005},

        {73.998, 74, 73.99, 74.007, 73.995},

        {73.994, 73.998, 73.994, 73.995, 73.99},

        {74.004, 74, 74.007, 74, 73.996},

        {73.983, 74.002, 73.998},

        {74.006, 73.967, 73.994, 74, 73.984},

        {74.012, 74.014, 73.998},

        {74, 73.984, 74.005, 73.998, 73.996},

        {73.994, 74.012, 73.986, 74.005},

        {74.006, 74.01, 74.018, 74.003, 74},

        {73.984, 74.002, 74.003, 74.005, 73.997},

        {74, 74.01, 74.013},

        {73.982, 74.001, 74.015, 74.005, 73.996},

        {74.004, 73.999, 73.99, 74.006, 74.009},

        {74.01, 73.989, 73.99, 74.009, 74.014},

        {74.015, 74.008, 73.993, 74, 74.01},

        {73.982, 73.984, 73.995, 74.017, 74.013}

    };

 

    public SampleXbarSUnequal() {

        Chart chart = getChart();

        ShewhartControlChart charts[] = XbarS.createCharts(chart, diameter);

        AxisXY axis = (AxisXY) (charts[0].getAxis());

        axis.getAxisY().setAutoscaleInput(Axis.AUTOSCALE_OFF);

        axis.getAxisY().setWindow(73.980, 74.020);

        String uclTitle = "ucl = {0,number,0.0000}";

        ((SChart) charts[1]).getUpperControlLimit().setTitle(uclTitle);

    }

 

    public static void main(String argv[]) {

        new SampleXbarSUnequal().setVisible(true);

    }

}

 

 

SampleXbarSCombo.tif



Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260