예제 #1
0
        protected override void UpdateLevelsValues(List<List<SamplePrimitive>> primitives, MobileObservableCollection<SampleUnit> samples)
        {
            Mean = samples.Any() ? Math.Round(samples.Average(x => (double)x.SampleValue), 2) : 0;

            foreach (var sample in samples)
            {
                sample.SetUCL(UCL);
                sample.SetMean(Mean);
                sample.SetLCL(LCL);

                sample.SetUCL(ParentPanel.CustomUCL, true);
                sample.SetLCL(ParentPanel.CustomLCL, true);

                sample.SetUSL(ParentPanel.USL);
                sample.SetLSL(ParentPanel.LSL);
            }
        }
예제 #2
0
        protected override void UpdateLevelsValues(List<List<SamplePrimitive>> primitives, MobileObservableCollection<SampleUnit> samples)
        {
            var stdDevAv = samples.Any() ? Math.Round(samples.Average(x => (double)x.SampleValue), 2) : 0;

            Mean = Math.Round(stdDevAv, 3);
            UCL = Math.Round(StatisticConstants.B4(ParentPanel.SubgroupSize) * Mean, 2);
            LCL = Math.Round(StatisticConstants.B3(ParentPanel.SubgroupSize) * Mean, 2);

            foreach (var sample in samples)
            {
                sample.SetUCL(UCL);
                sample.SetMean(Mean);
                sample.SetLCL(LCL);

                sample.SetUCL(ParentPanel.CustomUCL, true);
                sample.SetLCL(ParentPanel.CustomLCL, true);

                sample.SetUSL(ParentPanel.USL);
                sample.SetLSL(ParentPanel.LSL);
            }
        }
예제 #3
0
파일: RChart.cs 프로젝트: mparsin/Elements
        protected override void UpdateLevelsValues(List<List<SamplePrimitive>> primitives, MobileObservableCollection<SampleUnit> samples)
        {
            var rValues = primitives.Select(t => t.Select(x => (double)x.SampleValue).Range()).ToList();

            Mean = samples.Any() ? Math.Round(samples.Average(x => (double)x.SampleValue), 2) : 0;

            var rBar = rValues.Any() ? rValues.Average() : 0;

            UCL = Math.Round(rBar * StatisticConstants.D4(ParentPanel.SubgroupSize), 2);
            LCL = Math.Round(rBar * StatisticConstants.D3(ParentPanel.SubgroupSize), 2);

            foreach (var sample in samples)
            {
                sample.SetUCL(UCL);
                sample.SetMean(Mean);
                sample.SetLCL(LCL);

                sample.SetUCL(ParentPanel.CustomUCL, true);
                sample.SetLCL(ParentPanel.CustomLCL, true);

                sample.SetUSL(ParentPanel.USL);
                sample.SetLSL(ParentPanel.LSL);
            }
        }
예제 #4
0
        private void ResolveLimitsCalculationMethod(List<List<SamplePrimitive>> primitives, MobileObservableCollection<SampleUnit> samples)
        {
            var allRenderedCharts = ParentPanel.Charts.Select(x => x.ChartType);

            if (allRenderedCharts.Contains(ChartTypesEnum.RChart))
            {
                var rValues = new List<double>();

                for (var i = 0; i < primitives.Count; i++)
                    rValues.Add(primitives[i].Select(x => (double)x.SampleValue).Range());

                var rBar = rValues.Any() ? rValues.Average() : 0;
                Mean = samples.Any() ? Math.Round(samples.Average(x => (double)x.SampleValue), 2) : 0;

                var a2 = StatisticConstants.A2(ParentPanel.SubgroupSize);

                UCL = Math.Round(Mean + rBar * a2, 2);
                LCL = Math.Round(Mean - rBar * a2, 2);
            }
            else if (allRenderedCharts.Contains(ChartTypesEnum.StDevChart))
            {
                var stDevList = new List<double>();
                for (var i = 0; i < primitives.Count; i++)
                {
                    var data = primitives[i].Select(x => x.SampleValue).Cast<double>();
                    var calculatedValue = data != null && data.Any() ? Math.Round(data.StdDev(), 3) : 0;
                    stDevList.Add(calculatedValue);
                }
                var stdDevAv = stDevList.Any() ? stDevList.Average() : 0;

                Mean = samples.Any() ? Math.Round(samples.Average(x => (double)x.SampleValue), 2) : 0;

                var a3 = StatisticConstants.A3(ParentPanel.SubgroupSize);

                UCL = Math.Round(Mean + stdDevAv * a3, 2);
                LCL = Math.Round(Mean - stdDevAv * a3, 2);
            }
            else if (allRenderedCharts.Contains(ChartTypesEnum.XMRChart))
            {
                var mrList = new List<double>();
                var list = primitives.SelectMany(x => x.Select(y => y.SampleValue)).Cast<double>().ToList();

                for (var i = 0; i < list.Count; i++)
                {
                    if (i >= ParentPanel.SubgroupSize - 1)
                    {
                        var data = list.GetRange(i - (ParentPanel.SubgroupSize - 1), ParentPanel.SubgroupSize);
                        var sampleValue = data != null && data.Any() ? (double?)Math.Abs(data.Max() - data.Min()) : null;
                        if (sampleValue.HasValue)
                            mrList.Add(sampleValue.Value);
                    }
                }
                var mrAv = mrList.Any() ? mrList.Average() : 0;

                Mean = samples.Any() ? Math.Round(samples.Average(x => (double)x.SampleValue), 2) : 0;

                var d2 = StatisticConstants.d2(ParentPanel.SubgroupSize);

                UCL = Math.Round(Mean + 3 * (mrAv / d2), 2);
                LCL = Math.Round(Mean - 3 * (mrAv / d2), 2);
            }
        }