Beispiel #1
0
 public Buat(IDistribution d, IKernal k)
 {
     this._distribution = d;
     UValues = new List<double>();
     OptU = new List<double>();
     this._kernal = k;
 }
Beispiel #2
0
        /// <summary>
        /// Determines if the properties of the actual <see cref="IDistribution"/> are the same
        /// as the expected <see cref="IDistribution"/>.
        /// </summary>
        /// <param name="expectedDistribution">The expected <see cref="IDistribution"/>.</param>
        /// <param name="actualDistribution">The actual <see cref="IDistribution"/>.</param>
        /// <exception cref="AssertionException">Thrown when the following differences are found between
        /// the <paramref name="expectedDistribution"/> and <paramref name="actualDistribution"/>:
        /// <list type="bullet">
        /// <item>The probabilistic distribution types.</item>
        /// <item>The values for the mean and/or the standard deviation.</item>
        /// <item>The precision for the mean and/or the standard deviation.</item>
        /// </list></exception>
        public static void AreEqual(IDistribution expectedDistribution, IDistribution actualDistribution)
        {
            Assert.AreEqual(expectedDistribution.GetType(), actualDistribution.GetType());

            AreEqualValue(expectedDistribution.Mean, actualDistribution.Mean);
            AreEqualValue(expectedDistribution.StandardDeviation, actualDistribution.StandardDeviation);
        }
Beispiel #3
0
        public double CalculateDistance(IDistribution <T> obj1, IDistribution <T> obj2)
        {
            Func <Dictionary <T, int>, T, int, int> getRankOrDefault =
                (rankedDistribution, event_, defaultRank) =>
            {
                int rank;
                if (rankedDistribution.TryGetValue(event_, out rank) == false)
                {
                    rank = defaultRank;
                }
                return(rank);
            };
            var rankedDistribution1 = obj1.OrderByDescending <KeyValuePair <T, long>, long>(e => e.Value).Select((e, i) => new { event_ = e.Key, rank = i + 1 }).ToDictionary(p => p.event_, p => p.rank);
            var rankedDistribution2 = obj2.OrderByDescending <KeyValuePair <T, long>, long>(e => e.Value).Select((e, i) => new { event_ = e.Key, rank = i + 1 }).ToDictionary(p => p.event_, p => p.rank);
            // todo: 400 is hardcoded!
            int distance =
                obj1.DistinctRepresentedEvents
                .Union(obj2.DistinctRepresentedEvents)
                .Select(
                    e =>
                    Math.Abs(getRankOrDefault(rankedDistribution1, e, 400) -
                             getRankOrDefault(rankedDistribution2, e, 400)))
                .Sum();

            return(distance);
        }
Beispiel #4
0
 public void Setup()
 {
     this.position    = new Vector3(1, 2, 3);
     this.orientation = new Vector3(120, 80, 360);
     this.pose        = new Pose(this.position, this.orientation);
     this.dist        = new Uniform(1);
 }
Beispiel #5
0
        public static ParameterState Create(string name, double value)
        {
            var distributions = Distribution.GetDefaults();

            var indexDistribution = distributions.FindIndex(d => d.DistributionType == DistributionType.Normal);

            RequireTrue(indexDistribution.IsFound());
            IDistribution distribution = NormalDistribution.CreateDefault(value);

            distributions = distributions.SetItem(
                indexDistribution,
                distribution
                );

            indexDistribution = distributions.FindIndex(d => d.DistributionType == DistributionType.Uniform);
            RequireTrue(indexDistribution.IsFound());
            distribution  = UniformDistribution.CreateDefault(value);
            distributions = distributions.SetItem(
                indexDistribution,
                distribution
                );

            var parameterState = new ParameterState(
                name,
                DistributionType.Normal,
                distributions,
                true
                );

            return(parameterState);
        }
Beispiel #6
0
        /// <summary>
        ///   Gets the one-sided "Dn+" Kolmogorov-Sminorv statistic for the samples and target distribution.
        /// </summary>
        ///
        /// <param name="sortedSamples">The sorted samples.</param>
        /// <param name="distribution">The target distribution.</param>
        ///
        public static double OneSideUpper(double[] sortedSamples, IDistribution <double> distribution)
        {
            double N = sortedSamples.Length;

            double[] Y = sortedSamples;
            Func <double, double> F = distribution.DistributionFunction;

            // Test if the sample's distribution is "larger" than the
            // given theoretical distribution, in a statistical sense.

            double max = Math.Max(-F(Y[0]), 1 / N - F(Y[0]));

            for (int i = 1; i < Y.Length; i++)
            {
                double a = i / N - F(Y[i]);
                double b = (i + 1) / N - F(Y[i]);
                if (a > max)
                {
                    max = a;
                }
                if (b > max)
                {
                    max = b;
                }
            }

            return(max); // This is the one-sided "Dn+" statistic.
        }
        public void Derialize()
        {
            // Open the file containing the data that you want to deserialize.
            FileStream fs = new FileStream("DataFile.dat", FileMode.Open);

            try
            {
                BinaryFormatter formatter = new BinaryFormatter();

                // Deserialize the hashtable from the file and
                // assign the reference to the local variable.
                var context = (Context)formatter.Deserialize(fs);
                _distribution = context.Distribution;
                _classesProbablityDistribution = context.ClassesProbablityDistribution;
                _symbols = context.Symbols;
            }
            catch (SerializationException e)
            {
                Console.WriteLine("Failed to deserialize. Reason: " + e.Message);
                throw;
            }
            finally
            {
                fs.Close();
            }
        }
Beispiel #8
0
 public static void UpdateDistribution(EventEnum eventType, IDistribution distribution)
 {
     lock (lockobj)
     {
         _distribution[eventType] = distribution;
     }
 }
Beispiel #9
0
        public void Add(IDistribution d, double w)
        {
            if (_completed)
            {
                throw new Exception("Attempt to add a distribution to a Mixture that is marked completed");
            }
            if (d.SampleSpace != this.SampleSpace)
            {
                throw new Exception("Incompatible IDistribution added to Mixture");
            }

            //if (!_component.ContainsKey(d)) {
            // if (!_component.Contains(d)) {
            if (!Contains(d))
            {
                MixtureComponent mc = new MixtureComponent();
                mc.Distribution = d;
                mc.Weight       = w;
                mc.MinWeight    = 0.0;
                mc.MaxWeight    = 1.0;

                _component.Add(mc);

                // the parameters of the component distribution
                this.addParams(d.Params);
                // the weight of the component distribution in NOT a parameter in an immutable mixture
                // this.addParams(AdditionalPerComponentParameters);
            }
            else
            {
                throw new Exception("Duplicate IDistribution added to Mixture");
            }
        }
Beispiel #10
0
        /// <summary>
        ///   Gets the two-sided "Dn" Kolmogorov-Sminorv statistic for the samples and target distribution.
        /// </summary>
        ///
        /// <param name="sortedSamples">The sorted samples.</param>
        /// <param name="distribution">The target distribution.</param>
        ///
        public static double TwoSide(double[] sortedSamples, IDistribution <double> distribution)
        {
            double N = sortedSamples.Length;

            double[] Y = sortedSamples;
            Func <double, double> F = distribution.DistributionFunction;

            // Test if the sample's distribution is just significantly
            //   "different" than the given theoretical distribution.

            // This is a correction on the common formulation found in many places
            //  such as in Wikipedia. Please see the Engineering Statistics Handbook,
            //  section "1.3.5.16. Kolmogorov-Smirnov Goodness-of-Fit Test" for more
            //  details: http://www.itl.nist.gov/div898/handbook/eda/section3/eda35g.htm

            double max = Math.Max(Math.Abs(F(Y[0])), Math.Abs(1 / N - F(Y[0])));

            for (int i = 1; i < Y.Length; i++)
            {
                double a = Math.Abs(F(Y[i]) - i / N);
                double b = Math.Abs((i + 1) / N - F(Y[i]));
                if (a > max)
                {
                    max = a;
                }
                if (b > max)
                {
                    max = b;
                }
            }

            return(max); // This is the two-sided "Dn" statistic.
        }
 internal MeasurementDistributionDerivation(object type,
                                            Func <object> parameter, Func <object> derivation, string name,
                                            IDistribution distribution)
     : base(type, parameter, new Measurement(derivation, ""), name)
 {
     this.distribution = distribution;
 }
Beispiel #12
0
        /// <summary>
        /// Attempts to set <see cref="IDistribution.StandardDeviation"/>.
        /// </summary>
        /// <param name="distribution">The <see cref="IDistribution"/> to be updated.</param>
        /// <param name="standardDeviation">The new value for <see cref="IDistribution.StandardDeviation"/>.</param>
        /// <param name="stochastName">The descriptive name of <paramref name="distribution"/>.</param>
        /// <param name="calculationName">The name of the calculation to which <paramref name="distribution"/>
        /// is associated.</param>
        /// <returns><c>true</c> if setting <see cref="IDistribution.StandardDeviation"/>
        /// was successful, <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="distribution"/>
        /// is <c>null</c>.</exception>
        public static bool TrySetStandardDeviation(this IDistribution distribution, double?standardDeviation,
                                                   string stochastName, string calculationName)
        {
            if (distribution == null)
            {
                throw new ArgumentNullException(nameof(distribution));
            }

            if (standardDeviation.HasValue)
            {
                try
                {
                    distribution.StandardDeviation = (RoundedDouble)standardDeviation.Value;
                }
                catch (ArgumentOutOfRangeException e)
                {
                    string errorMessage = string.Format(
                        Resources.IDistributionExtensions_TrySetStandardDeviation_StandardDeviation_0_is_invalid_for_Stochast_1_,
                        standardDeviation, stochastName);

                    LogOutOfRangeException(errorMessage,
                                           calculationName,
                                           e);

                    return(false);
                }
            }

            return(true);
        }
Beispiel #13
0
 /// <summary>
 /// Attempts to set the parameters of an <see cref="IDistribution"/>.
 /// </summary>
 /// <param name="distribution">The <see cref="IDistribution"/> to be updated.</param>
 /// <param name="configuration">The configuration containing the new values for
 /// <see cref="IDistribution.Mean"/> and <see cref="IDistribution.StandardDeviation"/>.</param>
 /// <param name="stochastName">The descriptive name of <paramref name="distribution"/>.</param>
 /// <param name="calculationName">The name of the calculation to which <paramref name="distribution"/>
 /// is associated.</param>
 /// <returns><c>true</c> if setting all properties was successful, <c>false</c> otherwise.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="distribution"/>
 /// is <c>null</c>.</exception>
 public static bool TrySetDistributionProperties(this IDistribution distribution,
                                                 StochastConfiguration configuration,
                                                 string stochastName, string calculationName)
 {
     return(distribution.TrySetMean(configuration.Mean, stochastName, calculationName) &&
            distribution.TrySetStandardDeviation(configuration.StandardDeviation, stochastName, calculationName));
 }
Beispiel #14
0
        public void LoadModel(string path)
        {
            var stream    = File.OpenRead(path);
            var formatter = new BinaryFormatter();
            var model     = (ExportModel)formatter.Deserialize(stream);

            stream.Close();

            if (model.InputCell != null)
            {
                Distribution = DistributionFactory.GetDistribution(model.Distribution.Name, model.Distribution.Parameters);
                SetInputCell(Application.ActiveSheet.Cells(model.InputCell.Row, model.InputCell.Column));
            }

            if (model.OutputCell != null)
            {
                SetOutputCell(Application.ActiveSheet.Cells(model.OutputCell.Row, model.OutputCell.Column));
                OutputCell.Formula = model.OutputCell.Formula;
            }

            if (model.DecisionVariables?.Count > 0)
            {
                foreach (var v in model.DecisionVariables.Values)
                {
                    v.DecisionCell = Application.ActiveSheet.Cells(v.Row, v.Column);
                }
            }
            DecisionVariables = model.DecisionVariables;
        }
Beispiel #15
0
        /// <inheritdoc />
        protected override bool Init()
        {
            _latencyDistribution = ParsedConfig?.Latency?.CreateDistribution();
            if (_latencyDistribution != null)
            {
                Log.Information("Latency parameters: {0} milliseconds with random source {1}",
                                _latencyDistribution, ParsedConfig !.Latency !.RandomSourceType);
            }

            _writeDistribution = ParsedConfig?.WriteBandwidth?.CreateDistribution();
            if (_writeDistribution != null)
            {
                Log.Information("Write bandwidth parameters {0} kilobits/sec with random source {1}",
                                _writeDistribution, ParsedConfig !.WriteBandwidth !.RandomSourceType);
            }

            _readDistribution = ParsedConfig?.ReadBandwidth?.CreateDistribution();
            if (_readDistribution != null)
            {
                Log.Information("Read bandwidth parameters {0} kilobits/sec with random source {1}",
                                _readDistribution, ParsedConfig !.ReadBandwidth !.RandomSourceType);
            }

            return(true);
        }
Beispiel #16
0
        protected override bool ValidateDistribution(IDistribution dist)
        {
            bool ok = true;

            ok = ok && ValidateSampleSpace(dist.SampleSpace);
            return(ok);
        }
        /// <summary>
        ///   Constructs a new Hidden Markov Model with discrete state probabilities.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">
        ///   The initial emission probability distribution to be used by each of the states.
        /// </param>
        public ContinuousHiddenMarkovModel(ITopology topology, IDistribution emissions)
            : base(topology)
        {
            if (emissions == null)
            {
                throw new ArgumentNullException("emissions");
            }

            // Initialize B using the initial distribution
            B = new IDistribution[States];

            for (int i = 0; i < B.Length; i++)
            {
                B[i] = (IDistribution)emissions.Clone();
            }

            if (B[0] is IMultivariateDistribution)
            {
                dimension = ((IMultivariateDistribution)B[0]).Dimension;
            }
            else
            {
                dimension = 1;
            }
        }
        public NaiveBayesClassifier(IDistribution[,] distribution, IDistribution classDistribution)
        {
            _classes = distribution.GetLength(0);

            _distribution = distribution;
            _classesProbablityDistribution = classDistribution;
        }
        public NaiveBayesClassifier(IDistribution[,] distribution, IDistribution classDistribution)
        {
            _classes = distribution.GetLength(0);

            _distribution = distribution;
            _classesProbablityDistribution = classDistribution;
        }
Beispiel #20
0
        internal void SetTree(ObjectFormulaTree tree,
                              bool next,
                              AssociatedAddition addition,
                              IList <IMeasurement> list)
        {
            string dn = "D" + symbol;

            this.tree = tree;
            IDistribution d = DeltaFunction.GetDistribution(tree);

            if (next)
            {
                if (d != null)
                {
                    temp = new FormulaMeasurementDerivationDistribution(tree, null, symbol, addition);
                }
                else
                {
                    temp = new FormulaMeasurementDerivation(tree, null, symbol, addition);
                }
                derivation = temp;
                list.Add(derivation);
                return;
            }
            if (d != null)
            {
                derivation = new FormulaMeasurementDistribution(tree, symbol, addition);
            }
            else
            {
                derivation = new FormulaMeasurement(tree, symbol, addition);
            }
            list.Add(derivation);
            return;
        }
Beispiel #21
0
        public IDistribution next()
        {
            IDistribution answer = _current;

            if (_ds.MeanIterator.hasNext())
            {
                _mean    = _ds.MeanIterator.next();
                _current = new Distribution_Gaussian(_ds.BlauSpace, _mean, _std);
            }
            else
            {
                _ds.MeanIterator.reset();
                _mean = _ds.MeanIterator.next();

                if (_ds.StdIterator.hasNext())
                {
                    _std     = _ds.StdIterator.next();
                    _current = new Distribution_Gaussian(_ds.BlauSpace, _mean, _std);
                }
                else
                {
                    _current = null;
                }
            }
            return(answer);
        }
Beispiel #22
0
        protected void Check([NotNull] IDistribution distribution, [NotNull] double[] x, [NotNull] double[] expectedPdf,
                             [NotNull] double[] expectedCdf, [NotNull] double[] expectedQuantile)
        {
            AssertEqual("StandardDeviation", distribution.StandardDeviation, distribution.Variance.Sqrt());

            for (int i = 0; i < x.Length; i++)
            {
                AssertEqual($"Pdf({x[i]})", expectedPdf[i], distribution.Pdf(x[i]));
            }

            for (int i = 0; i < x.Length; i++)
            {
                AssertEqual($"Cdf({x[i]})", expectedCdf[i], distribution.Cdf(x[i]));
            }

            for (int i = 0; i < x.Length; i++)
            {
                AssertEqual($"Quantile({x[i]})", expectedQuantile[i], distribution.Quantile(x[i]));
            }

            for (int i = 0; i < x.Length; i++)
            {
                AssertEqual($"Cdf(Quantile({x[i]}))", x[i], distribution.Cdf(distribution.Quantile(x[i])));
            }

            Assert.Throws <ArgumentOutOfRangeException>(() => distribution.Quantile(-1));
            Assert.Throws <ArgumentOutOfRangeException>(() => distribution.Quantile(2));
        }
Beispiel #23
0
        /// <summary>
        /// Constructs a <see cref="GeneralizedLinearModel{T}"/> estimated with the given data.
        /// </summary>
        /// <param name="design">
        /// The design matrix of independent variables.
        /// </param>
        /// <param name="response">
        /// A collection of response values.
        /// </param>
        /// <param name="weights">
        /// An array of importance weights.
        /// </param>
        /// <param name="distribution">
        /// The distribution class used by the model.
        /// </param>
        /// <param name="addConstant">
        /// True to prepend the design matrix with a unit vector; otherwise false.
        /// </param>
        /// <param name="options">
        /// Executes select methods in parallel if provided.
        /// </param>
        public GeneralizedLinearModel(
            [NotNull][ItemNotNull] double[][] design,
            [NotNull] double[] response,
            [NotNull] double[] weights,
            [NotNull] IDistribution <T> distribution,
            bool addConstant = false,
            [CanBeNull] ParallelOptions options = default)
        {
            if (design is null)
            {
                throw new ArgumentNullException(nameof(design));
            }
            if (response is null)
            {
                throw new ArgumentNullException(nameof(response));
            }
            if (distribution is null)
            {
                throw new ArgumentNullException(nameof(distribution));
            }
            if (design.Length != response.Length || design.Length == 0)
            {
                throw new ArrayConformabilityException <double>(design, response);
            }

            double[][] designArray = addConstant ? design.Prepend(1.0) : design;

            _distribution = distribution;

            ObservationCount = designArray.Length;

            VariableCount = designArray[0].Length;

            double[] resultResponse;

            if (distribution is GaussianDistribution && distribution.LinkFunction is IdentityLinkFunction)
            {
                Coefficients =
                    options is null
                        ? designArray.RegressOls(response)
                        : designArray.RegressOls(response, options);

                resultResponse = response;
            }
            else
            {
                (Coefficients, resultResponse) =
                    options is null
                        ? designArray.RegressIrls(response, weights, distribution)
                        : designArray.RegressIrls(response, weights, distribution, options);
            }

            double[] squaredErrors = designArray.SquaredError(resultResponse, Evaluate);

            SumSquaredErrors = squaredErrors.Sum();

            _standardErrorsOls = new Lazy <double[]>(() => designArray.StandardError(squaredErrors, StandardErrorType.Ols));
            _standardErrorsHC0 = new Lazy <double[]>(() => designArray.StandardError(squaredErrors, StandardErrorType.HC0));
            _standardErrorsHC1 = new Lazy <double[]>(() => designArray.StandardError(squaredErrors, StandardErrorType.HC1));
        }
Beispiel #24
0
 public static IEnumerable <T> Generate <T>(this IDistribution <T> distribution, int count)
 {
     for (int i = 0; i < count; i++)
     {
         yield return(distribution.Generate());
     }
 }
Beispiel #25
0
 public Triangular(IDistribution d)
 {
     this._distribution = d;
     _sampling = _distribution.GetSampling();
     Center = (Xmax + Xmin) / 2;
     DeltaX = (Xmax - Xmin) / 2;
 }
Beispiel #26
0
        public void SingleAverage(IDistribution <Single> dist, UInt64 seed)
        {
            const Int32 iterations = 10_000;
            var         rng        = Pcg32.Create(seed, 11634580027462260723ul);

            Double mean = 0;

            for (var i = 0; i < iterations; i++)
            {
                var result = dist.Sample(rng);
                var delta  = result - mean;
                mean += delta / (i + 1);
                Assert.True(0 <= result);
                Assert.True(result <= 1);
            }

            Assert.True(Statistics.WithinConfidence(popMean: 0.5, popStdDev: 0.5, mean, iterations));

            Double mean2 = 0;

            for (var i = 0; i < iterations; i++)
            {
                Assert.True(dist.TrySample(rng, out var result));
                var delta = result - mean2;
                mean2 += delta / (i + 1);
                Assert.True(0 <= result);
                Assert.True(result <= 1);
            }

            Assert.True(Statistics.WithinConfidence(popMean: 0.5, popStdDev: 0.5, mean2, iterations));
        }
Beispiel #27
0
 /// <summary>
 /// Attempts to set the parameters of an <see cref="IDistribution"/>.
 /// </summary>
 /// <param name="distribution">The <see cref="IDistribution"/> to be updated.</param>
 /// <param name="mean">The new value for <see cref="IDistribution.Mean"/>.</param>
 /// <param name="standardDeviation">The new value for <see cref="IDistribution.StandardDeviation"/>.</param>
 /// <param name="stochastName">The descriptive name of <paramref name="distribution"/>.</param>
 /// <param name="calculationName">The name of the calculation to which <paramref name="distribution"/>
 /// is associated.</param>
 /// <returns><c>true</c> if setting all properties was successful, <c>false</c> otherwise.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="distribution"/>
 /// is <c>null</c>.</exception>
 public static bool TrySetDistributionProperties(this IDistribution distribution,
                                                 double?mean, double?standardDeviation,
                                                 string stochastName, string calculationName)
 {
     return(distribution.TrySetMean(mean, stochastName, calculationName) &&
            distribution.TrySetStandardDeviation(standardDeviation, stochastName, calculationName));
 }
Beispiel #28
0
        /// <inheritdoc/>
        public byte[] TransformToByte(decimal[] cdf, IDistribution distribution)
        {
            if (cdf is null)
            {
                throw new ArgumentNullException(nameof(cdf));
            }
            if (distribution is null)
            {
                throw new ArgumentNullException(nameof(distribution));
            }

            var result = new byte[256];

            //transform an array by a quantile function
            for (int index = 0; index < 256; ++index)
            {
                if (distribution.Quantile(cdf[index], out var pixel))
                {
                    if (pixel > 255M)
                    {
                        pixel = 255M;
                    }

                    if (pixel < 0M)
                    {
                        pixel = 0M;
                    }
                }

                result[index] = Convert.ToByte(pixel);
            }

            return(result);
        }
 public void SetDistribution(IDistribution distribution)
 {
     if (distribution is NormalDistribution)
     {
         DistributionDropdown.value = 0;
         DeviationInput.GetComponent <InputField>().text = ((NormalDistribution)distribution).Deviation.ToString();
         MeanInput.GetComponent <InputField>().text      = ((NormalDistribution)distribution).Mean.ToString();
     }
     else if (distribution is UniformDistribution)
     {
         DistributionDropdown.value = 1;
         MinInput.GetComponent <InputField>().text = ((UniformDistribution)distribution).Min.ToString();
         MaxInput.GetComponent <InputField>().text = ((UniformDistribution)distribution).Max.ToString();
     }
     else if (distribution is DeterministicDistribution)
     {
         DistributionDropdown.value = 2;
         ValueInput.GetComponent <InputField>().text = ((DeterministicDistribution)distribution).Value.ToString();
     }
     else if (distribution is ExponentialDistribution)
     {
         DistributionDropdown.value = 3;
         IntensityInput.GetComponent <InputField>().text = ((ExponentialDistribution)distribution).Intensity.ToString();
     }
     UpdateDistributionParamsVisibility();
 }
 public static IEnumerable <T> Samples <T>(this IDistribution <T> d)
 {
     while (true)
     {
         yield return(d.Sample());
     }
 }
 /// <summary>
 /// Asserts whether the values of a distribution are correctly set
 /// to another distribution.
 /// </summary>
 /// <param name="distributionToAssert">The distribution to assert.</param>
 /// <param name="setDistribution">The distribution which was used to set the properties.</param>
 /// <param name="expectedDistribution">The expected distribution.</param>
 /// <exception cref="AssertionException">Thrown when:
 /// <list type="bullet">
 /// <item>The <paramref name="distributionToAssert"/> and <paramref name="setDistribution"/>
 /// are the same reference.</item>
 /// <item>The values of the <paramref name="setDistribution"/> do not match with the
 /// <paramref name="expectedDistribution"/>.</item>
 /// </list></exception>
 public static void AssertDistributionCorrectlySet(IDistribution distributionToAssert,
                                                   IDistribution setDistribution,
                                                   IDistribution expectedDistribution)
 {
     Assert.AreNotSame(setDistribution, distributionToAssert);
     DistributionAssert.AreEqual(expectedDistribution, distributionToAssert);
 }
Beispiel #32
0
 /// <summary>
 /// Infinite enumerable of samples from this <see cref="IDistribution{T}"/>.
 /// </summary>
 /// <typeparam name="T">Type of items in this <see cref="IDistribution{T}"/></typeparam>
 /// <param name="distribution">The distribution we're sampling.</param>
 /// <param name="random"></param>
 /// <returns>The infinite <see cref="IEnumerable{T}"/> of samples.</returns>
 public static IEnumerable <T> Samples <T>(this IDistribution <T> distribution, IRNG random)
 {
     while (true)
     {
         yield return(distribution.Sample(random));
     }
 }
 public static IEnumerable <T> TakeSamples <T>(this IDistribution <T> distribution, int samples)
 {
     for (int i = 0; i < samples; i++)
     {
         yield return(distribution.Sample());
     }
 }
Beispiel #34
0
 public Backpropagation(IKernal kernal, IDistribution distribution)
 {
     r = new Random();
     this.Kernal = kernal;
     this.Distribution = distribution;
     Weights = new List<double>();
     //SetWeigths(Distribution.GetSampling().Count());
 }
Beispiel #35
0
        /// <summary>
        /// Initialises the dependency graph.
        /// </summary>
        /// <param name="transrel">a table of distribution transitive relationships</param>
        /// <param name="selected">the set of selected (top-level) distributions</param>
        /// <param name="depmap">a mapping of package and dependency metadata</param>
        private DependencyGraph(Dictionary<IDistribution, List<IDistribution>> transrel,
            IDistribution[] selected, Dictionary<string, List<Dependency>> depmap)
        {
            _sorted = DependencyGraph.TopoSort(transrel);
            _selected = selected;
            _depmap = depmap;

            Dictionary<IDistribution, Node> nodemap = new Dictionary<IDistribution, Node>();
            List<Node> visited = new List<Node>();
            Node tail;

            /* build the dependency graph */
            foreach (IDistribution dist in _sorted) {
                Node node = new Node();
                node.dist = dist;

                nodemap.Add(dist, node);

                foreach (IDistribution dep in transrel[dist]) {
                    tail = node.firstchild;

                    if (tail == null) {
                        Node first = nodemap[dep];
                        if (!visited.Contains(first)) {
                            node.firstchild = first;
                            visited.Add(first);
                        }
                    } else {
                        while (tail.next != null)
                            tail = tail.next;

                        Node next = nodemap[dep];
                        if (!visited.Contains(next)) {
                            tail.next = nodemap[dep];
                            visited.Add(next);
                        }
                    }
                }
            }

            /* find root nodes */
            IDistribution[] rootdists = transrel.Keys
                .Where(k => transrel.Values.Where(v => v.Contains(k)).Count() == 0)
                .ToArray();
            _root = nodemap[rootdists[0]];
            tail = _root;

            for (int i = 1; i < rootdists.Length; i++) {
                while (tail.next != null)
                    tail = tail.next;

                tail.next = nodemap[rootdists[i]];
            }
        }
        /// <summary>
        /// <para>Using VC-dimension, we can bound the probability of making an error when estimating empirical probability
        /// distributions. We are using Theorem 2.41 in "All Of Nonparametric Statistics".
        /// http://books.google.com/books?id=MRFlzQfRg7UC&lpg=PP1&dq=all%20of%20nonparametric%20statistics&pg=PA22#v=onepage&q=%22shatter%20coe%EF%AC%83cients%20do%20not%22&f=false .</para>
        /// <para>Note that for intervals on the real line the VC-dimension is 2.</para>
        /// </summary>
        /// <param name="epsilon">The error we are willing to tolerate.</param>
        /// <param name="delta">The error probability we are willing to tolerate.</param>
        /// <param name="s">The samples to use for testing.</param>
        /// <param name="dist">The distribution we are testing.</param>
        public static void VapnikChervonenkisTest(double epsilon, double delta, IEnumerable<double> s, IDistribution dist)
        {
            double N = (double) s.Count();
            Assert.GreaterThan(N, Math.Ceiling(32.0 * Math.Log(16.0 / delta) / epsilon / epsilon));

            var histogram = new Histogram(s, NumberOfBuckets);

            for (int i = 0; i < NumberOfBuckets; i++)
            {
                double p = dist.CumulativeDistribution(histogram[i].UpperBound) - dist.CumulativeDistribution(histogram[i].LowerBound);
                double pe = histogram[i].Count / N;
                Assert.LessThan(Math.Abs(p - pe), epsilon, dist.ToString());
            }
        }
        public SolitonEncoder(byte[] data, int blockSize)
        {
            if (blockSize <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            Data = data;
            Size = data.Length;
            K = (int)Math.Ceiling ((double)data.Length / (double)blockSize);
            BlockSize = blockSize;
            _neighbourSelector = new CryptoRNGHelper ();

            _dist = new Soliton (this.K, 0.0012, 0.0001);

            byte[] padded = Pad (data);
            _data = Split (padded);
        }
        public NaiveBayesClassifier(DataSample[] samples, int classes, ColumnDataType[] columnDataTypes)
        {
            _classes = classes;

            _distribution = new IDistribution[classes, columnDataTypes.Length];

            _classesProbablityDistribution = new CategoricalDistribution(
                samples.Select(item => item.ClassId).ToArray(), classes);
            var splitDataPerClass = SplitDataPerClass(samples, _classes, columnDataTypes.Length);

            var groups = GetClassGroups(samples, _classes);

            for (int index = 0; index < columnDataTypes.Length; index++)
            {
                //var values = GetDataPerClass(samples, _classes, index);
                Double[][] values = new double[classes][];
                for (int classIndex = 0; classIndex < classes; classIndex++)
                {
                    values[classIndex] = splitDataPerClass[index, classIndex];
                }
                //var values = splitDataPerClass[index,_]
                if (values.All(item => item == null))
                {
                    continue;
                }

                for (int classIndex = 0; classIndex < classes; classIndex++)
                {
                    var itemsOnClass = values[classIndex] ?? new double[0];

                    if (!columnDataTypes[index].IsDiscrete)
                    {
                        _distribution[classIndex, index] = new GaussianDistribution(itemsOnClass);
                    }
                    else
                    {

                        _distribution[classIndex, index] =
                            new CategoricalDistribution(itemsOnClass.Select(Convert.ToInt32).ToArray(),
                                columnDataTypes[index].NumberOfCategories, groups[classIndex]);
                    }
                }
            }
        }
Beispiel #39
0
 /// <summary>
 /// Determines if the given distribution is masked, either by the 
 /// profile or by keyword.
 /// </summary>
 /// <param name="dist">the distribution to check</param>
 /// <returns>true if masked, false otherwise</returns>
 public abstract bool IsMasked(IDistribution dist);
        /// <summary>
        ///   Constructs a new Hidden Markov Model with discrete state probabilities.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">
        ///   The initial emission probability distribution to be used by each of the states.
        /// </param>
        public ContinuousHiddenMarkovModel(ITopology topology, IDistribution emissions)
            : base(topology)
        {
            if (emissions == null)
            {
                throw new ArgumentNullException("emissions");
            }

            // Initialize B using the initial distribution
            B = new IDistribution[States];

            for (int i = 0; i < B.Length; i++)
                B[i] = (IDistribution) emissions.Clone();

            if (B[0] is IMultivariateDistribution)
                dimension = ((IMultivariateDistribution) B[0]).Dimension;
            else dimension = 1;
        }
Beispiel #41
0
        /// <summary>
        /// Вычисление градиента только для  ядра гаусса
        /// </summary>
        /// <param name="distribution"></param>
        public static double Grad(IDistribution distribution, GaussianKernal kernal)
        {
            double min = distribution.GetSampling().Min();
            double max = distribution.GetSampling().Max();
            double x0 = new Random().Next((int)min, (int)max);
            double xi = x0;

            double step = 0.0;
            double YMin = kernal.getDerivative(xi);
            double xNext = xi - EPSSILON * kernal.getDerivative(xi);
            while (kernal.getDerivative(xNext) - kernal.getDerivative(xi) > C)
            {
                step = xi - EPSSILON * kernal.getDerivative(xi) + xi;
                YMin = kernal.getDerivative(xi);
                xi = xNext;
                xNext = xi + step;
            }
            return YMin;
        }
Beispiel #42
0
 public void OnSetDistribution(IDistribution distribution,IKernal kernal)
 {
     _model = new MainModel(distribution,kernal);
 }
Beispiel #43
0
        /// <summary>
        /// Применить корректировку)(getWeight) и поработать с нормой .
        /// </summary>
        /// <param name="distribution"></param>
        /// <param name="kernal"></param>
        public void Learm(IDistribution distribution, IKernal kernal)
        {
            double norma = 0.0;
            List<double> ErrFunctionValues = new List<double>();
            LearmSampling = distribution.GetSampling().ToList();
            Signals = new List<double>();
            List<double> faktOj = new List<double>();//Подать на выход новой сети  разность между фактическим и ошидаемым значениями
            do
            {
                foreach (double sample in LearmSampling)
                {
                    Signals.Add(kernal.getDensityFunctionValue(sample));//выходные сигналы сети ска
                }

                for (int i = 0; i < LearmSampling.Count; i++)
                {
                    ErrFunctionValues.Add(this.ErrFunction(LearmSampling.ElementAt(i), Signals.ElementAt(i)));
                }
                List<double> BaskSignals = new List<double>();//Замена функций их производными
                for (int i = 0; i < Signals.Count; i++)//2
                {
                    BaskSignals.Add(kernal.getDerivative(LearmSampling.ElementAt(i)));
                }
                // DeltaWeight = -N*GetGradirnt()
            }
            while (norma > C);
            //Weights//вектор весов
        }
Beispiel #44
0
        /// <summary>
        /// Determines the packages needed for merging, including dependencies if necessary.
        /// </summary>
        /// <param name="distarr">packages selected for merging</param>
        /// <param name="mopts">merge options</param>
        /// <param name="downloader">the downloader</param>
        /// <param name="scheduled">output list of packages scheduled for merge</param>
        private void ScheduleMerges(IDistribution[] distarr, MergeOptions mopts, Downloader downloader, 
            out List<MergeEventArgs> scheduled)
        {
            scheduled = new List<MergeEventArgs>();

            DependencyGraph dg = DependencyGraph.Compute(distarr);
            IDistribution[] distdeparr = dg.SortedNodes.ToArray();

            DependencyGraph.Conflict[] conflicts = dg.FindSlotConflicts();
            if (conflicts.Length > 0)
                throw new SlotConflictException(conflicts);

            for (int i = 0; i < distdeparr.Length; i++) {
                IDistribution dist = distdeparr[i];
                Atom current = _pkgmgr
                    .FindPackages(Atom.Parse(dist.Package.FullName, AtomParseOptions.WithoutVersion))
                    .Where(n => n.Slot == dist.Slot)
                    .SingleOrDefault();
                bool realselect = distarr.Contains(dist);

                if (!realselect && current != null && !mopts.HasFlag(MergeOptions.Deep) && dg.CheckSatisfies(current))
                    dist = dist.PortsTree.Lookup(current);

                MergeEventArgs mea = new MergeEventArgs();
                mea.Previous = current;
                mea.Selected = realselect && !mopts.HasFlag(MergeOptions.OneShot);
                mea.Distribution = dist;
                mea.FetchOnly = mopts.HasFlag(MergeOptions.FetchOnly);

                mea.HardMask = dist.PortsTree.IsHardMasked(dist);
                mea.KeywordMask = dist.PortsTree.IsKeywordMasked(dist);

                mea.KeywordsNeeded = dist.Keywords
                    .Where(kw => _cfg.AcceptKeywords.Contains(kw) ||
                                 _cfg.AcceptKeywords.Contains(Distribution.GetKeywordName(kw)))
                    .ToArray();

                if (!mopts.HasFlag(MergeOptions.Pretend) && (mea.HardMask || mea.KeywordMask))
                    throw new MaskedPackageException(dist.Package.FullName);

                if (current == null)
                    mea.Flags |= MergeFlags.New;
                if (!mea.Flags.HasFlag(MergeFlags.New) && current.Version == dist.Version)
                    mea.Flags |= MergeFlags.Replacing;
                if (!mea.Flags.HasFlag(MergeFlags.New) && !mea.Flags.HasFlag(MergeFlags.Replacing))
                    mea.Flags |= MergeFlags.Updating;
                if (!mea.Flags.HasFlag(MergeFlags.New) && current.Version > dist.Version)
                    mea.Flags |= MergeFlags.Downgrading;
                if (dist.Slot > 0)
                    mea.Flags |= MergeFlags.Slot;
                if (dist.Interactive)
                    mea.Flags |= MergeFlags.Interactive;
                /* TODO block */

                if (mea.Flags.HasFlag(MergeFlags.Updating))
                    mea.Selected = _pkgmgr.IsSelected(dist.Atom);

                if (dist.FetchRestriction && Distribution.CheckSourcesExist(dist, _cfg.DistFilesDir))
                    mea.Flags |= MergeFlags.FetchExists;
                else if (dist.FetchRestriction)
                    mea.Flags |= MergeFlags.FetchNeeded;

                if (mea.Flags.HasFlag(MergeFlags.Replacing) &&
                        (!realselect || mopts.HasFlag(MergeOptions.NoReplace)) && !mopts.HasFlag(MergeOptions.EmptyTree))
                    continue;

                if (mea.Flags.HasFlag(MergeFlags.FetchNeeded) && !mopts.HasFlag(MergeOptions.Pretend)) {
                    throw new InstallException("Fetch restriction is enabled for " + dist.ToString()
                        + "\nCopy the package archive into " + _cfg.DistFilesDir);
                }

                if (!(mea.Flags.HasFlag(MergeFlags.FetchExists) || mea.Flags.HasFlag(MergeFlags.FetchNeeded)))
                    mea.FetchHandle = downloader.Enqueue(dist);

                scheduled.Add(mea);
            }
        }
Beispiel #45
0
        /// <summary>
        /// Merges the given distributions into the system.
        /// </summary>
        /// <param name="distarr">the distributions to merge</param>
        /// <param name="mopts">merge option flags</param>
        public void Merge(IDistribution[] distarr, MergeOptions mopts)
        {
            if (distarr.Length == 0)
                return;

            Downloader downloader = new Downloader(_cfg.DistFilesDir);
            List<MergeEventArgs> scheduled = null;

            this.ScheduleMerges(distarr, mopts, downloader, out scheduled);

            if (!mopts.HasFlag(MergeOptions.Pretend)) {
                if (this.OnParallelFetch != null)
                    this.OnParallelFetch.Invoke(this, new EventArgs());

                downloader.FetchAsync();
            }

            for (int i = 0; i < scheduled.Count; i++) {
                MergeEventArgs mea = scheduled[i];
                mea.CurrentIter = i + 1;
                mea.TotalMerges = scheduled.Count;

                this.MergeOne(mea, mopts, downloader, _pkgmgr.RootDir);
            }

            if (!mopts.HasFlag(MergeOptions.Pretend)) {
                if (this.OnAutoClean != null)
                    this.OnAutoClean.Invoke(this, new EventArgs());

                TrashWorker.Purge(_pkgmgr);
            }
        }
 /// <summary>
 ///   Constructs a new Hidden Markov Model.
 /// </summary>
 /// <param name="states">The number of states for the model.</param>
 /// <param name="emissions">A initial distribution to be copied to all states in the model.</param>
 public ContinuousHiddenMarkovModel(int states, IDistribution emissions)
     : this(new Ergodic(states), emissions)
 {
 }
        /// <summary>
        /// Vapnik Chervonenkis test.
        /// </summary>
        /// <param name="epsilon">The error we are willing to tolerate.</param>
        /// <param name="delta">The error probability we are willing to tolerate.</param>
        /// <param name="s">The samples to use for testing.</param>
        /// <param name="dist">The distribution we are testing.</param>
        public static void VapnikChervonenkisTest(double epsilon, double delta, IEnumerable<double> s, IDistribution dist)
        {
            // Using VC-dimension, we can bound the probability of making an error when estimating empirical probability
            // distributions. We are using Theorem 2.41 in "All Of Nonparametric Statistics". 
            // http://books.google.com/books?id=MRFlzQfRg7UC&lpg=PP1&dq=all%20of%20nonparametric%20statistics&pg=PA22#v=onepage&q=%22shatter%20coe%EF%AC%83cients%20do%20not%22&f=false .</para>
            // For intervals on the real line the VC-dimension is 2.
            double n = s.Count();
            Assert.Greater(n, Math.Ceiling(32.0 * Math.Log(16.0 / delta) / epsilon / epsilon));

            var histogram = new Histogram(s, NumberOfBuckets);
            for (var i = 0; i < NumberOfBuckets; i++)
            {
                var p = dist.CumulativeDistribution(histogram[i].UpperBound) - dist.CumulativeDistribution(histogram[i].LowerBound);
                var pe = histogram[i].Count / n;
                Assert.Less(Math.Abs(p - pe), epsilon, dist.ToString());
            }
        }
Beispiel #48
0
 public MainModel(IDistribution distribution, IKernal kernal)
 {
     _distribution = distribution;
     _kernal = kernal;
 }
Beispiel #49
0
        public GaussianKernal(IDistribution distibution)
        {
            this._distribution = distibution;
            _sampling = _distribution.GetSampling();

        }
Beispiel #50
0
 /// <summary>
 /// в зависимости от того какое распределение и какой тип алгоритма исп-ся для подбора - накидал переключатель
 /// </summary>
 /// <param name="distribution"></param>
 public void OnSetParans(IDistribution distribution,string typeOptimization)
 {
     GA genetic = null;
     Backpropagation bp = null;
     switch (typeOptimization)
     {
         case "genetic":
             {
                 switch (distribution.getType())
                 {
                     case "Gaussian":
                         {
                             break;
                         }
                     case "Laplas":
                         {
                             break;
                         }
                     case "Exponentioal":
                         {
                             break;
                         }
                 }
                 break;
             }
         case "baskOpt":
             {
                 switch (distribution.getType())
                 {
                     case "Gaussian":
                         {
                             break;
                         }
                     case "Laplas":
                         {
                             break;
                         }
                     case "Exponentioal":
                         {
                             break;
                         }
                 }
                 break;
             }
     }
 }
Beispiel #51
0
        /// <summary>
        /// Determines if the given distribution is masked by keywords.
        /// </summary>
        /// <param name="dist">the distribution to check</param>
        /// <returns>true if masked, false otherwise</returns>
        public override bool IsKeywordMasked(IDistribution dist)
        {
            bool result = _xmlconf.AcceptKeywords.Intersect(dist.Keywords).Count() == 0;
            Dictionary<Atom, string[]> kwdict = this.GetPackageKeywords();

            foreach (KeyValuePair<Atom, string[]> kvp in kwdict) {
                if (kvp.Key.Match(dist.Atom) && kvp.Value.Intersect(dist.Keywords).Count() > 0) {
                    result = false;
                    break;
                }
            }

            return result;
        }
Beispiel #52
0
 /// <summary>
 /// Determines if the given distribution is masked, either by the profile 
 /// package.mask file or by keyword.
 /// </summary>
 /// <param name="dist">the distribution to check</param>
 /// <returns>true if masked, false otherwise</returns>
 public override bool IsMasked(IDistribution dist)
 {
     return this.IsHardMasked(dist) || this.IsKeywordMasked(dist);
 }
Beispiel #53
0
 /// <summary>
 /// Determines if the given distribution is masked by keywords.
 /// </summary>
 /// <param name="dist">the distribution to check</param>
 /// <returns>true if masked, false otherwise</returns>
 public abstract bool IsKeywordMasked(IDistribution dist);
 /// <summary>
 ///   Constructs a new Hidden Markov Model.
 /// </summary>
 /// <param name="transitions">The transitions matrix A for this model.</param>
 /// <param name="emissions">The emissions matrix B for this model.</param>
 /// <param name="probabilities">The initial state probabilities for this model.</param>
 public ContinuousHiddenMarkovModel(double[,] transitions, IDistribution[] emissions, double[] probabilities)
     : this(new Custom(transitions, probabilities), emissions)
 {
 }
Beispiel #55
0
 public QuarticKernal(IDistribution distr)
 {
     this._distribution = distr;
     _sampling = _distribution.GetSampling();
 }
 public EpanichnikovKernal(IDistribution distributiob)
 {
     this._distribution = distributiob;
     _sampling = _distribution.GetSampling();
     r = new Random();
 }
Beispiel #57
0
		private CompressionStats Compress( IGrid grid,
		                                   ICompressor compressor,
										   double[] errors,
										   string outName,
		                                   ProgressViewModel progressBar )
		{
			double[] leftBorders = new double[grid.ColumnCount];
			double[] rightBorders = new double[grid.ColumnCount];

			var qs = new IQuantization[grid.ColumnCount];
			var distrs = new IDistribution[grid.ColumnCount];

			progressBar.Status = "Quantizing columns...";

			Parallel.For( 0, grid.ColumnCount, column =>
			{
				var distr = new EmpiricalDistribution( grid, column );

				leftBorders[column] = double.MaxValue;
				rightBorders[column] = double.MinValue;

				for ( int row = 0; row < grid.RowCount; ++row )
				{
					double value = grid.GetValue( row, column );
					leftBorders[column] = leftBorders[column] < value ? leftBorders[column] : value;
					rightBorders[column] = rightBorders[column] > value ? rightBorders[column] : value;
				}

				var quantizer = new Quantizer( leftBorders[column], rightBorders[column] );
				var quantization = quantizer.Quantize( errors[column], distr );

				lock ( _lockGuard )
				{
					progressBar.Progress += 1.0 / ( grid.ColumnCount + 1 );
					distrs[column] = distr;
					qs[column] = quantization;
				}
			} );

			var quantizations = new List<IQuantization>( qs );
			var distributions = new List<IDistribution>( distrs );

			progressBar.Status = "Writing archive...";
			progressBar.Progress = ( double )grid.ColumnCount / ( grid.ColumnCount + 1 );

			ICompressionResult result;

			using ( var stream = new FileOutputStream( outName ) )
			{
				result = compressor.Compress( grid, quantizations, stream );
			}

			progressBar.Progress = 1.0;
			progressBar.TryClose( );

			return new CompressionStats
			{
				CompressionResult = result,
				Distributions = distributions,
				LeftBorders = leftBorders,
				RightBorders = rightBorders,
				Quantizations = quantizations
			};
		}
        /// <summary>
        ///   Constructs a new Hidden Markov Model.
        /// </summary>
        /// <param name="topology">
        ///   A <see cref="Topology"/> object specifying the initial values of the matrix of transition 
        ///   probabilities <c>A</c> and initial state probabilities <c>pi</c> to be used by this model.
        /// </param>
        /// <param name="emissions">
        ///   The initial emission probability distributions for each state.
        /// </param>
        public ContinuousHiddenMarkovModel(ITopology topology, IDistribution[] emissions)
            : base(topology)
        {
            if (emissions == null)
            {
                throw new ArgumentNullException("emissions");
            }

            if (emissions.GetLength(0) != States)
            {
                throw new ArgumentException(
                    "The emission matrix should have the same number of rows as the number of states in the model.",
                    "emissions");
            }

            B = emissions;

            if (B[0] is IMultivariateDistribution)
                dimension = ((IMultivariateDistribution) B[0]).Dimension;
            else dimension = 1;
        }
Beispiel #59
0
        /// <summary>
        /// Determines if the given distribution is masked by the profile package.mask file.
        /// </summary>
        /// <param name="dist">the distribution to check</param>
        /// <returns>true if masked, false otherwise</returns>
        public override bool IsHardMasked(IDistribution dist)
        {
            bool fmasked = false;

            /* look in hard-masked packages */
            foreach (Atom a in _hdmasked) {
                if (a.Match(dist.Atom)) {
                    fmasked = true;
                    break;
                }
            }

            /* look in unmasked packages */
            foreach (Atom a in _unmasked) {
                if (a.Match(dist.Atom)) {
                    fmasked = false;
                    break;
                }
            }

            return fmasked;
        }
 public DistributionChart(IDistribution distribution, int intervalsCount,IKernal kernal)
 {
     _distribution = distribution;
     _intervalsCount = intervalsCount;
     _kernal = kernal;
 }