math-exercises 2.2.71 → 2.2.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts +10 -0
  2. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts.map +1 -0
  3. package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.js +138 -0
  4. package/lib/exercises/math/calculLitteral/distributivity/index.d.ts +1 -0
  5. package/lib/exercises/math/calculLitteral/distributivity/index.d.ts.map +1 -1
  6. package/lib/exercises/math/calculLitteral/distributivity/index.js +1 -0
  7. package/lib/exercises/math/probaStat/stats1var/index.d.ts +6 -0
  8. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  9. package/lib/exercises/math/probaStat/stats1var/index.js +6 -0
  10. package/lib/exercises/math/probaStat/stats1var/interquartilesList.d.ts +7 -0
  11. package/lib/exercises/math/probaStat/stats1var/interquartilesList.d.ts.map +1 -0
  12. package/lib/exercises/math/probaStat/stats1var/interquartilesList.js +93 -0
  13. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts +8 -0
  14. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -0
  15. package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +101 -0
  16. package/lib/exercises/math/probaStat/stats1var/quartilesList.js +1 -1
  17. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.d.ts +7 -0
  18. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.d.ts.map +1 -0
  19. package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +131 -0
  20. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts +8 -0
  21. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts.map +1 -0
  22. package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +147 -0
  23. package/lib/exercises/math/probaStat/stats1var/varianceList.d.ts +7 -0
  24. package/lib/exercises/math/probaStat/stats1var/varianceList.d.ts.map +1 -0
  25. package/lib/exercises/math/probaStat/stats1var/varianceList.js +121 -0
  26. package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts +8 -0
  27. package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts.map +1 -0
  28. package/lib/exercises/math/probaStat/stats1var/varianceTable.js +136 -0
  29. package/lib/exercises/vea/sqrtVEA.d.ts +2 -1
  30. package/lib/exercises/vea/sqrtVEA.d.ts.map +1 -1
  31. package/lib/exercises/vea/sqrtVEA.js +6 -3
  32. package/lib/index.d.ts +19 -0
  33. package/lib/index.d.ts.map +1 -1
  34. package/lib/math/utils/quartiles.d.ts +3 -0
  35. package/lib/math/utils/quartiles.d.ts.map +1 -0
  36. package/lib/math/utils/quartiles.js +47 -0
  37. package/lib/math/utils/standardDeviation.d.ts +3 -0
  38. package/lib/math/utils/standardDeviation.d.ts.map +1 -0
  39. package/lib/math/utils/standardDeviation.js +13 -0
  40. package/lib/math/utils/variance.d.ts +1 -0
  41. package/lib/math/utils/variance.d.ts.map +1 -1
  42. package/lib/math/utils/variance.js +9 -1
  43. package/lib/playground.d.ts.map +1 -1
  44. package/lib/tree/nodes/operators/addNode.js +1 -1
  45. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  46. package/lib/tree/nodes/operators/multiplyNode.js +8 -0
  47. package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -1
  48. package/lib/tree/nodes/polynomials/monomNode.js +3 -1
  49. package/lib/tree/parsers/monomParser.d.ts.map +1 -1
  50. package/lib/tree/parsers/monomParser.js +25 -0
  51. package/lib/tree/parsers/polynomialParser.d.ts +3 -0
  52. package/lib/tree/parsers/polynomialParser.d.ts.map +1 -0
  53. package/lib/tree/parsers/polynomialParser.js +50 -0
  54. package/lib/utils/average.d.ts +1 -0
  55. package/lib/utils/average.d.ts.map +1 -1
  56. package/lib/utils/average.js +9 -1
  57. package/lib/utils/latex/approxOrEqual.d.ts +2 -0
  58. package/lib/utils/latex/approxOrEqual.d.ts.map +1 -0
  59. package/lib/utils/latex/approxOrEqual.js +11 -0
  60. package/lib/utils/variance.d.ts +2 -0
  61. package/lib/utils/variance.d.ts.map +1 -0
  62. package/lib/utils/variance.js +12 -0
  63. package/package.json +1 -1
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.standardDeviationTable = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const sqrtVEA_1 = require("../../../../exercises/vea/sqrtVEA");
7
+ const randfloat_1 = require("../../../../math/utils/random/randfloat");
8
+ const randint_1 = require("../../../../math/utils/random/randint");
9
+ const round_1 = require("../../../../math/utils/round");
10
+ const standardDeviation_1 = require("../../../../math/utils/standardDeviation");
11
+ const variance_1 = require("../../../../math/utils/variance");
12
+ const average_1 = require("../../../../utils/average");
13
+ const alignTex_1 = require("../../../../utils/latex/alignTex");
14
+ const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
15
+ const mdTable_1 = require("../../../../utils/markdown/mdTable");
16
+ const getPropositions = (n, { answer, sortedValues, effectifs }) => {
17
+ const propositions = [];
18
+ (0, exercise_1.addValidProp)(propositions, answer);
19
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, round_1.round)((0, variance_1.varianceWithEffectifs)(sortedValues, effectifs), 2).frenchify());
20
+ while (propositions.length < n) {
21
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, randfloat_1.randfloat)(0, 5, 2).frenchify());
22
+ }
23
+ return (0, exercise_1.shuffleProps)(propositions, n);
24
+ };
25
+ const getAnswer = (identifiers) => {
26
+ const sigma = (0, standardDeviation_1.standardDeviationWithEffectifs)(identifiers.sortedValues, identifiers.effectifs);
27
+ return (0, round_1.round)(sigma, 2).frenchify();
28
+ };
29
+ const getInstruction = (identifiers) => {
30
+ return `Calculer l'écart-type de la série statistique suivante :
31
+
32
+ ${(0, mdTable_1.mdTable)([
33
+ ["$x_i$", ...identifiers.sortedValues.map((e) => `$${e.frenchify()}$`)],
34
+ ["$n_i$", ...identifiers.effectifs.map((e) => `$${e.frenchify()}$`)],
35
+ ])}
36
+
37
+ Arrondir au centième.`;
38
+ };
39
+ const getHint = (identifiers) => {
40
+ return `On note :
41
+
42
+ - $N$ le nombre de valeurs de la liste,
43
+ - $\\overline x$ la moyenne de la liste,
44
+ - $x_1$, $x_2$, $\\ldots$, $x_N$ les valeurs de la liste,
45
+ - $n_1$, $n_2$, $\\ldots$, $n_N$ les effectifs de la liste.
46
+
47
+ Alors la variance est égale à :
48
+
49
+ $$
50
+ V = \\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}
51
+ $$
52
+
53
+ Puis, l'écart-type est la racine carrée de la variance.`;
54
+ };
55
+ const getCorrection = (identifiers) => {
56
+ const { sortedValues, effectifs } = identifiers;
57
+ const n = effectifs.reduce((acc, curr) => acc + curr, 0);
58
+ const avg = (0, average_1.averageWithEffectifs)(sortedValues, effectifs);
59
+ const roundedAvg = (0, round_1.round)(avg, 2);
60
+ const vce = (0, variance_1.varianceWithEffectifs)(sortedValues, effectifs);
61
+ const sigma = Math.sqrt(vce);
62
+ return `La moyenne $\\overline{x}$ de cette série vaut :
63
+
64
+ ${(0, alignTex_1.alignTex)([
65
+ [
66
+ `\\overline{x}`,
67
+ "=",
68
+ `\\frac{${sortedValues
69
+ .map((e, i) => `${effectifs[i].frenchify()}\\times ${e.frenchify()}`)
70
+ .join("+")}}{${n}}`,
71
+ ],
72
+ ["", ...(0, approxOrEqual_1.approxOrEqual)(avg, 2)],
73
+ ])}
74
+
75
+ La variance est donc :
76
+
77
+ ${(0, alignTex_1.alignTex)([
78
+ [
79
+ "V",
80
+ "=",
81
+ `\\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}`,
82
+ ],
83
+ [
84
+ "",
85
+ "=",
86
+ `\\frac{${sortedValues
87
+ .map((e, i) => `${effectifs[i].frenchify()}\\times(${e.frenchify()} - ${roundedAvg.frenchify()})^2`)
88
+ .join("+")}}{${n}}`,
89
+ ],
90
+ ["", ...(0, approxOrEqual_1.approxOrEqual)(vce, 2)],
91
+ ])}
92
+
93
+ L'écart-type vaut alors :
94
+
95
+ $$
96
+ \\sigma = \\sqrt{V} ${(0, approxOrEqual_1.approxOrEqual)(sigma, 2).join("")}
97
+ $$`;
98
+ };
99
+ const getKeys = (identifiers) => {
100
+ return [];
101
+ };
102
+ const isAnswerValid = (ans, { answer }) => {
103
+ return (0, sqrtVEA_1.sqrtVEA)(ans, answer, { decimalApproxAllowed: 0.01 });
104
+ };
105
+ const getStandardDeviationTableQuestion = (ops) => {
106
+ const nbValues = (0, randint_1.randint)(4, 7);
107
+ const values = [];
108
+ const effectifs = [];
109
+ for (let i = 0; i < nbValues; i++) {
110
+ values.push((0, randint_1.randint)(1, 15, values));
111
+ effectifs.push((0, randint_1.randint)(1, 7));
112
+ }
113
+ const identifiers = {
114
+ sortedValues: values.sort((a, b) => a - b),
115
+ effectifs,
116
+ };
117
+ const question = {
118
+ answer: getAnswer(identifiers),
119
+ instruction: getInstruction(identifiers),
120
+ keys: getKeys(identifiers),
121
+ answerFormat: "tex",
122
+ identifiers,
123
+ hint: getHint(identifiers),
124
+ correction: getCorrection(identifiers),
125
+ style: {
126
+ tableHasNoHeader: true,
127
+ },
128
+ };
129
+ return question;
130
+ };
131
+ exports.standardDeviationTable = {
132
+ id: "standardDeviationTable",
133
+ connector: "=",
134
+ label: "Calcul de l'écart-type d'un tableau d'effectifs",
135
+ isSingleStep: true,
136
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getStandardDeviationTableQuestion(opts), nb),
137
+ qcmTimer: 60,
138
+ freeTimer: 60,
139
+ getPropositions,
140
+ isAnswerValid,
141
+ subject: "Mathématiques",
142
+ getInstruction,
143
+ getHint,
144
+ getCorrection,
145
+ getAnswer,
146
+ hasHintAndCorrection: true,
147
+ };
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ sortedValues: number[];
4
+ };
5
+ export declare const varianceList: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=varianceList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varianceList.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/varianceList.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AA6GF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAiB9C,CAAC"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.varianceList = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const rationalVEA_1 = require("../../../../exercises/vea/rationalVEA");
7
+ const randfloat_1 = require("../../../../math/utils/random/randfloat");
8
+ const randint_1 = require("../../../../math/utils/random/randint");
9
+ const round_1 = require("../../../../math/utils/round");
10
+ const variance_1 = require("../../../../math/utils/variance");
11
+ const average_1 = require("../../../../utils/average");
12
+ const alignTex_1 = require("../../../../utils/latex/alignTex");
13
+ const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
14
+ const getPropositions = (n, { answer, sortedValues }) => {
15
+ const propositions = [];
16
+ (0, exercise_1.addValidProp)(propositions, answer);
17
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, round_1.round)((0, average_1.average)(sortedValues), 2).frenchify());
18
+ while (propositions.length < n) {
19
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, randfloat_1.randfloat)(3, 10, 2).frenchify());
20
+ }
21
+ return (0, exercise_1.shuffleProps)(propositions, n);
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ const vrc = (0, variance_1.variance)(identifiers.sortedValues, (0, average_1.average)(identifiers.sortedValues));
25
+ return (0, round_1.round)(vrc, 2).frenchify();
26
+ };
27
+ const getInstruction = (identifiers) => {
28
+ return `Calculer la variance de la série statistique suivante :
29
+
30
+ $$
31
+ ${identifiers.sortedValues.map((e) => e.frenchify()).join("\\ ; \\ ")}
32
+ $$
33
+
34
+ Arrondir au centième.`;
35
+ };
36
+ const getHint = (identifiers) => {
37
+ return `Si on note $N$ le nombre de valeurs, $\\overline x$ la moyenne de cette liste, et $x_1$, $x_2$, $\\ldots$, $x_N$ les valeurs de la liste, alors la variance est :
38
+
39
+ $$
40
+ V = \\frac{(x_1-\\overline{x})^2 + (x_2-\\overline{x})^2 + \\ldots + (x_N-\\overline{x})^2}{N}
41
+ $$`;
42
+ };
43
+ const getCorrection = (identifiers) => {
44
+ const n = identifiers.sortedValues.length;
45
+ const avg = (0, average_1.average)(identifiers.sortedValues);
46
+ const roundedAvg = (0, round_1.round)(avg, 2);
47
+ const vce = (0, variance_1.variance)(identifiers.sortedValues, (0, average_1.average)(identifiers.sortedValues));
48
+ return `La moyenne $\\overline{x}$ de cette série vaut :
49
+
50
+ ${(0, alignTex_1.alignTex)([
51
+ [
52
+ `\\overline{x}`,
53
+ "=",
54
+ `\\frac{${identifiers.sortedValues
55
+ .map((e) => e.frenchify())
56
+ .join("+")}}{${n}}`,
57
+ ],
58
+ ["", ...(0, approxOrEqual_1.approxOrEqual)(avg, 2)],
59
+ ])}
60
+
61
+ La variance est donc :
62
+
63
+ ${(0, alignTex_1.alignTex)([
64
+ [
65
+ "V",
66
+ "=",
67
+ `\\frac{(x_1-\\overline{x})^2 + (x_2-\\overline{x})^2 + \\ldots + (x_n-\\overline{x})^2}{N}`,
68
+ ],
69
+ [
70
+ "",
71
+ "=",
72
+ `\\frac{${identifiers.sortedValues
73
+ .map((e) => `(${e.frenchify()} - ${roundedAvg.frenchify()})^2`)
74
+ .join("+")}}{${n}}`,
75
+ ],
76
+ ["", ...(0, approxOrEqual_1.approxOrEqual)(vce, 2)],
77
+ ])}`;
78
+ };
79
+ const getKeys = (identifiers) => {
80
+ return [];
81
+ };
82
+ const isAnswerValid = (ans, { answer }) => {
83
+ return (0, rationalVEA_1.rationalVEA)(ans, answer);
84
+ };
85
+ const getVarianceListQuestion = (ops) => {
86
+ const nbValues = (0, randint_1.randint)(4, 7);
87
+ const values = [];
88
+ for (let i = 0; i < nbValues; i++) {
89
+ values.push((0, randint_1.randint)(1, 15));
90
+ }
91
+ const identifiers = {
92
+ sortedValues: values.sort((a, b) => a - b),
93
+ };
94
+ const question = {
95
+ answer: getAnswer(identifiers),
96
+ instruction: getInstruction(identifiers),
97
+ keys: getKeys(identifiers),
98
+ answerFormat: "tex",
99
+ identifiers,
100
+ hint: getHint(identifiers),
101
+ correction: getCorrection(identifiers),
102
+ };
103
+ return question;
104
+ };
105
+ exports.varianceList = {
106
+ id: "varianceList",
107
+ connector: "=",
108
+ label: "Calcul de la variance d'une liste de valeurs",
109
+ isSingleStep: true,
110
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getVarianceListQuestion(opts), nb),
111
+ qcmTimer: 60,
112
+ freeTimer: 60,
113
+ getPropositions,
114
+ isAnswerValid,
115
+ subject: "Mathématiques",
116
+ getInstruction,
117
+ getHint,
118
+ getCorrection,
119
+ getAnswer,
120
+ hasHintAndCorrection: true,
121
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ sortedValues: number[];
4
+ effectifs: number[];
5
+ };
6
+ export declare const varianceTable: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=varianceTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varianceTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/varianceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA0HF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.varianceTable = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const rationalVEA_1 = require("../../../../exercises/vea/rationalVEA");
7
+ const randfloat_1 = require("../../../../math/utils/random/randfloat");
8
+ const randint_1 = require("../../../../math/utils/random/randint");
9
+ const round_1 = require("../../../../math/utils/round");
10
+ const variance_1 = require("../../../../math/utils/variance");
11
+ const average_1 = require("../../../../utils/average");
12
+ const alignTex_1 = require("../../../../utils/latex/alignTex");
13
+ const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
14
+ const mdTable_1 = require("../../../../utils/markdown/mdTable");
15
+ const getPropositions = (n, { answer }) => {
16
+ const propositions = [];
17
+ (0, exercise_1.addValidProp)(propositions, answer);
18
+ while (propositions.length < n) {
19
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, randfloat_1.randfloat)(3, 10, 2).frenchify());
20
+ }
21
+ return (0, exercise_1.shuffleProps)(propositions, n);
22
+ };
23
+ const getAnswer = (identifiers) => {
24
+ const vce = (0, variance_1.varianceWithEffectifs)(identifiers.sortedValues, identifiers.effectifs);
25
+ return (0, round_1.round)(vce, 2).frenchify();
26
+ };
27
+ const getInstruction = (identifiers) => {
28
+ return `Calculer la variance de la série statistique suivante :
29
+
30
+ ${(0, mdTable_1.mdTable)([
31
+ ["$x_i$", ...identifiers.sortedValues.map((e) => `$${e.frenchify()}$`)],
32
+ ["$n_i$", ...identifiers.effectifs.map((e) => `$${e.frenchify()}$`)],
33
+ ])}
34
+
35
+ Arrondir au centième.`;
36
+ };
37
+ const getHint = (identifiers) => {
38
+ return `On note :
39
+
40
+ - $N$ le nombre de valeurs de la liste,
41
+ - $\\overline x$ la moyenne de la liste,
42
+ - $x_1$, $x_2$, $\\ldots$, $x_N$ les valeurs de la liste,
43
+ - $n_1$, $n_2$, $\\ldots$, $n_N$ les effectifs de la liste.
44
+
45
+ Alors la variance est égale à :
46
+
47
+ $$
48
+ V = \\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}
49
+ $$`;
50
+ };
51
+ const getCorrection = (identifiers) => {
52
+ const { sortedValues, effectifs } = identifiers;
53
+ const n = effectifs.reduce((acc, curr) => acc + curr, 0);
54
+ const avg = (0, average_1.averageWithEffectifs)(sortedValues, effectifs);
55
+ const roundedAvg = (0, round_1.round)(avg, 2);
56
+ const vce = (0, variance_1.varianceWithEffectifs)(sortedValues, effectifs);
57
+ return `La moyenne $\\overline{x}$ de cette série vaut :
58
+
59
+ ${(0, alignTex_1.alignTex)([
60
+ [
61
+ `\\overline{x}`,
62
+ "=",
63
+ `\\frac{${sortedValues
64
+ .map((e, i) => `${effectifs[i].frenchify()}\\times ${e.frenchify()}`)
65
+ .join("+")}}{${n}}`,
66
+ ],
67
+ ["", ...(0, approxOrEqual_1.approxOrEqual)(avg, 2)],
68
+ ])}
69
+
70
+ La variance est donc :
71
+
72
+ ${(0, alignTex_1.alignTex)([
73
+ [
74
+ "V",
75
+ "=",
76
+ `\\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}`,
77
+ ],
78
+ [
79
+ "",
80
+ "=",
81
+ `\\frac{${sortedValues
82
+ .map((e, i) => `${effectifs[i].frenchify()}\\times(${e.frenchify()} - ${roundedAvg.frenchify()})^2`)
83
+ .join("+")}}{${n}}`,
84
+ ],
85
+ ["", ...(0, approxOrEqual_1.approxOrEqual)(vce, 2)],
86
+ ])}`;
87
+ };
88
+ const getKeys = (identifiers) => {
89
+ return [];
90
+ };
91
+ const isAnswerValid = (ans, { answer }) => {
92
+ return (0, rationalVEA_1.rationalVEA)(ans, answer);
93
+ };
94
+ const getVarianceTableQuestion = (ops) => {
95
+ const nbValues = (0, randint_1.randint)(4, 7);
96
+ const values = [];
97
+ const effectifs = [];
98
+ for (let i = 0; i < nbValues; i++) {
99
+ values.push((0, randint_1.randint)(1, 15, values));
100
+ effectifs.push((0, randint_1.randint)(1, 7));
101
+ }
102
+ const identifiers = {
103
+ sortedValues: values.sort((a, b) => a - b),
104
+ effectifs,
105
+ };
106
+ const question = {
107
+ answer: getAnswer(identifiers),
108
+ instruction: getInstruction(identifiers),
109
+ keys: getKeys(identifiers),
110
+ answerFormat: "tex",
111
+ identifiers,
112
+ hint: getHint(identifiers),
113
+ correction: getCorrection(identifiers),
114
+ style: {
115
+ tableHasNoHeader: true,
116
+ },
117
+ };
118
+ return question;
119
+ };
120
+ exports.varianceTable = {
121
+ id: "varianceTable",
122
+ connector: "=",
123
+ label: "Calcul de la variance d'un tableau d'effectifs",
124
+ isSingleStep: true,
125
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getVarianceTableQuestion(opts), nb),
126
+ qcmTimer: 60,
127
+ freeTimer: 60,
128
+ getPropositions,
129
+ isAnswerValid,
130
+ subject: "Mathématiques",
131
+ getInstruction,
132
+ getHint,
133
+ getCorrection,
134
+ getAnswer,
135
+ hasHintAndCorrection: true,
136
+ };
@@ -1,6 +1,7 @@
1
1
  type Opts = {
2
2
  allowNonIrreductible?: boolean;
3
+ decimalApproxAllowed?: number;
3
4
  };
4
- export declare const sqrtVEA: (studentAns: string, answer: string, { allowNonIrreductible }?: Opts) => boolean;
5
+ export declare const sqrtVEA: (studentAns: string, answer: string, { allowNonIrreductible, decimalApproxAllowed }?: Opts) => boolean;
5
6
  export {};
6
7
  //# sourceMappingURL=sqrtVEA.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqrtVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/sqrtVEA.ts"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AACF,eAAO,MAAM,OAAO,eACN,MAAM,UACV,MAAM,6BACY,IAAI,YAmB/B,CAAC"}
1
+ {"version":3,"file":"sqrtVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/sqrtVEA.ts"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AACF,eAAO,MAAM,OAAO,eACN,MAAM,UACV,MAAM,mDACkC,IAAI,YA0BrD,CAAC"}
@@ -4,20 +4,23 @@ exports.sqrtVEA = void 0;
4
4
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
5
5
  const latexParser_1 = require("../../tree/parsers/latexParser");
6
6
  const sqrtParser_1 = require("../../tree/parsers/sqrtParser");
7
- const sqrtVEA = (studentAns, answer, { allowNonIrreductible } = {
7
+ const sqrtVEA = (studentAns, answer, { allowNonIrreductible, decimalApproxAllowed } = {
8
8
  allowNonIrreductible: true,
9
9
  }) => {
10
10
  try {
11
11
  allowNonIrreductible = allowNonIrreductible ?? true;
12
+ decimalApproxAllowed = decimalApproxAllowed ?? 0.0000001;
12
13
  const parsed = (0, sqrtParser_1.sqrtParser)(studentAns);
13
14
  if (!parsed)
14
15
  return false;
15
16
  const parsedAnswer = (0, latexParser_1.parseAlgebraic)(answer);
16
17
  if ((0, numberNode_1.isNumberNode)(parsed)) {
17
- return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001;
18
+ return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
19
+ decimalApproxAllowed);
18
20
  }
19
21
  else if (allowNonIrreductible) {
20
- return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) < 0.0000001;
22
+ return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
23
+ decimalApproxAllowed);
21
24
  }
22
25
  else {
23
26
  return parsed.equals(parsedAnswer);
package/lib/index.d.ts CHANGED
@@ -236,6 +236,10 @@ declare const mathExercises: (Exercise<{
236
236
  affine2: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers;
237
237
  affine3: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers;
238
238
  affine4?: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers | undefined;
239
+ }, {}> | Exercise<{
240
+ type: number;
241
+ a: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
242
+ b: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
239
243
  }, {}> | Exercise<{
240
244
  randNbr: number;
241
245
  }, {}> | Exercise<{
@@ -1389,6 +1393,21 @@ declare const mathExercises: (Exercise<{
1389
1393
  sortedValues: number[];
1390
1394
  }, {}> | Exercise<{
1391
1395
  sortedValues: number[];
1396
+ }, {}> | Exercise<{
1397
+ sortedValues: number[];
1398
+ }, {}> | Exercise<{
1399
+ sortedValues: number[];
1400
+ effectifs: number[];
1401
+ }, {}> | Exercise<{
1402
+ sortedValues: number[];
1403
+ }, {}> | Exercise<{
1404
+ sortedValues: number[];
1405
+ effectifs: number[];
1406
+ }, {}> | Exercise<{
1407
+ sortedValues: number[];
1408
+ }, {}> | Exercise<{
1409
+ sortedValues: number[];
1410
+ effectifs: number[];
1392
1411
  }, {}> | Exercise<{
1393
1412
  xValues: number[];
1394
1413
  yValues: number[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;SAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const firstQuartile: (values: number[], effectifs?: number[]) => number;
2
+ export declare const thirdQuartile: (values: number[], effectifs?: number[]) => number;
3
+ //# sourceMappingURL=quartiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quartiles.d.ts","sourceRoot":"","sources":["../../../src/math/utils/quartiles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,WAAY,MAAM,EAAE,cAAc,MAAM,EAAE,WAkBnE,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,MAAM,EAAE,cAAc,MAAM,EAAE,WAkBnE,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.thirdQuartile = exports.firstQuartile = void 0;
4
+ const firstQuartile = (values, effectifs) => {
5
+ if (!values.length)
6
+ throw Error("Malformed data in firstQuartile");
7
+ if (!effectifs?.length) {
8
+ const N = values.length;
9
+ const rank = Math.ceil(N / 4);
10
+ return values[rank - 1];
11
+ }
12
+ else {
13
+ const N = effectifs.reduce((acc, curr) => acc + curr, 0);
14
+ const rank = Math.ceil(N / 4);
15
+ let s = 0;
16
+ for (let i = 0; i < effectifs.length; i++) {
17
+ s += effectifs[i];
18
+ if (rank <= s) {
19
+ return values[i];
20
+ }
21
+ }
22
+ return values[values.length - 1];
23
+ }
24
+ };
25
+ exports.firstQuartile = firstQuartile;
26
+ const thirdQuartile = (values, effectifs) => {
27
+ if (!values.length)
28
+ throw Error("Malformed data in thirdQuartile");
29
+ if (!effectifs?.length) {
30
+ const N = values.length;
31
+ const rank = Math.ceil((3 * N) / 4);
32
+ return values[rank - 1];
33
+ }
34
+ else {
35
+ const N = effectifs.reduce((acc, curr) => acc + curr, 0);
36
+ const rank = Math.ceil((3 * N) / 4);
37
+ let s = 0;
38
+ for (let i = 0; i < effectifs.length; i++) {
39
+ s += effectifs[i];
40
+ if (rank <= s) {
41
+ return values[i];
42
+ }
43
+ }
44
+ return values[values.length - 1];
45
+ }
46
+ };
47
+ exports.thirdQuartile = thirdQuartile;
@@ -0,0 +1,3 @@
1
+ export declare const standardDeviation: (values: number[]) => number;
2
+ export declare const standardDeviationWithEffectifs: (values: number[], effectifs: number[]) => number;
3
+ //# sourceMappingURL=standardDeviation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardDeviation.d.ts","sourceRoot":"","sources":["../../../src/math/utils/standardDeviation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,WAAY,MAAM,EAAE,WAEjD,CAAC;AACF,eAAO,MAAM,8BAA8B,WACjC,MAAM,EAAE,aACL,MAAM,EAAE,WAGpB,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.standardDeviationWithEffectifs = exports.standardDeviation = void 0;
4
+ const average_1 = require("../../utils/average");
5
+ const variance_1 = require("./variance");
6
+ const standardDeviation = (values) => {
7
+ return Math.sqrt((0, variance_1.variance)(values, (0, average_1.average)(values)));
8
+ };
9
+ exports.standardDeviation = standardDeviation;
10
+ const standardDeviationWithEffectifs = (values, effectifs) => {
11
+ return Math.sqrt((0, variance_1.varianceWithEffectifs)(values, effectifs));
12
+ };
13
+ exports.standardDeviationWithEffectifs = standardDeviationWithEffectifs;
@@ -1,4 +1,5 @@
1
1
  import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
2
2
  export declare function varianceAsNode(xValues: number[], avgX: AlgebraicNode): AlgebraicNode;
3
3
  export declare function variance(xValues: number[], avgX: number): number;
4
+ export declare const varianceWithEffectifs: (values: number[], effectifs: number[]) => number;
4
5
  //# sourceMappingURL=variance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variance.d.ts","sourceRoot":"","sources":["../../../src/math/utils/variance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,aAAa,GAClB,aAAa,CAgBf;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQhE"}
1
+ {"version":3,"file":"variance.d.ts","sourceRoot":"","sources":["../../../src/math/utils/variance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,aAAa,GAClB,aAAa,CAgBf;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQhE;AAED,eAAO,MAAM,qBAAqB,WACxB,MAAM,EAAE,aACL,MAAM,EAAE,WAapB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.variance = exports.varianceAsNode = void 0;
3
+ exports.varianceWithEffectifs = exports.variance = exports.varianceAsNode = void 0;
4
4
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
5
5
  const addNode_1 = require("../../tree/nodes/operators/addNode");
6
6
  const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
@@ -25,3 +25,11 @@ function variance(xValues, avgX) {
25
25
  return variance / xValues.length;
26
26
  }
27
27
  exports.variance = variance;
28
+ const varianceWithEffectifs = (values, effectifs) => {
29
+ if (!values.length || !effectifs.length || values.length !== effectifs.length)
30
+ throw Error("Malformed data in variance");
31
+ const N = effectifs.reduce((acc, curr) => acc + curr, 0);
32
+ const avg = values.reduce((acc, value, index) => acc + value * effectifs[index], 0) / N;
33
+ return (values.reduce((acc, value, index) => acc + Math.pow(value - avg, 2) * effectifs[index], 0) / N);
34
+ };
35
+ exports.varianceWithEffectifs = varianceWithEffectifs;
@@ -1 +1 @@
1
- {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAoDA,eAAO,MAAM,UAAU,YAAW,CAAC"}
1
+ {"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAqDA,eAAO,MAAM,UAAU,YAAW,CAAC"}
@@ -368,6 +368,6 @@ const addSimplifyMonoms = (a, b, opts) => {
368
368
  return new numberNode_1.NumberNode(0);
369
369
  return new monomNode_1.MonomNode(sum, aMonom.degree, {
370
370
  variable: aMonom.variable,
371
- }).toTree();
371
+ });
372
372
  }
373
373
  };
@@ -1 +1 @@
1
- {"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBA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