spc-rs

Crates.iospc-rs
lib.rsspc-rs
version
sourcesrc
created_at2024-12-04 22:43:09.427691
updated_at2024-12-06 22:09:03.964925
descriptionA Rust Implementation of SPC (Statistical Process Control)
homepagehttps://github.com/CrayfishGo/spc.git
repository
max_upload_size
id1472618
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`
size0
(CrayfishGo)

documentation

https://docs.rs/spc-rs/

README

spc

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.

Group Statistics

Support folwing charts:

  • Xbar-R Chart

  • Xbar-S Chart

  • R Chart

  • S Chart

Attribute Statistics

Support folwing charts:

  • P Chart
  • NP Chart
  • C Chart
  • U Chart

Moving Statistics

Support folwing charts:

  • Individuals Chart

  • Moving Range Chart

  • Moving Average Chart

How to choose an appropriate control chart

img.png

SPC Rule

  • Rule1Beyond3Sigma image-20241205130847842
  • Rule2Of3Beyond2Sigma image-20241205131508536
  • Rule4Of5Beyond1Sigma image-20241205131638701
  • Rule8PointsAboveOrBelowCenter image-20241205131728167
  • Rule9PointsOnSameSideOfCenter image-20241205131021531
  • Rule14PointsOscillating image-20241205131354714
  • Rule15PointsWithin1Sigma image-20241205131802239
  • Rule6PointsUpOrDown image-20241205132213056

Examples

    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);
        
    }


Commit count: 0

cargo fmt