Exemple #1
0
        public KetQuaUocLuong UocLuong(KieuUocLuong kieuUL, double alpha = 0.0, double xichma = double.MinValue)
        {
            KetQuaUocLuong kq = new KetQuaUocLuong();

            kq.kieuUL = kieuUL;

            string tam = null; // chuoi tao ket qua cho KetQuaULMoiNhat dung de xuat ra file

            switch (kieuUL)
            {
            case KieuUocLuong.Diem:
                kq.giatriULDiem = this.KyVong;

                tam = string.Format("uld\n{0:f4}", kq.giatriULDiem);
                break;

            case KieuUocLuong.Khoang:
                tam = string.Format("ulk {0}", alpha);
                if (xichma != double.MinValue)
                {
                    double gtToiHanU = GiaTriToiHan.LayGiaTriU(alpha / 2);
                    kq.giatriDauKhoang  = this.KyVong - gtToiHanU * xichma / Math.Sqrt(this.CoMau);
                    kq.giatriCuoiKhoang = this.KyVong + gtToiHanU * xichma / Math.Sqrt(this.CoMau);

                    tam += string.Format(" {0}", xichma);
                }
                else
                {
                    double gtToiHanT = GiaTriToiHan.LayGiaTriT(alpha / 2, this.CoMau - 1);
                    kq.giatriDauKhoang  = this.KyVong - gtToiHanT * this.PhuongSai / Math.Sqrt(this.CoMau - 1);
                    kq.giatriCuoiKhoang = this.KyVong + gtToiHanT * this.PhuongSai / Math.Sqrt(this.CoMau - 1);
                }
                tam += string.Format("\n{0:f4} {1:f4}", kq.giatriDauKhoang, kq.giatriCuoiKhoang);
                break;
            }
            KetQuaULMoiNhat = tam;

            return(kq);
        }
Exemple #2
0
        public KetQuaKiemDinh KiemDinh(KieuGiaThiet kieuGT, double muy0 = 0.0, double alpha = 0.0, double xichma = double.MinValue)
        {
            KetQuaKiemDinh kq = new KetQuaKiemDinh();

            kq.kieuGT = kieuGT;

            string tam; // xu ly chuoi cho KetQuaKDMoiNhat

            tam = string.Format("{0} {1}", kieuGT, alpha);

            double gtToiHan;

            if (xichma != double.MinValue)
            { // truong hop da biet phuong sai tong the
                // tinh U
                kq.tieuchuanKD = (this.KyVong - muy0) * Math.Sqrt(this.CoMau) / Math.Sqrt(xichma);
                gtToiHan       = GiaTriToiHan.LayGiaTriU(alpha / 2);

                tam += string.Format(" {0}", xichma);
            }
            else
            { // truong hop chua biet phuong sai tong the
                // tinh T
                kq.tieuchuanKD = (this.KyVong - muy0) * Math.Sqrt(this.CoMau) / Math.Sqrt(this.PhuongSai);
                gtToiHan       = GiaTriToiHan.LayGiaTriT(alpha / 2, this.CoMau - 1);
            }
            tam += string.Format("\n{0:f4}", kq.tieuchuanKD);

            kq.kqKD = KieuKetQuaKiemDinh.KhongBacBo;
            switch (kieuGT)
            {
            case KieuGiaThiet.Khac:
                kq.cantren = -gtToiHan;
                kq.canduoi = gtToiHan;
                if (kq.tieuchuanKD < kq.cantren || kq.tieuchuanKD > kq.canduoi)
                {
                    kq.kqKD = KieuKetQuaKiemDinh.BacBo;
                }

                tam += string.Format("\n{0:f4} {1:f4}", kq.cantren, kq.canduoi);
                break;

            case KieuGiaThiet.LonHon:
                kq.cantren = double.MinValue;
                kq.canduoi = gtToiHan;
                if (kq.tieuchuanKD > kq.canduoi)
                {
                    kq.kqKD = KieuKetQuaKiemDinh.BacBo;
                }

                tam += string.Format("\n{0:f4}", kq.canduoi);
                break;

            case KieuGiaThiet.NhoHon:
                kq.cantren = -gtToiHan;
                kq.canduoi = double.MaxValue;
                if (kq.tieuchuanKD < kq.cantren)
                {
                    kq.kqKD = KieuKetQuaKiemDinh.BacBo;
                }

                tam += string.Format("\n{0:f4}", kq.cantren);
                break;
            }
            tam += string.Format("\n{0}", kq.kqKD);

            KetQuaKDMoiNhat = tam;

            return(kq);
        }