File:Np control chart.svg
From A Bunch of Idiots and Their Adventures Through Space
Jump to navigation
Jump to search
Size of this PNG preview of this SVG file: 600 × 599 pixels. Other resolutions: 240 × 240 pixels | 481 × 480 pixels | 769 × 768 pixels | 1,026 × 1,024 pixels | 2,051 × 2,048 pixels | 630 × 629 pixels.
Original file (SVG file, nominally 630 × 629 pixels, file size: 38 KB)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionNp control chart.svg |
English: Example np-chart for a process that experienced a 1.5σ drift starting at midnight. |
| Date | |
| Source | Own work |
| Author | DanielPenfield |
| SVG genesis InfoField |
Creation technique
- Simulate process observations using perl, output to file.
- Read file into R, use qcc package to render control chart.
- Save to PDF.
- Import into Inkscape, save to SVG.
Source code

This media was created with Perl (interpreted programming language first released in 1987)
Here is a listing of the source used to create this file.
Here is a listing of the source used to create this file.
Deutsch ∙ македонски ∙ English ∙ +/−
#!/usr/bin/perl -w
use strict;
use Math::Random;
my %shiftSchedule = (
"first" => { "start" => 6.00, "end" => 14.00 },
"second" => { "start" => 14.00, "end" => 22.00 },
"third" => { "start" => 22.00, "end" => 6.00 }
);
my $shift = "third"; # shift to monitor
my $inspectionRate = 1 / 2; # every 1/2 hour
my $drift = 1.5; # sigma drift to simulate
my $m = 25; # samples in control chart setup
my $target = 0.10; # fraction nonconforming target
my $p = $target;
my $n = # observations per sample
int((9 * $p * (1 - $p)) / ($drift * $p * $drift * $p) + 0.5);
my $hour;
my $i;
my $minute;
my $observation;
my $setupM = $m;
print "timestamp sample sampleSize observation phase\r\n";
for ($i = 1; $i <= $m; $i++) {
$observation = Math::Random::random_binomial(1, $n, $p);
printf " 0:00 %6d %6d %2d setup\r\n", $i, $n, $observation;
}
$m = $shiftSchedule{$shift}{"end"} - $shiftSchedule{$shift}{"start"};
if ($m < 0) {
$m += 24;
}
$m /= $inspectionRate;
for ($i = 1; $i <= $m; $i++) {
$hour = int($i * $inspectionRate + $shiftSchedule{$shift}{"start"});
if ($hour >= 24) {
$hour -= 24;
}
$minute = ($i & 0x1) ? (60 * $inspectionRate) : 0;
if ($i >= (0.25 * $m)) {
if ($i < (0.75 * $m)) {
$p = $target + ($drift * $target / (0.5 * $m)) * ($i - (0.25 * $m));
} else {
$p = $target + $drift * $target;
}
}
$observation = Math::Random::random_binomial(1, $n, $p);
printf " %2d:%02d %6d %6d %2d monitoring\r\n", $hour, $minute, $setupM + $i, $n, $observation;
}
Source code

This media was created with R (programming language for statistical analysis)
Here is a listing of the source used to create this file.
Here is a listing of the source used to create this file.
Deutsch ∙ македонски ∙ English ∙ +/−
observations <- read.table("thirdshiftfractionnonconforming.txt", TRUE)
require(qcc)
attach(observations)
# identify "observation" and "sample" columns as providing the
# observations and sample numbers
observation <- qcc.groups(observation, sample)
# number of samples in phase I ("setup")
m = length(phase[phase == "setup"]);
# we do not plot the phase I ("setup") data, so just provide a filler
setupTimestamps <- rep.int(c(""), m)
# extract the timestamps to display for the phase II ("monitoring") data
monitoringTimestamps <- as.character(timestamp[phase == "monitoring"])
# reduce to one per hour
for (i in 1:length(monitoringTimestamps)) {
minutes <- strsplit(monitoringTimestamps[[i]], ":")[[1]][[2]]
if (minutes != "00") monitoringTimestamps[[i]] <- ""
}
# extract the sample sizes
setupSampleSizes <- as.numeric(sampleSize[phase == "setup"])
monitoringSampleSizes <- as.numeric(sampleSize[phase == "monitoring"])
# plot np chart
obj <- qcc(data = observation[1:m],
type = "np",
sizes = setupSampleSizes,
newdata = observation[-(1:m)],
newsizes = monitoringSampleSizes,
labels = setupTimestamps,
newlabels = monitoringTimestamps,
axes.las = 3,
chart.all = FALSE,
title = "np chart for quality characteristic XXX",
xlab = "Sample",
ylab = "Number nonconforming")
Licensing
DanielPenfield, the copyright holder of this work, hereby publishes it under the following licences:
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported licence.
Attribution:
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the licence, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible licence as the original.
| Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation Licence, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the licence is included in the section entitled GNU Free Documentation Licence.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
You may select the licence of your choice.
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
some value
16 January 2010
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 21:48, 16 January 2010 | 630 × 629 (38 KB) | wikimediacommons>DanielPenfield | {{Information |Description={{en|1=Example en:np-chart for a process that experienced a 1.5σ drift starting at midnight.}} |Source={{own}} |Author=DanielPenfield |Date=2010-01-16 |Permission= |other_versions= }} [[Category:Co |
File usage
The following 2 pages use this file:
Retrieved from ‘https://traveller.m9s5ever.co.uk/index.php/File:Np_control_chart.svg’