Crates.io | spc-rs |
lib.rs | spc-rs |
version | |
source | src |
created_at | 2024-12-04 22:43:09.427691 |
updated_at | 2024-12-06 22:09:03.964925 |
description | A Rust Implementation of SPC (Statistical Process Control) |
homepage | https://github.com/CrayfishGo/spc.git |
repository | |
max_upload_size | |
id | 1472618 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
SPC (Statistical Process Control) is a method of monitoring and controlling manufacturing or business processes through statistical methods, aimed at ensuring that the process is always in a controlled state, thereby reducing variability and improving quality.
Support folwing charts:
Xbar-R Chart
Xbar-S Chart
R Chart
S Chart
Support folwing charts:
Support folwing charts:
Individuals Chart
Moving Range Chart
Moving Average Chart
use spc_rs::RoundingMode::RoundHalfUp;
use spc_rs::RoundingContext;
use spc_rs::group_stats::{GroupStats, GroupStatsChartType};
use spc_rs::{SpcRule};
pub fn main() {
let v1 = vec![
0.65, 0.75, 0.75, 0.60, 0.70, 0.60, 0.75, 0.60, 0.65, 0.60, 0.80, 0.85, 0.70, 0.65,
0.90, 0.75, 0.75, 0.75, 0.65, 0.60, 0.50, 0.60, 0.80, 0.65, 0.65,
];
let v2 = vec![
0.70, 0.85, 0.80, 0.70, 0.75, 0.75, 0.80, 0.70, 0.80, 0.70, 0.75, 0.75, 0.70, 0.70,
0.80, 0.80, 0.70, 0.70, 0.65, 0.60, 0.55, 0.80, 0.65, 0.60, 0.70,
];
let v3 = vec![
0.65, 0.75, 0.80, 0.70, 0.65, 0.75, 0.65, 0.80, 0.85, 0.60, 0.90, 0.85, 0.75, 0.85,
0.80, 0.75, 0.85, 0.60, 0.85, 0.65, 0.65, 0.65, 0.75, 0.65, 0.70,
];
let v4 = vec![
0.65, 0.85, 0.70, 0.75, 0.85, 0.85, 0.75, 0.75, 0.85, 0.80, 0.50, 0.65, 0.75, 0.75,
0.75, 0.80, 0.70, 0.70, 0.65, 0.60, 0.80, 0.65, 0.65, 0.60, 0.60,
];
let v5 = vec![
0.85, 0.65, 0.75, 0.65, 0.80, 0.70, 0.70, 0.75, 0.75, 0.65, 0.80, 0.70, 0.70, 0.60,
0.85, 0.65, 0.80, 0.60, 0.70, 0.65, 0.80, 0.75, 0.65, 0.70, 0.65,
];
let mut xbar_r_chart_stats = GroupStats::new(5, GroupStatsChartType::XbarRChart).unwrap();
xbar_r_chart_stats.set_group_count(100);
xbar_r_chart_stats.set_rounding_ctx(Some(RoundingContext::new(2, RoundHalfUp)));
for i in 0..v1.len() {
let _r = xbar_r_chart_stats
.add_data(&vec![v1[i], v2[i], v3[i], v4[i], v5[i]])
.unwrap();
}
let ucl = xbar_r_chart_stats.ucl();
let lcl = xbar_r_chart_stats.lcl();
let cl = xbar_r_chart_stats.cl();
let average = xbar_r_chart_stats.average();
let ranges = xbar_r_chart_stats.ranges();
assert_eq!(0.82, ucl);
assert_eq!(0.72, cl);
assert_eq!(0.61, lcl);
println!("average: {:?}",average);
println!("range: {:?}",ranges);
// apply spc rules
let res = xbar_r_chart_stats.apply_rule_validation(vec![
SpcRule::Rule1Beyond3Sigma(1, 3),
SpcRule::Rule2Of3Beyond2Sigma(2, 3, 2),
]);
println!("res: {:#?}", res);
}