//public EM(EMbase model, EMConf emparam, Message msg) //{ // this.model = model; // this.msg = msg; // this.emparam = emparam; // init(); //} public EM(SRM model, EMConf emparam, IMessage msg) { this.model = model as IEMbase; this.msg = msg; this.emparam = emparam; Init(); }
public static void Test_herlall() { double[] time = { 2, 1, 2, 3, 2, 1 }; int[] num = { 0, 1, 1, 0, 2, 0 }; int[] type = { 0, 0, 0, 0, 0, 0 }; SRMData data = new SRMData(); data.SetData(time, num, type); EMConf emconf = new EMConf(); emconf.Progress = 10000; emconf.MaxIter = 1000000; emconf.StopCond = StopCondition.PARAMETER; //.LLF; HErlang.HErlangAll all = new HErlang.HErlangAll(5); all.FitAll(data, emconf, null); Console.WriteLine(all.GetModelName()); Console.WriteLine(all.GetParam().ToString()); Console.WriteLine(); Result result = all.Calc(data); print_result(result); }
public void Set(EMConf conf) { Atol = conf.Atol; Rtol = conf.Rtol; MaxIter = conf.MaxIter; PrintFlag = conf.PrintFlag; Progress = conf.Progress; StopCond = conf.StopCond; Cnt = conf.Cnt; Aerror = conf.Aerror; Rerror = conf.Rerror; Status = conf.Status; InitFlag = conf.InitFlag; Llf = conf.Llf; }
public static void Test_srm() { double[] time = { 2, 1, 2, 3, 2, 1 }; int[] num = { 0, 1, 1, 0, 2, 0 }; int[] type = { 0, 0, 0, 0, 0, 0 }; SRMData data = new SRMData(); data.SetData(time, num, type); SRM[] models = new SRM[11]; models[0] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.EXP); models[1] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.GAMMA); models[2] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.PARETO); models[3] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.TNORM); models[4] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.LNORM); models[5] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.TLOGIS); models[6] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.LLOGIS); models[7] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.TXVMAX); models[8] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.TXVMIN); models[9] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.LXVMAX); models[10] = SRMFactory.GetInstance().CreateSRM(OriginalSRMModel.LXVMIN); EMConf[] emconf = new EMConf[11]; EM[] em = new EM[11]; for (int i = 0; i < 11; i++) { emconf[i] = new EMConf(); em[i] = new EM(models[i], emconf[i], new MODELS.SRMConsoleMessage(models[i], emconf[i])); } for (int i = 0; i < 11; i++) { emconf[i].Progress = 1; emconf[i].StopCond = StopCondition.PARAMETER; em[i].Initialize(data); em[i].Fit(data); Console.WriteLine(emconf[i].Status); Result result = models[i].Calc(data); print_result(result); } }
public static void Test_cphem() { double[] time = { 2, 1, 2, 3, 2, 1 }; int[] num = { 0, 1, 1, 0, 2, 0 }; int[] type = { 0, 0, 0, 0, 0, 0 }; SRMData data = new SRMData(); data.SetData(time, num, type); int nm = 4; SRM[] models = new SRM[nm]; models[0] = new CPH.CPHEMSRM(new CPH.CPHParam(1)); models[1] = new CPH.CPHEMSRM(new CPH.CPHParam(2)); models[2] = new CPH.CPHEMSRM(new CPH.CPHParam(3)); models[3] = new CPH.CPHEMSRM(new CPH.CPHParam(4)); EMConf[] emconf = new EMConf[nm]; EM[] em = new EM[nm]; for (int i = 0; i < nm; i++) { emconf[i] = new EMConf(); em[i] = new EM(models[i], emconf[i], new MODELS.SRMConsoleMessage(models[i], emconf[i])); } for (int i = 0; i < nm; i++) { emconf[i].Progress = 1; emconf[i].StopCond = StopCondition.LLF; em[i].Initialize(data); em[i].Fit(data); Console.WriteLine(emconf[i].Status); Result result = models[i].Calc(data); print_result(result); } }