Accord.Statistics.Models.Markov.MarkovHelperMethods.convertNoCheck C# (CSharp) Method

convertNoCheck() static private method

Converts a univariate or multivariate array of observations into a two-dimensional jagged array.
static private convertNoCheck ( Array array, int dimension ) : double[][]
array System.Array
dimension int
return double[][]
        internal static double[][] convertNoCheck(Array array, int dimension)
        {
            double[][] multivariate = array as double[][];
            if (multivariate != null) return multivariate;

            double[] univariate = array as double[];
            if (univariate != null) return Accord.Math.Matrix.Split(univariate, dimension);

            throw new ArgumentException("Invalid array argument type.", "array");
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        ///   Predicts the next observation occurring after a given observation sequence.
        /// </summary>
        ///
        public double[] Predict(double[] observations, int next, out double logLikelihood)
        {
            if (multivariate)
            {
                throw new ArgumentException("Model is multivariate.", "observations");
            }

            if (observations == null)
            {
                throw new ArgumentNullException("observations");
            }


            // Convert to multivariate observations
            double[][] obs = MarkovHelperMethods.convertNoCheck(observations, dimension);

            // Matrix to store the probabilities in assuming the next
            // observations (prediction) will belong to each state.
            double[][] weights;

            // Compute the next observations
            double[][] prediction = predict(obs, next, out logLikelihood, out weights);

            // Return the first (single) dimension of the next observations.
            return(Accord.Math.Matrix.Concatenate(prediction));
        }
All Usage Examples Of Accord.Statistics.Models.Markov.MarkovHelperMethods::convertNoCheck