コード例 #1
0
        public AnnualCDF(List <Point> points)
        {
            var values = Utils.GetWYAnnualAverages(points);

            List <double> sorted_values;
            var           cdf = Utils.ComputeCDF(values, out sorted_values);

            Probability = cdf;
            Flow        = sorted_values;
            LNfit       = new LNFit(values);
        }
コード例 #2
0
        public MonthCDF(List <Point> points, int month)
        {
            var values = GetMonthlyData(points, month);

            List <double> sorted_values;
            List <double> cdf = Utils.ComputeCDF(values, out sorted_values);

            Month       = month;
            Probability = cdf;
            Flow        = sorted_values;
            LNfit       = new LNFit(values);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: xuexianwu/BiasCorrectQ
        private static double GetBiasCorrectedFlow(double value,
                                                   List <double> obs_flow, List <double> obs_exc, LNFit obs_stats,
                                                   List <double> sim_flow, List <double> sim_exc, LNFit sim_stats)
        {
            double rval;

            //if simulated value is zero return zero
            if (value > -0.001 && value < 0.001)
            {
                return(0);
            }

            double quantile = -1;
            double ln3anom  = (Math.Log(value) - sim_stats.lnmean) / sim_stats.lnstd;
            double thresh   = 3.5;

            //check if flow higher or lower than any quantile value
            bool outRangeFlow = (value > sim_flow[0] ||
                                 value < sim_flow[sim_flow.Count - 1]);

            if (!outRangeFlow)
            {
                quantile = Interpolate(value, sim_flow, sim_exc);
            }

            //check if quantile is out of range of observed quantile
            bool outRangeQuantile = (quantile > obs_exc[obs_exc.Count - 1] ||
                                     quantile < obs_exc[0] || outRangeFlow);

            if (outRangeQuantile)
            {
                rval = Math.Exp(obs_stats.lnstd * ln3anom + obs_stats.lnmean);
            }
            else
            {
                rval = Interpolate(quantile, obs_exc, obs_flow);
            }

            //if simulated value is sufficiently out of range as defined by
            //threshold value, use simple scaling technique
            if (ln3anom < (-1 * thresh) || ln3anom > thresh)
            {
                rval = value / sim_stats.mean * obs_stats.mean;
            }

            return(rval);
        }