-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5pl.html
58 lines (47 loc) · 2.04 KB
/
5pl.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE html>
<html>
<head>
<title>5PL Curve Fit mit Funktion zur nichtlinearen Regression mit Anfangswerten</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.min.js"></script>
</head>
<body>
<script>
// Funktion für den 5PL-Curve-Fit
function fivePLCurveFit(x, top, bottom, EC50, slope, hillSlope) {
var response = bottom + ((top - bottom) / (1 + Math.pow((x / EC50), hillSlope))) * Math.pow((x / EC50), slope);
return response;
}
// Datenpunkte
var xData = [0.08, 0.15, 0.93, 0.96, 0.61, 0.49, 0.24]; // x-Werte Coverage
var yData = [0.13, 0.19, 0.78, 0.84, 0.52, 0.38, 0.25]; // y-Werte CE, J_B1, J_B2 ...
// Funktion zur nichtlinearen Regression mit Anfangswerten
var result = numeric.uncmin(function(params) {
var residuals = [];
for (var i = 0; i < xData.length; i++) {
var x = xData[i];
var y = yData[i];
var modelY = fivePLCurveFit(x, params[0], params[1], params[2], params[3], params[4]);
var residual = y - modelY;
residuals.push(residual);
}
return numeric.norm2(residuals);
}, [1, 1, 1, 1, 1]); // Anfangswerte
var fittedParams = result.solution;
// Ergebnisse ausgeben
console.log("Geschätzte Top:", fittedParams[0]);
console.log("Geschätzte Bottom:", fittedParams[1]);
console.log("Geschätztes EC50:", fittedParams[2]);
console.log("Geschätzter Slope:", fittedParams[3]);
console.log("Geschätzter Hill Slope:", fittedParams[4]);
// Generiere Vorhersagen für neue x-Werte mit den geschätzten Parametern
var new_x = [0.08, 0.15, 0.93, 0.96, 0.61, 0.49, 0.24];
var predictions = [];
for (var i = 0; i < new_x.length; i++) {
var x = new_x[i];
var prediction = fivePLCurveFit(x, fittedParams[0], fittedParams[1], fittedParams[2], fittedParams[3], fittedParams[4]);
predictions.push(prediction);
}
console.log("Vorhergesagte y-Werte:", predictions);
</script>
</body>
</html>