private void Calculate()
        {
            if (double.TryParse(comparerValueEntry.Text, out double comparer) &&
                double.TryParse(meanEntry.Text, out double mean) &&
                double.TryParse(deviationEntry.Text, out double deviation))
            {
                double result = 0;
                switch (NormalDistributionMode)
                {
                case NormalDistributionMode.LessThan:
                    result = Statistics.NormalDistributionDensity(comparer, deviation, mean);
                    break;

                case NormalDistributionMode.Between:
                    if (double.TryParse(optionalComparerValueEntry.Text, out double optionalComparer) &&
                        optionalComparer < comparer)
                    {
                        result = Statistics.NormalDistributionDensity(optionalComparer, comparer,
                                                                      deviation, mean);
                    }
                    break;

                case NormalDistributionMode.GreaterThan:
                    result = Statistics.NormalDistributionDensity(comparer, deviation, mean, true);
                    break;

                default:
                    result = 0;
                    break;
                }
                ResultField = result.ToString("P2");
                ResultLabel = StringTranslationExtension.Translate("PercentageLabel");
            }
        }
        public StatisticsPage()
        {
            InitializeComponent();
            var context = new StatisticsViewModel();

            BindingContext = context;

            DefaultCalculatorView defaultCalculator = CreateCalculator <DefaultCalculatorView>();

            defaultCalculator.SetBinding(DefaultCalculatorView.SampleProperty, "Sample");
            defaultCalculator.SetBinding(DefaultCalculatorView.SampleModeProperty, "SampleMode");
            NormalDistributionView normalDistribution = CreateCalculator <NormalDistributionView>();
            BinomialView           binomial           = CreateCalculator <BinomialView>();
            PoissonView            poisson            = CreateCalculator <PoissonView>();
            LinearRegressionView   linearRegression   = CreateCalculator <LinearRegressionView>();

            linearRegression.SetBinding(LinearRegressionView.SampleProperty, "Sample");
            linearRegression.SetBinding(LinearRegressionView.SampleModeProperty, "SampleMode");
            var calculators = new List <CalculatorPickerItem>
            {
                new CalculatorPickerItem
                {
                    Label      = StringTranslationExtension.Translate("BaseCalculatorLabel"),
                    Calculator = defaultCalculator
                },
                new CalculatorPickerItem
                {
                    Label      = StringTranslationExtension.Translate("NormalDistributionLabel"),
                    Calculator = normalDistribution
                },
                new CalculatorPickerItem
                {
                    Label      = "Binomial",
                    Calculator = binomial
                },
                new CalculatorPickerItem
                {
                    Label      = "Poisson",
                    Calculator = poisson
                },
                new CalculatorPickerItem
                {
                    Label      = StringTranslationExtension.Translate("LinearRegressionLabel"),
                    Calculator = linearRegression
                }
            };

            CalculatorPicker.ItemsSource   = calculators;
            CalculatorPicker.SelectedIndex = 0;
        }