コード例 #1
0
ファイル: Independent`1.cs プロジェクト: haf/Accord.Net
        /// <summary>
        ///   Fits the underlying distribution to a given set of observations.
        /// </summary>
        ///
        /// <param name="observations">The array of observations to fit the model against. The array
        ///   elements can be either of type double (for univariate data) or
        ///   type double[] (for multivariate data).</param>
        /// <param name="weights">The weight vector containing the weight for each of the samples.</param>
        /// <param name="options">Optional arguments which may be used during fitting, such
        ///   as regularization constants and additional parameters.</param>
        ///
        /// <example>
        ///   For an example on how to fit an independent joint distribution, please
        ///   take a look at the examples section for <see cref="Independent{TDistribution}"/>.
        /// </example>
        ///
        public void Fit(double[][] observations, double[] weights, IndependentOptions options)
        {
            observations = observations.Transpose();

            if (options != null)
            {
                if (options.InnerOptions != null)
                {
                    for (int i = 0; i < components.Length; i++)
                    {
                        components[i].Fit(observations[i], weights, options.InnerOptions[i]);
                    }
                }
                else
                {
                    for (int i = 0; i < components.Length; i++)
                    {
                        components[i].Fit(observations[i], weights, options.InnerOption);
                    }
                }
            }
            else
            {
                for (int i = 0; i < components.Length; i++)
                {
                    components[i].Fit(observations[i], weights, null);
                }
            }

            mean       = null;
            variance   = null;
            covariance = null;
        }
コード例 #2
0
        /// <summary>
        ///   Fits the underlying distribution to a given set of observations.
        /// </summary>
        ///
        /// <param name="observations">The array of observations to fit the model against. The array
        ///   elements can be either of type double (for univariate data) or
        ///   type double[] (for multivariate data).</param>
        /// <param name="weights">The weight vector containing the weight for each of the samples.</param>
        /// <param name="options">Optional arguments which may be used during fitting, such
        ///   as regularization constants and additional parameters.</param>
        ///
        /// <example>
        ///   For an example on how to fit an independent joint distribution, please
        ///   take a look at the examples section for <see cref="Independent{TDistribution}"/>.
        /// </example>
        ///
        public void Fit(TObservation[][] observations, double[] weights, IndependentOptions options)
        {
            if (options != null)
            {
                if (!options.Transposed)
                {
                    observations = observations.Transpose();
                }

                if (options.InnerOptions != null)
                {
                    for (int i = 0; i < Components.Length; i++)
                    {
                        ((IFittableDistribution <TObservation>)Components[i]).Fit(observations[i], weights, options.InnerOptions[i]);
                    }
                }
                else
                {
                    for (int i = 0; i < Components.Length; i++)
                    {
                        ((IFittableDistribution <TObservation>)Components[i]).Fit(observations[i], weights, options.InnerOption);
                    }
                }
            }
            else
            {
                observations = observations.Transpose();
                for (int i = 0; i < Components.Length; i++)
                {
                    ((IFittableDistribution <TObservation>)Components[i]).Fit(observations[i], weights);
                }
            }

            Reset();
        }
コード例 #3
0
        /// <summary>
        ///   Fits the underlying distribution to a given set of observations.
        /// </summary>
        ///
        /// <param name="observations">The array of observations to fit the model against. The array
        ///   elements can be either of type double (for univariate data) or
        ///   type double[] (for multivariate data).</param>
        /// <param name="weights">The weight vector containing the weight for each of the samples.</param>
        /// <param name="options">Optional arguments which may be used during fitting, such
        ///   as regularization constants and additional parameters.</param>
        ///
        /// <remarks>
        ///   Although both double[] and double[][] arrays are supported,
        ///   providing a double[] for a multivariate distribution or a
        ///   double[][] for a univariate distribution may have a negative
        ///   impact in performance.
        /// </remarks>
        ///
        /// <example>
        ///   For an example on how to fit an independent joint distribution, please
        ///   take a look at the examples section for <see cref="Independent{TDistribution}"/>.
        /// </example>
        ///
        public override void Fit(double[][] observations, double[] weights, IFittingOptions options)
        {
            IndependentOptions independentOptions = options as IndependentOptions;

            if (options != null && independentOptions == null)
            {
                throw new ArgumentException("The specified options' type is invalid.", "options");
            }

            Fit(observations, weights, independentOptions);
        }
コード例 #4
0
ファイル: Independent`3.cs プロジェクト: zadiran/framework
        /// <summary>
        ///   Fits the underlying distribution to a given set of observations.
        /// </summary>
        ///
        /// <param name="observations">The array of observations to fit the model against. The array
        ///   elements can be either of type double (for univariate data) or
        ///   type double[] (for multivariate data).</param>
        /// <param name="weights">The weight vector containing the weight for each of the samples.</param>
        /// <param name="options">Optional arguments which may be used during fitting, such
        ///   as regularization constants and additional parameters.</param>
        ///
        /// <example>
        ///   For an example on how to fit an independent joint distribution, please
        ///   take a look at the examples section for <see cref="Independent{TDistribution}"/>.
        /// </example>
        ///

        public void Fit(TObservation[][] observations, double[] weights = null,
                        IndependentOptions <TOptions> options           = null)
        {
            base.Fit(observations, weights, options);
        }