From c980006f026e6041f11b0d53ea8be87bd5ea8454 Mon Sep 17 00:00:00 2001 From: 3011357 <3011357@stud.hs-mannheim.de> Date: Sun, 7 Jan 2024 17:02:40 +0100 Subject: [PATCH] =?UTF-8?q?stabw()=20Methode=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../informatik/spreadsheet/Spreadsheet.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 53ccd58..8484eaa 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -231,9 +231,22 @@ public class Spreadsheet { * @return The standard deviation calculated. */ private long stabw(String startCellName, String endCellName) { + long mean = mit(startCellName, endCellName); + long counter = counterOfCellsWithValue(startCellName, endCellName); + long result = 0; + for(char col = startCellName.charAt(0); col <= endCellName.charAt(0); col++) { - return 0; + for (int row = Integer.parseInt(startCellName.substring(1)); row <= Integer.parseInt(endCellName.substring(1)); row++) { + + String value = get((row - 1), (col - 'A')); + + if(!value.isEmpty()){ + result += (long) Math.pow(Long.parseLong(value) - mean, 2); + } + } + } + return (long) Math.sqrt(result / counter); } /**