Example #1
0
        public void Initialize(SRMData data)
        {
            Alloc(data);
            double[] p = { 2.0, 4.0, 8.0, 16.0, 32.0, 64.0 };
            SetPowerStructuredParameter(data, p[0]);
            double   maxllf   = DoEstimation(data, 5);
            CPHParam maxparam = param.Create() as CPHParam;

            param.CopyTo(maxparam);
            for (int i = 1; i < p.Length; i++)
            {
                SetPowerStructuredParameter(data, p[i]);
                double llf = DoEstimation(data, 5);
                if (maxllf < llf)
                {
                    maxllf = llf;
                    param.CopyTo(maxparam);
                }
            }
            for (int i = 0; i < p.Length; i++)
            {
                SetLinearStructuredParameter(data, p[i]);
                double llf = DoEstimation(data, 5);
                if (maxllf < llf)
                {
                    maxllf = llf;
                    param.CopyTo(maxparam);
                }
            }
            maxparam.CopyTo(param);
            CPHDist cph = dist as CPHDist;

            cph.ClearCache();
        }
Example #2
0
        public double Rdiff(IModelParam param)
        {
            CPHParam v = param as CPHParam;
            double   o = NMath.Abs(omega - v.omega) / v.omega;
            double   a = Blas.Rdiff(ndim, alpha, v.alpha);
            double   b = Blas.Rdiff(ndim, rate, v.rate);

            return(NMath.Max(o, a, b));
        }
Example #3
0
        public static void Test_cph()
        {
            double[]     alpha = { 1, 0 };
            double[]     rate  = { 100.0, 100.0 };
            CPH.CPHParam p     = new CPH.CPHParam(2, 1.0, alpha, rate);
            CPH.CPHDist  dist  = new CPH.CPHDist(2, p.GetAlpha, p.GetRate, p.GetLambda, p.GetScaledRate, 1.0e-8);

            double x = 0.0;

            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine(dist.Pdf(x));
                x += 0.01;
            }
        }
Example #4
0
        public void CopyTo(IModelParam p)
        {
            CPHParam v = p as CPHParam;

            if (ndim == v.ndim)
            {
                v.omega  = omega;
                v.lambda = lambda;
                Blas.Dcopy(ndim, alpha, v.alpha);
                Blas.Dcopy(ndim, rate, v.rate);
                Blas.Dcopy(ndim, scaledRate, v.scaledRate);
            }
            else
            {
                throw new InvalidCastException();
            }
        }
Example #5
0
        public CPHEMSRM(CPHParam param, double epsi = 1.0e-8)
            : base(param.N + "-CanonicalPH SRGM", 2 * param.N, param.GetOmega,
                   new CPHDist(param.N, param.GetAlpha, param.GetRate, param.GetLambda, param.GetScaledRate, epsi))
        {
            ndim       = param.N;
            this.param = param;
            this.epsi  = epsi;
            cuni       = new CPHUniformization(ndim, param.GetLambda, param.GetScaledRate);

            tmp = new double[ndim];
            h0  = new double[ndim * 2];
            pi2 = new double[ndim];

            //vf = new double[ndim];
            //vf2 = new double[ndim];

            eb  = new double[ndim];
            eb2 = new double[ndim];
            en  = new double[ndim * 2];
            ey  = new double[ndim];
        }