예제 #1
0
        /// <summary>
        /// Analyzes the multiple correspondence of the specified
        /// categorical data set.
        /// </summary>
        /// <param name="dataSet">The data set to analyze.</param>
        /// <returns>The multiple correspondence of the specified data set.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="dataSet"/> is <b>null</b>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The disjoint form of parameter <paramref name="dataSet"/> has at least a non
        /// positive marginal sum.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The Singular Value Decomposition needed to acquire
        /// the correspondence cannot be executed or does not converge.<br/>
        /// -or-<br/>
        /// No principal variable has positive variance.
        /// The principal information cannot be acquired.
        /// </exception>
        public static MultipleCorrespondence Analyze(
            CategoricalDataSet dataSet)
        {
            if (dataSet is null)
            {
                throw new ArgumentNullException(nameof(dataSet));
            }

            var disjunctiveProtocol = dataSet.Disjoin();

            Correspondence correspondence;

            try
            {
                correspondence = Correspondence.Analyze(
                    disjunctiveProtocol);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new ArgumentOutOfRangeException(nameof(dataSet),
                                                      ImplementationServices.GetResourceString(
                                                          "STR_EXCEPT_GDA_MCA_NON_POSITIVE_MARGINAL_SUMS"));
            }
            catch (Exception)
            {
                throw;
            }

            var multipleCorrespondence = new MultipleCorrespondence
            {
                correspondence = correspondence
            };

            return(multipleCorrespondence);
        }
예제 #2
0
        /// <summary>
        /// Analyzes the correspondence of the specified data.
        /// </summary>
        /// <param name="data">The data to analyze.</param>
        /// <returns>
        /// The correspondence of the specified data.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="data"/> is <b>null</b>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Parameter <paramref name="data"/> has at least a non
        /// positive marginal sum.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The Singular Value Decomposition needed to acquire
        /// the correspondence cannot be executed or does not converge.<br/>
        /// -or-<br/>
        /// No principal variable has positive variance.
        /// The principal information cannot be acquired.
        /// </exception>
        public static Correspondence Analyze(DoubleMatrix data)
        {
            if (data is null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            PrincipalProjections.FromReciprocalAveraging(
                data: data,
                rowPrincipalProjections:
                out PrincipalProjections rowPrincipalProjections,
                columnPrincipalProjections:
                out PrincipalProjections columnPrincipalProjections);

            var correspondence = new Correspondence
            {
                RowProfiles    = rowPrincipalProjections,
                ColumnProfiles = columnPrincipalProjections
            };

            return(correspondence);
        }