コード例 #1
0
        ///<summary>
        /// Gets a list of aircraft positions at a time.
        /// Querying the latest position entry per aircraft but not older than ttl back in history
        /// and estimating the position at given time
        /// <param name="at">The given time. </param>
        /// <param name="ttl">"Time To Live": discard positions which are older than ttl [min]. </param>
        ///
        /// </summary>
        public List <AircraftPositionDesignator> AircraftPositionGetAllLatest(DateTime at, int ttl)
        {
            List <AircraftPositionDesignator> l = new List <AircraftPositionDesignator>();
            int       to     = SupportFunctions.DateTimeToUNIXTime(at);
            int       from   = to - ttl * 60;
            DataTable Result = db.Select("SELECT Hex, Call, Lat, Lon, Alt, Track, Speed, max(Lastupdated) AS LastUpdated FROM " + AircraftPositionDesignator.TableName + " WHERE LastUpdated >= " + from.ToString() + " AND LastUpdated <= " + to.ToString() + " GROUP BY Hex");

            if (!IsValid(Result) || (Result.Rows.Count == 0))
            {
                return(l);
            }
            foreach (DataRow row in Result.Rows)
            {
                AircraftPositionDesignator ap = new AircraftPositionDesignator(row);
                //estimate new position
                // change speed to km/h
                double speed = ap.Speed * 1.852;
                // calculate distance after timespan
                double dist = speed * (at - ap.LastUpdated).TotalHours;
                // estimate new position
                LatLon.GPoint newpos = LatLon.DestinationPoint(ap.Lat, ap.Lon, ap.Track, dist);
                ap.Lat = newpos.Lat;
                ap.Lon = newpos.Lon;
                l.Add(ap);
            }
            return(l);
        }
コード例 #2
0
        public List <PlaneInfo> PlaneInfoGetAll(DateTime newerthan)
        {
            List <PlaneInfo> l = new List <PlaneInfo>();
            int i = SupportFunctions.DateTimeToUNIXTime(newerthan);
            // SELECT max(AircraftPositions.Lastupdated) AS LastUpdated, Call, Reg, AircraftPositions.Hex, Lat, Lon, Track, Alt, Speed, TypeCode, Manufacturer, Model, Category FROM AircraftPositions INNER JOIN Aircrafts ON AircraftPositions.Hex = Aircrafts.Hex INNER JOIN AircraftTypes ON AircraftTypes.ICAO = Aircrafts.TypeCode WHERE AircraftPositions.LastUpdated > 1500000 GROUP BY AircraftPositions.Hex
            DataTable Result = db.Select("SELECT max(AircraftPositions.Lastupdated) AS LastUpdated, Call, Reg, AircraftPositions.Hex, Lat, Lon, Track, Alt, Speed, TypeCode, Manufacturer, Model, Category FROM AircraftPositions INNER JOIN Aircrafts ON AircraftPositions.Hex = Aircrafts.Hex INNER JOIN AircraftTypes ON AircraftTypes.ICAO = Aircrafts.TypeCode WHERE AircraftPositions.LastUpdated > " + i.ToString() + " GROUP BY AircraftPositions.Hex");

            if (!IsValid(Result) || (Result.Rows.Count == 0))
            {
                return(l);
            }
            foreach (DataRow row in Result.Rows)
            {
                PlaneInfo info = new PlaneInfo(row);
                try
                {
                    l.Add(info);
                }
                catch (Exception ex)
                {
                    Log.WriteMessage("Error inserting PlaneInfo[" + info.ToString() + "]: " + ex.ToString(), LogLevel.Error);
                }
            }
            return(l);
        }
コード例 #3
0
        public void Matrix_QR_Givens_Rotation_2_row_symmetric_test_2()
        {
            InitData_dataset_2_rows_symmetric_eigenValue();
            double[][] Q = null;
            double[][] R = null;
            _mo.QRDecomposition_Givens_Rotation(_matrix1, ref Q, ref R);

            //Verify R is upper triangular
            Assert.IsTrue(_mo.IsUpperTriangular(R));

            //---Veriy if A = Q.R
            double[][] T = _mo.Multiply(Q, R);
            Assert.IsTrue(_mo.CompareMatrix(_matrix1, T));

            Assert.IsTrue(SupportFunctions.DoubleCompare(R[0][0], 2.23));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[0][1], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[1][0], 1.78));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[1][1], 1.34));


            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[0][0], .89));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[0][1], .44));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[1][0], -.44));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[1][1], .89));
        }
コード例 #4
0
        public void Statictics_CoVariance_1()
        {
            InitData_dataset_pca_example();
            double value = Dispersion.CoVarianceSample(_trainingData[0], _trainingData[1]);

            Assert.IsTrue(SupportFunctions.DoubleCompare(value, .6154));
        }
コード例 #5
0
        public void NN_activation_function_linear()
        {
            Linear aFunc = new Linear();
            double value = aFunc.GetValue(3.0);

            Assert.IsTrue(SupportFunctions.DoubleCompare(value, 3.00));
        }
コード例 #6
0
        public void NN_activation_function_sigmoid()
        {
            Sigmoid aFunc = new Sigmoid();
            double  value = aFunc.GetValue(3.0);

            Assert.IsTrue(SupportFunctions.DoubleCompare(value, 0.9526));
        }
コード例 #7
0
        public void Matrix_QR_Householder_3_row_test_0()
        {
            InitData_dataset_3_rows_symmetric_givens_rotation();
            double[][] Q = null;
            double[][] R = null;

            _mo.QRDecomposition_Householder(_matrix1, ref Q, ref R);

            Assert.IsTrue(SupportFunctions.DoubleCompare(R[0][0], 7.81));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[0][1], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[0][2], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(R[1][0], 4.48));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[1][1], 4.68));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[1][2], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(R[2][0], 2.56));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[2][1], .96));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[2][2], -4.18));

            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[0][0], .76));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[0][1], .64));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[0][2], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[1][0], .3327));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[1][1], -.39));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[1][2], .85));

            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[2][0], .54));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[2][1], -.65));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[2][2], -.51));
        }
コード例 #8
0
        public void Matrix_hessenberg_4_row_test_1()
        {
            InitData_dataset_4_rows_symmetric_hessenberg();
            //Convert Matrix 1 to Hessenberg

            _matrix1[0][2] = 0;
            _matrix1[0][3] = 0;
            _matrix1[1][3] = 0;

            double[][] U         = null;
            double[][] newMatrix =
                _mo.Hessenberg(_matrix1, ref U);

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][0], 4));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][1], 1));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][2], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][3], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][0], 1));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][1], 2));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][2], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][3], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][0], -2));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][1], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][2], 3));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][3], -2));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][0], 2));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][1], 1));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][2], -2));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][3], -1));
        }
コード例 #9
0
ファイル: ModelBase.cs プロジェクト: Dasmic/MLLib
 Get2DArray(int cols, int rows)
 {
     double[][] array2D =
         SupportFunctions.Get2DArray(cols,
                                     rows, _maxParallelThreads);
     return(array2D);
 }
コード例 #10
0
        /// <summary>
        /// Compares 2 batrices and returns true if there are same
        /// </summary>
        /// <param name="matrix1"></param>
        /// <param name="matrix2"></param>
        /// <returns></returns>
        public bool CompareMatrix(double[][] matrix1,
                                  double[][] matrix2)
        {
            bool flag = true;

            if (matrix1.Length != matrix2.Length)
            {
                return(false);
            }
            if (matrix1[0].Length != matrix2[0].Length)
            {
                return(false);
            }

            for (int col = 0; col < matrix1.Length; col++)
            {
                for (int row = 0; row < matrix1[0].Length; row++)
                {
                    if (!SupportFunctions.DoubleCompare(matrix1[col][row],
                                                        matrix2[col][row]))
                    {
                        flag = false;
                        break;
                    }
                }
            }
            return(flag);
        }
コード例 #11
0
ファイル: ModelBase.cs プロジェクト: Dasmic/MLLib
 /// <summary>
 /// Returns a Single Rows of Data from a 2D array
 /// </summary>
 /// <param name="mainArray"></param>
 /// <param name="mainArrayRowIdx"></param>
 /// <param name="endColumnIdx"></param>
 /// <returns></returns>
 public double[] GetSingleRowData(double[][] mainArray,
                                  long mainArrayRowIdx, int endColumnIdx)
 {
     double[] data = SupportFunctions.GetLinearArray(mainArray,
                                                     mainArrayRowIdx, endColumnIdx);
     return(data);
 }
コード例 #12
0
        public void NN_perceptron_single_sgd_all_training_samples()
        {
            initData_NN_dataset_linear_subgd_jason_example();
            BuildSingleUnitPerceptronSGD build = new BuildSingleUnitPerceptronSGD();

            setPrivateVariablesInBuildObject(build);

            //Set params
            //build.setParameters(1,1,.45);


            ModelSingleUnitPerceptron model =
                (ModelSingleUnitPerceptron)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            int count = 0;

            for (int row = 0; row < _trainingData[0].Length; row++)
            {
                double[] data  = GetSingleTrainingRowDataForTest(row);
                double   value = model.RunModelForSingleData(data);
                if (SupportFunctions.DoubleCompare(value, _trainingData[_indexTargetAttribute][row]))
                {
                    count++;
                }
            }

            Assert.AreEqual(count,
                            10);
        }
コード例 #13
0
            public void GetBytes(byte[] buffer)
            {
                int byteCount = buffer.Length;

                byte[] randomBuffer = SupportFunctions.GenerateSecureRandomBytes(byteCount);
                Array.Copy(randomBuffer, buffer, byteCount);
            }
コード例 #14
0
        public void NN_perceptron_multi_all_training_samples_gnb()
        {
            initData_dataset_gaussian_naive_bayes_jason_example();
            BuildMultiUnitPerceptronSGD build =
                new BuildMultiUnitPerceptronSGD();

            ModelMultiUnitPerceptron model =
                (ModelMultiUnitPerceptron)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            int count = 0;

            for (int row = 0; row < 10; row++)
            {
                double[] data  = GetSingleTrainingRowDataForTest(row);
                double   value = model.RunModelForSingleData(data);

                if (SupportFunctions.DoubleCompare(value,
                                                   _trainingData[_indexTargetAttribute][row]))
                {
                    count++;
                }
            }

            Assert.AreEqual(count,
                            10);
        }
コード例 #15
0
        public void PCA_new_matrix_3_rows_rank_3_1()
        {
            InitData_dataset_3_rows_non_symmetric();
            PrincipalComponentAnalysis pca = new PrincipalComponentAnalysis();

            pca.Rank = 3;
            double[][] rotationMatrix    = null;
            double[]   standardDeviation = null;
            double[][] newMatrix         = pca.GetPrincipleFeatures(_trainingData,
                                                                    _attributeHeaders, ref standardDeviation, ref rotationMatrix);

            Assert.AreEqual(newMatrix.Length, 3);
            Assert.AreEqual(newMatrix[0].Length, _trainingData[0].Length);

            Assert.IsTrue(SupportFunctions.DoubleCompare(standardDeviation[0], 1.73));
            Assert.IsTrue(SupportFunctions.DoubleCompare(standardDeviation[1], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(standardDeviation[2], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[0][0], .57));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[0][1], .57));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[0][2], .57));

            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[1][0], -.81));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[1][1], .40));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[1][2], .40));

            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[2][0], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[2][1], -.70));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[2][2], .70));
        }
コード例 #16
0
        public void Matrix_hessenberg_4_row_test_0()
        {
            InitData_dataset_4_rows_symmetric_hessenberg();
            double[][] U         = null;
            double[][] newMatrix =
                _mo.Hessenberg(_matrix1, ref U);


            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][0], 4));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][1], 3));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][2], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][3], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][0], 3));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][1], 10.0 / 3.0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][2], 5.0 / 3.0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][3], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][0], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][1], 5.0 / 3.0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][2], -33.0 / 25.0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][3], -68.0 / 75.0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][0], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][1], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][2], -68.0 / 75.0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[3][3], 149.0 / 75.0));
        }
コード例 #17
0
        public void PCA_new_matrix_3_rows_rank_2_0()
        {
            InitData_dataset_3_rows_symmetric_hessenberg();
            PrincipalComponentAnalysis pca = new PrincipalComponentAnalysis();

            pca.Rank = 2;
            double[][] rotationMatrix    = null;
            double[]   standardDeviation = null;
            double[][] newMatrix         = pca.GetPrincipleFeatures(_trainingData,
                                                                    _attributeHeaders, ref standardDeviation, ref rotationMatrix);

            Assert.AreEqual(newMatrix.Length, 2);
            Assert.AreEqual(standardDeviation.Length, 2);
            Assert.AreEqual(rotationMatrix.Length, 2);

            Assert.IsTrue(SupportFunctions.DoubleCompare(standardDeviation[0], 1.26));
            Assert.IsTrue(SupportFunctions.DoubleCompare(standardDeviation[1], .85));


            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[0][0], .29));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[0][1], .60));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[0][2], -.74));

            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[1][0], -.52));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[1][1], .75));
            Assert.IsTrue(SupportFunctions.DoubleCompare(rotationMatrix[1][2], .40));
        }
コード例 #18
0
        public void Matrix_hessenberg_3_row_test_2()
        {
            InitData_dataset_3_rows_symmetric_givens_rotation();
            double[][] U         = null;
            double[][] newMatrix =
                _mo.Hessenberg(_matrix1, ref U);

            //U is null as matrix is already householder
            Assert.IsNull(U);

            Assert.AreEqual(newMatrix.Length, 3);
            Assert.AreEqual(newMatrix[0].Length, 3);

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][0], 6));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][1], 5));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[0][2], 0));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][0], 5));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][1], 1));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[1][2], 4));

            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][0], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][1], 4));
            Assert.IsTrue(SupportFunctions.DoubleCompare(newMatrix[2][2], 3));
        }
コード例 #19
0
        public void NN_backpropagation_2L_nb_custom_activation_SigSig_all_training_samples()
        {
            initData_dataset_naive_bayes_jason_example();
            Build2LBackPropagation build =
                new Build2LBackPropagation();

            build.SetParameters(1);

            build.SetActivationFunction(0, new Dasmic.MLLib.Algorithms.NeuralNetwork.Support.ActivationFunction.Sigmoid());
            build.SetActivationFunction(1, new Dasmic.MLLib.Algorithms.NeuralNetwork.Support.ActivationFunction.Sigmoid());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            int count = 0;

            for (int row = 0; row < 10; row++)
            {
                double[] data  = GetSingleTrainingRowDataForTest(row);
                double   value = model.RunModelForSingleData(data);

                if (SupportFunctions.DoubleCompare(value,
                                                   _trainingData[_indexTargetAttribute][row]))
                {
                    count++;
                }
            }

            //Due to random weights
            Assert.IsTrue(count >= 8 && count <= 10);
        }
コード例 #20
0
        public void NN_activation_function_hyperbolictangent()
        {
            HyperbolicTangent aFunc = new HyperbolicTangent();
            double            value = aFunc.GetValue(3.0);

            Assert.IsTrue(SupportFunctions.DoubleCompare(value, 0.9950));
        }
コード例 #21
0
        public void NN_backpropagation_2L_gnb_all_training_samples()
        {
            initData_dataset_gaussian_naive_bayes_jason_example();
            Build2LBackPropagation build =
                new Build2LBackPropagation();

            build.SetParameters(1);

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            int count = 0;

            for (int row = 0; row < 10; row++)
            {
                double[] data  = GetSingleTrainingRowDataForTest(row);
                double   value = model.RunModelForSingleData(data);

                if (SupportFunctions.DoubleCompare(value,
                                                   _trainingData[_indexTargetAttribute][row]))
                {
                    count++;
                }
            }

            Assert.AreEqual(count,
                            10);
        }
コード例 #22
0
        public void Matrix_QR_Givens_Rotation_2_row_non_symmetric_test_1()
        {
            InitData_dataset_2_rows_householder();
            double[][] Q = null;
            double[][] R = null;

            _mo.QRDecomposition_Givens_Rotation(_matrix1, ref Q, ref R);

            //Verify R is upper triangular
            Assert.IsTrue(_mo.IsUpperTriangular(R));

            //---Veriy if A = Q.R
            double[][] T = _mo.Multiply(Q, R);
            Assert.IsTrue(_mo.CompareMatrix(_matrix1, T));

            Assert.IsTrue(SupportFunctions.DoubleCompare(R[0][0], 5));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[0][1], 0));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[1][0], 2.4));
            Assert.IsTrue(SupportFunctions.DoubleCompare(R[1][1], -3.2));


            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[0][0], .6));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[0][1], .8));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[1][0], -.8));
            Assert.IsTrue(SupportFunctions.DoubleCompare(Q[1][1], .6));
        }
コード例 #23
0
        public void NN_backpropagation_generic_std_3L_gnb_all_training_samples()
        {
            initData_dataset_gaussian_naive_bayes_jason_example();
            BuildGenericBackPropagationStandard build =
                new BuildGenericBackPropagationStandard();

            build.SetParameters(1, 2, .5, 1500);
            //build.SetNumberOfHiddenLayers(2);
            build.AddHiddenLayer(0, 2, new Sigmoid());
            build.AddHiddenLayer(1, 2, new Sigmoid());
            build.SetOutputLayerActivationFunction(new Sigmoid());

            ModelBackPropagationBase model =
                (ModelBackPropagationBase)build.BuildModel(
                    _trainingData, _attributeHeaders,
                    _indexTargetAttribute);

            int count = 0;

            for (int row = 0; row < 10; row++)
            {
                double[] data  = GetSingleTrainingRowDataForTest(row);
                double   value = model.RunModelForSingleData(data);

                if (SupportFunctions.DoubleCompare(value,
                                                   _trainingData[_indexTargetAttribute][row]))
                {
                    count++;
                }
            }
            //Due to random weights
            Assert.IsTrue(count >= 5);
        }
コード例 #24
0
        public void Statistics_Pdf_Example_3()
        {
            DistributionNormal snd =
                new DistributionNormal();
            double value = snd.ProbabilityDensityFunction(4, 0, 1);

            Assert.IsTrue(SupportFunctions.DoubleCompare(value, .0001));
        }
コード例 #25
0
 public ApplicantAddedLogEntry(Applicant newApplicant)
 {
     this.ApplicantId = newApplicant.Identity;
     if (HttpContext.Current != null)
     {
         ActingIPAddress = SupportFunctions.GetMostLikelyRemoteIPAddress();
     }
 }
コード例 #26
0
 public new void Launch()
 {
     if ((this.Name == "Shoot" && SupportFunctions.HaveWand()) || (this.Name == "Attack" && !SupportFunctions.HaveWand()))
     {
         SupportFunctions.ActivateAutoAttack(this);
         return;
     }
     base.Launch(this.stopMove, this.waitIsCast);
 }
コード例 #27
0
        private void PrintResultHelper(object result)
        {
            if (result is bool)
            {
                buffer.Write((bool)result ? "True" : "False");
            }
            else if (result is Stringish || result is long || result is double)
            {
                buffer.Write("{0}", HttpUtility.HtmlEncode(result));
            }
            else if (result is byte[])
            {
                buffer.Write("{0} bytes of Unspeakable Horror", ((byte[])result).Length);
            }
            else if (result is Template)
            {
                buffer.Write("Template {");
                foreach (var attr in ((Template)result).GetAttributeNames())
                {
                    buffer.Write(" {0}", attr);
                }
                buffer.Write(" }");
            }
            else if (result is Frame)
            {
                var frame_result = (Frame)result;
                if (result_seen.ContainsKey(frame_result))
                {
                    buffer.Write("<a href='#{0}'>Frame {0}</a>", frame_result.Id);
                    return;
                }
                if (filter_lib && frame_result.Container == frame_result && frame_result.SourceReference is BasicSourceReference && ((BasicSourceReference)frame_result.SourceReference).FileName != "web")
                {
                    buffer.Write("<p>Library {0} (not shown)</p>", ((BasicSourceReference)frame_result.SourceReference).FileName);
                    return;
                }
                result_seen[frame_result] = true;
                buffer.Write("<p>Frame {0}</p><table id='{0}' title='{0}'>", frame_result.Id);
                foreach (var attr_name in frame_result.GetAttributeNames())
                {
                    var type = frame_result[attr_name].GetType();
                    buffer.Write("<tr class='{1}' title='{1}'><td>{0}</td><td>", attr_name, typeof(Future).IsAssignableFrom(type) ? "Comp" : SupportFunctions.NameForType(type));
                    PrintResultHelper(frame_result[attr_name]);
                    buffer.Write("</td></tr>");
                }

                buffer.Write("</table>");
            }
            else if (result is Future)
            {
                buffer.Write("Unfinished computation");
            }
            else
            {
                buffer.Write("Unknown value of type {0}.", SupportFunctions.NameForType(result.GetType()));
            }
        }
コード例 #28
0
        private double computeKernel(long row1, long row2)
        {
            double value = 0;

            double[] point1 = SupportFunctions.GetLinearArray(_trainingData, row1, _trainingData.Length - 2);
            double[] point2 = SupportFunctions.GetLinearArray(_trainingData, row2, _trainingData.Length - 2);

            value = _kernel.compute(point1, point2);
            return(value);
        }
コード例 #29
0
        public void Statictics_CoVariance_matrix_2_cols_1()
        {
            InitData_dataset_pca_example();
            double[][] matrix = Dispersion.CovarianceMatrixSample(_trainingData);

            Assert.IsTrue(SupportFunctions.DoubleCompare(matrix[0][0], .6165));
            Assert.IsTrue(SupportFunctions.DoubleCompare(matrix[0][1], .6154));
            Assert.IsTrue(SupportFunctions.DoubleCompare(matrix[1][0], .6154));
            Assert.IsTrue(SupportFunctions.DoubleCompare(matrix[1][1], .7165));
        }
コード例 #30
0
 public PersonAddedLogEntry(Participation participation, Person actingPerson)
 {
     DateTime        = System.DateTime.UtcNow;
     ParticipationId = participation.Identity;
     ActingPersonId  = actingPerson.Identity;
     if (HttpContext.Current != null)
     {
         ActingIPAddress = SupportFunctions.GetMostLikelyRemoteIPAddress();
     }
 }