Exemple #1
0
        public double StaticNS3FactorModelObjfun(double[] para)
        {
            var sns3factor = new StaticNS3FactorModel();

            sns3factor.beta1  = para[0];
            sns3factor.beta2  = para[1];
            sns3factor.beta3  = para[2];
            sns3factor.lambda = para[3];
            sns3factor.tau    = maturities;
            var modelyields = sns3factor.GetYield();
            var error       = 0.0;

            if (checkpara(sns3factor) == false)
            {
                error = 9999999999999999.99;
            }
            else
            {
                for (int i = 0; i < yields.Length; i++)
                {
                    var temperror = (modelyields[i] - yields[i]);
                    error = error + temperror * temperror;
                }
            }
            return(error);
        }
Exemple #2
0
        public bool checkpara(StaticNS3FactorModel n3factor)
        {
            var result = true;

            if (n3factor.beta1 + n3factor.beta2 <= 0)
            {
                result = false;
            }
            return(result);
        }
Exemple #3
0
        public double[] CalculateModelOutput(double[] tau, double[] para)
        {
            var sns3factor = new StaticNS3FactorModel();

            sns3factor.beta1  = para[0];
            sns3factor.beta2  = para[1];
            sns3factor.beta3  = para[2];
            sns3factor.lambda = para[3];
            sns3factor.tau    = tau;
            var modelyields = sns3factor.GetYield();

            return(modelyields);
        }