diff --git a/ex3/README.md b/ex3/README.md index ddffa45..fcbbbfb 100644 --- a/ex3/README.md +++ b/ex3/README.md @@ -18,7 +18,7 @@ **[Script Scilab](scripts/ex3-1.sce) :** ```scilab -tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)) * 100; +tauxAccroissement = (data(:, 4) / 1000) - (data(:, 5) / 1000); tauxAccroissementMin = min(tauxAccroissement) tauxAccroissementMax = max(tauxAccroissement) ``` @@ -86,7 +86,7 @@ mean(tauxAccroissement); ```scilab tauxAccroissementMoyenParContient = [mean(tauxAccroissement(1:57)), mean(tauxAccroissement(58:86)), mean(tauxAccroissement(87:99)), mean(tauxAccroissement(100:150)), mean(tauxAccroissement(151:193)), mean(tauxAccroissement(194:207))]; -bar(tauxAccroissementMoyenParContient) +bar(tauxAccroissementMoyenParContient * 100) ``` **Résultat :** @@ -107,7 +107,7 @@ population2050 = sum(data(:, 6)*1000000) x = population; while population2050 > x - x = x * tauxAccroissementMoyen; + x = x * (1+tauxAccroissementMoyen); end ``` @@ -117,7 +117,7 @@ end - La population mondiale prévue en 2050 n'est pas conforme à l'hypothèse d'un taux d'accroissement constant car en multipliant la population mondiale actuelle (7 534 720 000) par le taux d'accroissement moyen (1.32%) jusqu'à atteindre ou dépasser la population mondiale prévue en 2050 (9 848 330 000), on obtient une prévision largement - supérieur à la population mondiale prévue en 2050 (+ 70 564 686). + supérieur à la population mondiale prévue en 2050 (+ 67 843 751). --- diff --git a/ex3/scripts/ex3-1.sce b/ex3/scripts/ex3-1.sce index 50380ab..f652f7c 100644 --- a/ex3/scripts/ex3-1.sce +++ b/ex3/scripts/ex3-1.sce @@ -2,12 +2,12 @@ data = csvRead("data.csv"); // Calcul du taux d'accroissement à partir du taux de natalité et du taux de mortalité // On divise par 1000 pour avoir les taux par habitant -// On multiplie par 100 pour avoir le taux d'accroissement en pourcentage -tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)) * 100; +tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)); // Récupération du taux le plus faible et du taux le plus élevé de la liste tauxAccroissementMin = min(tauxAccroissement); tauxAccroissementMax = max(tauxAccroissement); -mprintf('Taux d''accroissement minimal : %.2f%%\n', tauxAccroissementMin); -mprintf('Taux d''accroissement maximal : %.2f%%\n', tauxAccroissementMax); +// On multiplie par 100 pour avoir le taux d'accroissement en pourcentage +mprintf('Taux d''accroissement minimal : %.2f%%\n', tauxAccroissementMin * 100); +mprintf('Taux d''accroissement maximal : %.2f%%\n', tauxAccroissementMax * 100); diff --git a/ex3/scripts/ex3-2.sce b/ex3/scripts/ex3-2.sce index a180804..b81be18 100644 --- a/ex3/scripts/ex3-2.sce +++ b/ex3/scripts/ex3-2.sce @@ -1,6 +1,6 @@ data = csvRead("data.csv"); -tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)) * 100; +tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)); // Récupération des pays // une matrice peut avoir qu'un seul type de données, donc la 1ère colonne de la variable data est NaN @@ -9,4 +9,4 @@ pays = csvRead("data.csv",",",".","string")(:,1) mprintf('Pays ayant un taux d''accroissement négatif :\n'); // on affiche les pays ayant un taux d'accroissement négatif -mprintf("- %s : %.2f%%\n",pays(tauxAccroissement < 0), tauxAccroissement(tauxAccroissement < 0)); +mprintf("- %s : %.2f%%\n",pays(tauxAccroissement < 0), (tauxAccroissement(tauxAccroissement < 0) * 100)); diff --git a/ex3/scripts/ex3-4.sce b/ex3/scripts/ex3-4.sce index 5511ec8..adc62c8 100644 --- a/ex3/scripts/ex3-4.sce +++ b/ex3/scripts/ex3-4.sce @@ -1,11 +1,11 @@ data = csvRead("data.csv"); -tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)) * 100; +tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)); // On sépare les taux d'accroissement par continent tauxAccroissementMoyenParContient = [mean(tauxAccroissement(1:57)), mean(tauxAccroissement(58:86)), mean(tauxAccroissement(87:99)), mean(tauxAccroissement(100:150)), mean(tauxAccroissement(151:193)), mean(tauxAccroissement(194:207))]; -bar(tauxAccroissementMoyenParContient); +bar(tauxAccroissementMoyenParContient * 100); gca().x_ticks.labels = "$\rotatebox{90}{\mathsf{"+_(["Afrique", "Amérique du nord", "Amérique du sud", "Asie", "Europe", "Océanie"])'+"}}$"; title("Taux d''accroissement moyen par continent"); ylabel("Taux d''accroissement (%)"); diff --git a/ex3/scripts/ex3-5.sce b/ex3/scripts/ex3-5.sce index 96ce708..d034902 100644 --- a/ex3/scripts/ex3-5.sce +++ b/ex3/scripts/ex3-5.sce @@ -5,17 +5,17 @@ population2050 = sum(data(:, 6)*1000000); mprintf("La population mondiale prévue en 2050 est de %.0f habitants.\n", population2050); population = sum(data(:, 3)*1000000); -tauxAccroissement = ((data(:, 4) / 1000) - (data(:, 5) / 1000)) * 100; +tauxAccroissement = (data(:, 4) / 1000) - (data(:, 5) / 1000); tauxAccroissementMoyen = mean(tauxAccroissement); x = population; // On multiplie la population mondiale actuelle par le taux d'accroissement moyen jusqu'à atteindre ou dépasser la population mondiale prévue en 2050 while population2050 > x - x = x * tauxAccroissementMoyen; + x = x * (1+tauxAccroissementMoyen); end if population2050 == x - mprintf("La population mondiale prévue en 2050 est conforme à l''hypothèse d''un taux d''accroissement constant car\nen multipliant la population mondiale actuelle (%.0f) par le taux d''accroissement moyen (%.2f%%) jusqu''à\natteindre ou dépasser la population mondiale prévue en 2050 (%.0f), on obtient une prévision égale\nà la population mondiale prévue en 2050 (+ %.0f).", population, tauxAccroissementMoyen, population2050); + mprintf("La population mondiale prévue en 2050 est conforme à l''hypothèse d''un taux d''accroissement constant car\nen multipliant la population mondiale actuelle (%.0f) par le taux d''accroissement moyen (%.2f%%) jusqu''à\natteindre ou dépasser la population mondiale prévue en 2050 (%.0f), on obtient une prévision égale\nà la population mondiale prévue en 2050 (+ %.0f).", population, (tauxAccroissementMoyen * 100), population2050); else - mprintf("La population mondiale prévue en 2050 n''est pas conforme à l''hypothèse d''un taux d''accroissement constant car\nen multipliant la population mondiale actuelle (%.0f) par le taux d''accroissement moyen (%.2f%%) jusqu''à\natteindre ou dépasser la population mondiale prévue en 2050 (%.0f), on obtient une prévision largement\nsupérieur à la population mondiale prévue en 2050 (+ %.0f).", population, tauxAccroissementMoyen, population2050, x - population2050); + mprintf("La population mondiale prévue en 2050 n''est pas conforme à l''hypothèse d''un taux d''accroissement constant car\nen multipliant la population mondiale actuelle (%.0f) par le taux d''accroissement moyen (%.2f%%) jusqu''à\natteindre ou dépasser la population mondiale prévue en 2050 (%.0f), on obtient une prévision largement\nsupérieur à la population mondiale prévue en 2050 (+ %.0f).", population, (tauxAccroissementMoyen * 100), population2050, x - population2050); end