public void Setup()
 {
     this.generator = new GaussianRandomGenerator();
     this.numberOfGeneratedNumbers = 100000;
     this.mean         = new Double[] { 0, 1, 10, -10, 100, -100, 10000, -10000, 10, 10 };
     this.stdDeviation = new Double[] { 1, 1, 5, 5, 10, 10, 100, 100, 0.1, 0.1 };
     this.error        = new Double[] { 0.01, 0.1, 0.1, 0.1, 1, 1, 1, 1, 0.01, 0.01 };
 }
Exemple #2
0
 public void Setup()
 {
     _generator = new GaussianRandomGenerator();
     _numberOfGeneratedNumbers = 100000;
     _mean         = new Double[] { 0, 1, 10, -10, 100, -100, 10000, -10000, 10, 10 };
     _stdDeviation = new Double[] { 1, 1, 5, 5, 10, 10, 100, 100, 0.1, 0.1 };
     _error        = new Double[] { 0.01, 0.05, 0.05, 0.05, 0.1, 0.1, 1, 1, 0.005, 0.005 };
 }
Exemple #3
0
        /// <summary>
        /// Creates the initial clusters.
        /// </summary>
        private void CreateInitialClusters()
        {
            // compute median and std. deviation
            Double[] mean = new Double[Source.Raster.NumberOfBands];
            Double[] standardDeviation = new Double[Source.Raster.NumberOfBands];

            for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
            {
                mean[bandIndex] = 0;
                standardDeviation[bandIndex] = 0;

                for (Int32 rowIndex = 0; rowIndex < Source.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < Source.Raster.NumberOfColumns; columnIndex++)
                    {
                        mean[bandIndex] += Source.Raster.GetFloatValue(rowIndex, columnIndex, bandIndex);
                    }
                }

                mean[bandIndex] /= (Source.Raster.NumberOfColumns * Source.Raster.NumberOfRows);

                for (Int32 rowIndex = 0; rowIndex < Source.Raster.NumberOfRows; rowIndex++)
                {
                    for (Int32 columnIndex = 0; columnIndex < Source.Raster.NumberOfColumns; columnIndex++)
                    {
                        standardDeviation[bandIndex] += Math.Pow(Source.Raster.GetFloatValue(rowIndex, columnIndex, bandIndex) - mean[bandIndex], 2);
                    }
                }

                standardDeviation[bandIndex] = Math.Sqrt(standardDeviation[bandIndex] / (Source.Raster.NumberOfRows * Source.Raster.NumberOfColumns - 1));
            }

            // generate the initial clusters
            _clusterCenters = new Double[_numberOfClusters][];
            GaussianRandomGenerator randomGenerator = new GaussianRandomGenerator();

            for (Int32 clusterIndex = 0; clusterIndex < _numberOfClusters; clusterIndex++)
            {
                Double[] randomNumbers = new Double[Source.Raster.NumberOfBands];

                for (Int32 bandIndex = 0; bandIndex < Source.Raster.NumberOfBands; bandIndex++)
                {
                    randomNumbers[bandIndex] = randomGenerator.NextDouble(mean[bandIndex], standardDeviation[bandIndex]);
                }

                _clusterCenters[clusterIndex] = randomNumbers;
            }
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GaussianRandomGenerator obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(GaussianRandomGenerator obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }