Prechádzať zdrojové kódy

添加weibull、指数、正态分布、对数正态分布可靠度计算

hecs 4 mesiacov pred
rodič
commit
034f2c01b9

+ 73 - 0
nationrel-module-fta-api/src/main/java/com/nationrel/modules/fta/util/ReliabilityAlgorithmUtil.java

@@ -0,0 +1,73 @@
+package com.nationrel.modules.fta.util;
+
+import org.apache.commons.math3.distribution.LogNormalDistribution;
+import org.apache.commons.math3.distribution.NormalDistribution;
+
+public class ReliabilityAlgorithmUtil {
+
+    /**
+     * 指数分布可靠度算法
+     *
+     * @param lambda
+     * @param gamma
+     * @param time
+     * @return
+     */
+    public static double exponentialReliability(double lambda, double gamma, double time) {
+        // TODO 根据实际情况添加判断
+        if (lambda <= 0 || time < 0) {
+            throw new IllegalArgumentException("lambda and x must be positive");
+        }
+        return Math.exp(-lambda * (time - gamma));
+    }
+
+    /**
+     * WEIBULL分布可靠度算法
+     *
+     * @param time
+     * @param beta
+     * @param eta
+     * @return
+     */
+    public static double weibullReliability(double beta, double eta, double gamma, double time) {
+        // TODO 根据实际情况添加判断
+        if (time < 0 || beta <= 0 || eta <= 0) {
+            return 0;
+        }
+        return Math.exp(-Math.pow((time - gamma) / eta, beta));
+    }
+
+    /**
+     * normal分布可靠度算法
+     *
+     * @param time
+     * @param mean
+     * @param sigma
+     * @return
+     */
+    public static double normalReliability(double mean, double sigma, double time) {
+        // TODO 根据实际情况添加判断
+        if (time < 0 || mean <= 0 || sigma <= 0) {
+            return 0;
+        }
+        NormalDistribution normalDistribution = new NormalDistribution(sigma, sigma);
+        return  1 - normalDistribution.cumulativeProbability(time);
+    }
+
+    /**
+     * logNormal分布可靠度算法
+     *
+     * @param time
+     * @param logMean
+     * @param logSigma
+     * @return
+     */
+    public static double logNormalReliability(double logMean, double logSigma, double time) {
+        // TODO 根据实际情况添加判断
+        if (time < 0 || logMean <= 0 || logSigma <= 0) {
+            return 0;
+        }
+        LogNormalDistribution logNormalDistribution = new LogNormalDistribution(logMean, logSigma);
+        return  1 - logNormalDistribution.cumulativeProbability(time);
+    }
+}