internal descriptive_stats(
            double[] data,
            descriptive_stats_encoding_options dse_options,
            string ds_group_name,
            string ds_member_name,
            bool presorted
            )
        {
            this.ds_group_name  = /*program.string_debug*/ (ds_group_name);
            this.ds_member_name = /*program.string_debug*/ (ds_member_name);


            if (data == null || data.Length == 0 || data.All(a => a == 0))
            {
                if (dse_options?.intervals != null)
                {
                    var interval_group_name  = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.intervals), this.ds_group_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    var interval_member_name = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.intervals), this.ds_member_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    intervals_descriptive_stats = new descriptive_stats(Array.Empty <double>(), dse_options?.intervals, interval_group_name, interval_member_name, presorted: true);
                }

                if (dse_options?.distances != null)
                {
                    var distance_group_name  = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.distances), this.ds_group_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    var distance_member_name = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.distances), this.ds_member_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    distances_descriptive_stats = new descriptive_stats(Array.Empty <double>(), dse_options?.distances, distance_group_name, distance_member_name, presorted: true);
                }

                if (dse_options?.interquartile != null)
                {
                    var interquartile_group_name  = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.interquartile), this.ds_group_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    var interquartile_member_name = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.interquartile), this.ds_member_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    interquartile_range_descriptive_stats = new descriptive_stats(Array.Empty <double>(), dse_options?.interquartile, interquartile_group_name, interquartile_member_name, presorted: true);
                }

                if (dse_options?.abs != null)
                {
                    var abs_group_name  = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.abs), this.ds_group_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    var abs_member_name = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.abs), this.ds_member_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    abs_descriptive_stats = new descriptive_stats(Array.Empty <double>(), dse_options?.abs, abs_group_name, abs_member_name, presorted: true);
                }

                if (dse_options?.rescale != null)
                {
                    var rescale_group_name  = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.rescale), this.ds_group_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    var rescale_member_name = /*program.string_debug*/ (string.Join(/*program.string_debug*/ ($@"_"), new string[] { nameof(dse_options.rescale), this.ds_member_name }.Where(a => !string.IsNullOrWhiteSpace(a)).ToArray()));
                    rescaled_descriptive_stats = new descriptive_stats(Array.Empty <double>(), dse_options?.rescale, rescale_group_name, rescale_member_name, presorted: true);
                }

                return;
            }

            if (data.Any(a => double.IsInfinity(a) || double.IsNaN(a)))
            {
                throw new ArgumentOutOfRangeException(nameof(data), /*program.string_debug*/ ($@""));
            }



            var sorted_data = presorted ? data : data.OrderBy(a => a).ToArray();

            if (dse_options.count || dse_options.sum || dse_options.mean_arithmetic || dse_options.dev_standard || dse_options.mad_mean_arithmetic)
            {
                count = (uint)sorted_data.Length;
            }

            if (dse_options.count_distinct_values)
            {
                count_distinct_values = (uint)sorted_data.Distinct().Count();
            }

            if (dse_options.count_non_zero_values || dse_options.count_zero_values)
            {
                count_non_zero_values = (uint)sorted_data.Count(a => a != 0);
            }

            if (dse_options.count_zero_values)
            {
                count_zero_values = (uint)sorted_data.Length - count_non_zero_values;
            }

            if (dse_options.sum || dse_options.mean_arithmetic || dse_options.dev_standard || dse_options.mad_mean_arithmetic)
            {
                sum = sorted_data.Sum();
            }

            if (dse_options.root_mean_square)
            {
                root_mean_square = rms(sorted_data);
            }

            if (dse_options.mean_arithmetic || dse_options.dev_standard || dse_options.mad_mean_arithmetic)
            {
                mean_arithmetic = count != 0 ? sum / count : 0d;
            }

            if (dse_options.mean_harmonic_corrected || /*dse_options.mean_harmonic_nonzero ||*/ dse_options.mad_mean_harmonic_corrected)
            {
                var hm = harmonic_mean(sorted_data);
                mean_harmonic_corrected = hm.corrected;
                //mean_harmonic_nonzeros = hm.nonzeros;
            }

            if (dse_options.mean_geometric_corrected || /*dse_options.mean_geometric_nonzero ||*/ dse_options.mad_mean_geometric_corrected)
            {
                var gm = geometric_mean(sorted_data);
                mean_geometric_corrected = gm.corrected;
                //mean_geometric_nonzeros = gm.nonzeros;
            }


            if (dse_options.variance || dse_options.dev_standard || dse_options.kurtosis || dse_options.skewness)
            {
                var stat = shape(sorted_data);
                variance     = stat.variance;
                dev_standard = stat.stdev;
                kurtosis     = stat.kurtosis;
                skewness     = stat.skewness;
            }

            if (dse_options.min || dse_options.range || dse_options.mid_range || dse_options.mad_mid_range)
            {
                min = sorted_data[0];
            }

            if (dse_options.max || dse_options.range || dse_options.mid_range || dse_options.mad_mid_range)
            {
                max = sorted_data[^ 1];
        private static List <(string group_id, string member_id, string perspective_id, double perspective_value)> encode(
            descriptive_stats stats,
            descriptive_stats_encoding_options dse_options,
            /*bool same_group = true,*/
            /*bool individual = true,*/
            int level = 0)
        {
            const string module_name = nameof(descriptive_stats);
            const string method_name = nameof(encode);

            var result = new List <(string group_id, string member_id, string perspective_id, double perspective_value)>();

            if (stats == null)
            {
                stats = new descriptive_stats(null, dse_options, ds_group_name: /*program.string_debug*/ ($@""), ds_member_name: /*program.string_debug*/ ($@""), presorted: true);
            }

            /*if (!same_group && !individual)
             * {
             *  throw new Exception(/*program.string_debug* /($@"{module_name}.{method_name}: {nameof(same_group)} and {nameof(individual)} both false."));
             * }*/

            if (dse_options == null)
            {
                //descriptive_stats_encoding_options = descriptive_stats_encoding_options.options_mean_arithmetic;
                throw new ArgumentOutOfRangeException(nameof(dse_options), /*program.string_debug*/ ($@""));
            }

            if (dse_options?.intervals != null && stats.intervals_descriptive_stats != null && dse_options.intervals.key_value_list().Any(a => a.value))
            {
                var encoded_intervals_descriptive_stats = stats.intervals_descriptive_stats.encode(dse_options.intervals, /*same_group, individual,*/ level + 1);

                result.AddRange(encoded_intervals_descriptive_stats);
            }

            if (dse_options?.distances != null && stats.distances_descriptive_stats != null && dse_options.distances.key_value_list().Any(a => a.value))
            {
                var encoded_distances_descriptive_stats = stats.distances_descriptive_stats.encode(dse_options.distances, /*same_group, individual,*/ level + 1);

                result.AddRange(encoded_distances_descriptive_stats);
            }

            if (dse_options?.interquartile != null && stats.interquartile_range_descriptive_stats != null && dse_options.interquartile.key_value_list().Any(a => a.value))
            {
                var encoded_interquartile_range_descriptive_stats = stats.interquartile_range_descriptive_stats.encode(dse_options.interquartile, /*same_group, individual,*/ level + 1);

                result.AddRange(encoded_interquartile_range_descriptive_stats);
            }

            if (dse_options?.abs != null && stats.abs_descriptive_stats != null && dse_options.abs.key_value_list().Any(a => a.value))
            {
                var encoded_abs_descriptive_stats = stats.abs_descriptive_stats.encode(dse_options.abs, /*same_group, individual,*/ level + 1);

                result.AddRange(encoded_abs_descriptive_stats);
            }


            if (dse_options?.rescale != null && stats.rescaled_descriptive_stats != null && dse_options.rescale.key_value_list().Any(a => a.value))
            {
                var encoded_abs_descriptive_stats = stats.rescaled_descriptive_stats.encode(dse_options.rescale, /*same_group, individual,*/ level + 1);

                result.AddRange(encoded_abs_descriptive_stats);
            }


            /*if (same_group || individual)*/
            {
                var z = new List <(string group_id, string member_id, string perspective_id, double perspective_value)>();

                if (dse_options.count)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.count)}"), (double)stats.count));
                }
                if (dse_options.count_zero_values)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.count_zero_values)}"), (double)stats.count_zero_values));
                }
                if (dse_options.count_non_zero_values)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.count_non_zero_values)}"), (double)stats.count_non_zero_values));
                }
                if (dse_options.count_distinct_values)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.count_distinct_values)}"), (double)stats.count_distinct_values));
                }
                if (dse_options.min)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.min)}"), stats.min));
                }
                if (dse_options.max)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.max)}"), stats.max));
                }
                if (dse_options.range)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.range)}"), stats.range));
                }
                if (dse_options.sum)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.sum)}"), stats.sum));
                }
                if (dse_options.mid_range)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mid_range)}"), stats.mid_range));
                }
                if (dse_options.median_q1)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.median_q1)}"), stats.median_q1));
                }
                if (dse_options.median_q2)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.median_q2)}"), stats.median_q2));
                }
                if (dse_options.median_q3)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.median_q3)}"), stats.median_q3));
                }
                if (dse_options.root_mean_square)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.root_mean_square)}"), stats.root_mean_square));
                }
                if (dse_options.mean_arithmetic)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mean_arithmetic)}"), stats.mean_arithmetic));
                }

                if (dse_options.mean_geometric_corrected)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mean_geometric_corrected)}"), stats.mean_geometric_corrected));
                }
                //if (dse_options.mean_geometric_nonzero) { z.Add((group_id: /*program.string_debug*/($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/($@"{nameof(stats.mean_geometric_nonzeros)}"), stats.mean_geometric_nonzeros)); }

                if (dse_options.mean_harmonic_corrected)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mean_harmonic_corrected)}"), stats.mean_harmonic_corrected));
                }
                //if (dse_options.mean_harmonic_nonzero) { z.Add((group_id: /*program.string_debug*/($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/($@"{nameof(stats.mean_harmonic_nonzeros)}"), stats.mean_harmonic_nonzeros)); }

                if (dse_options.variance)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.variance)}"), stats.variance));
                }
                if (dse_options.dev_standard)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.dev_standard)}"), stats.dev_standard));
                }
                if (dse_options.mad_mean_arithmetic)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mad_mean_arithmetic)}"), stats.mad_mean_arithmetic));
                }
                if (dse_options.mad_mean_harmonic_corrected)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mad_mean_harmonic_corrected)}"), stats.mad_mean_harmonic_corrected));
                }
                if (dse_options.mad_mean_geometric_corrected)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mad_mean_geometric_corrected)}"), stats.mad_mean_geometric_corrected));
                }
                if (dse_options.mad_median_q1)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mad_median_q1)}"), stats.mad_median_q1));
                }
                if (dse_options.mad_median_q2)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mad_median_q2)}"), stats.mad_median_q2));
                }
                if (dse_options.mad_median_q3)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mad_median_q3)}"), stats.mad_median_q3));
                }
                if (dse_options.mad_mid_range)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.mad_mid_range)}"), stats.mad_mid_range));
                }
                if (dse_options.interquartile_range)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.interquartile_range)}"), stats.interquartile_range));
                }
                if (dse_options.skewness)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.skewness)}"), stats.skewness));
                }
                if (dse_options.kurtosis)
                {
                    z.Add((group_id: /*program.string_debug*/ ($@"{stats.ds_group_name}"), member_id: /*program.string_debug*/ ($@"{stats.ds_member_name}"), perspective_id: /*program.string_debug*/ ($@"{nameof(stats.kurtosis)}"), stats.kurtosis));
                }
                //if (descriptive_stats_encoding_options.mode) { z.Add((group_id: /*program.string_debug*/($@"{stats.group_id_name}", member_id: /*program.string_debug*/($@"{stats.member_id_name}", perspective_id: /*program.string_debug*/($@"{nameof(stats.mode)}", stats.mode)); }
                //if (descriptive_stats_encoding_options.mad_mode) { z.Add((group_id: /*program.string_debug*/($@"{stats.group_id_name}", member_id: /*program.string_debug*/($@"{stats.member_id_name}", perspective_id: /*program.string_debug*/($@"{nameof(stats.mad_mode)}", stats.mad_mode)); }

                if (z.Count > 0)
                {
                    /*if (same_group)*/
                    {
                        result.AddRange(z);
                    }

                    /*if (individual)
                     * {
                     *  var z2 = z.Select(a => (string.Join(/*program.string_debug* /($@"_"), new[] {a.group_id, a.member_id, a.perspective_id}.Where(c => !string.IsNullOrWhiteSpace(c)).Distinct().ToArray()), a.member_id, a.perspective_id, a.perspective_value)).ToList();
                     *
                     *  result.AddRange(z2);
                     * }*/
                }
            }


            if (level == 0 && result.Count == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(dse_options), /*program.string_debug*/ ($@"{module_name}.{method_name}: no features are enabled in {nameof(dse_options)}."));
            }

            return(result);
        }