math-exercises 3.0.82 → 3.0.84

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 (81) hide show
  1. package/lib/exercises/exercise.d.ts +7 -0
  2. package/lib/exercises/exercise.d.ts.map +1 -1
  3. package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.d.ts +9 -0
  4. package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.d.ts.map +1 -0
  5. package/lib/exercises/math/calcul/arithmetics/evalFractionExpression.js +113 -0
  6. package/lib/exercises/math/calcul/arithmetics/index.d.ts +1 -0
  7. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calcul/arithmetics/index.js +1 -0
  9. package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.d.ts.map +1 -1
  10. package/lib/exercises/math/calcul/arithmetics/isNumberDecimal.js +5 -1
  11. package/lib/exercises/math/calcul/ordering/framing.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/ordering/framing.js +10 -3
  13. package/lib/exercises/math/functions/basics/index.d.ts +1 -0
  14. package/lib/exercises/math/functions/basics/index.d.ts.map +1 -1
  15. package/lib/exercises/math/functions/basics/index.js +1 -1
  16. package/lib/exercises/math/functions/basics/valueTableCompletion.d.ts +2 -1
  17. package/lib/exercises/math/functions/basics/valueTableCompletion.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/basics/valueTableCompletion.js +104 -31
  19. package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.d.ts +8 -0
  20. package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.d.ts.map +1 -0
  21. package/lib/exercises/math/probaStat/basicProbas/ballsBasicProbas.js +96 -0
  22. package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.d.ts +10 -0
  23. package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.d.ts.map +1 -0
  24. package/lib/exercises/math/probaStat/basicProbas/cardBasicProbas.js +153 -0
  25. package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.d.ts +10 -0
  26. package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.d.ts.map +1 -0
  27. package/lib/exercises/math/probaStat/basicProbas/diceBasicProbas.js +130 -0
  28. package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.d.ts +7 -0
  29. package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.d.ts.map +1 -0
  30. package/lib/exercises/math/probaStat/basicProbas/getComplementaryProbability.js +90 -0
  31. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts +9 -0
  32. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.d.ts.map +1 -0
  33. package/lib/exercises/math/probaStat/basicProbas/getMissingProbabilityValue.js +109 -0
  34. package/lib/exercises/math/probaStat/basicProbas/index.d.ts +8 -0
  35. package/lib/exercises/math/probaStat/basicProbas/index.d.ts.map +1 -0
  36. package/lib/exercises/math/probaStat/basicProbas/index.js +7 -0
  37. package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.d.ts +8 -0
  38. package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.d.ts.map +1 -0
  39. package/lib/exercises/math/probaStat/basicProbas/mostLeastProbable.js +114 -0
  40. package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.d.ts +8 -0
  41. package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.d.ts.map +1 -0
  42. package/lib/exercises/math/probaStat/basicProbas/rouletteProbas.js +139 -0
  43. package/lib/exercises/math/probaStat/events/describeEvent.d.ts +15 -0
  44. package/lib/exercises/math/probaStat/events/describeEvent.d.ts.map +1 -0
  45. package/lib/exercises/math/probaStat/events/describeEvent.js +182 -0
  46. package/lib/exercises/math/probaStat/events/eventNotation.d.ts +15 -0
  47. package/lib/exercises/math/probaStat/events/eventNotation.d.ts.map +1 -0
  48. package/lib/exercises/math/probaStat/events/eventNotation.js +156 -0
  49. package/lib/exercises/math/probaStat/events/index.d.ts +3 -0
  50. package/lib/exercises/math/probaStat/events/index.d.ts.map +1 -0
  51. package/lib/exercises/math/probaStat/events/index.js +2 -0
  52. package/lib/exercises/math/probaStat/index.d.ts +2 -10
  53. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  54. package/lib/exercises/math/probaStat/index.js +2 -10
  55. package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
  56. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +35 -52
  57. package/lib/exercises/math/probaStat/stats1var/averageLinearity.d.ts +16 -0
  58. package/lib/exercises/math/probaStat/stats1var/averageLinearity.d.ts.map +1 -0
  59. package/lib/exercises/math/probaStat/stats1var/averageLinearity.js +217 -0
  60. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts +8 -0
  61. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.d.ts.map +1 -0
  62. package/lib/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.js +108 -0
  63. package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.d.ts +9 -0
  64. package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.d.ts.map +1 -0
  65. package/lib/exercises/math/probaStat/stats1var/compareSeriesDispersion.js +139 -0
  66. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts +9 -0
  67. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.d.ts.map +1 -0
  68. package/lib/exercises/math/probaStat/stats1var/cumulativeSum.js +105 -0
  69. package/lib/exercises/math/probaStat/stats1var/index.d.ts +4 -0
  70. package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
  71. package/lib/exercises/math/probaStat/stats1var/index.js +4 -0
  72. package/lib/index.d.ts +57 -34
  73. package/lib/index.d.ts.map +1 -1
  74. package/lib/tests/exoTest.d.ts.map +1 -1
  75. package/lib/tests/exoTest.js +9 -2
  76. package/lib/tests/questionTest.d.ts.map +1 -1
  77. package/lib/tests/questionTest.js +21 -2
  78. package/lib/utils/markdown/mdTable.d.ts +1 -1
  79. package/lib/utils/markdown/mdTable.d.ts.map +1 -1
  80. package/lib/utils/markdown/mdTable.js +10 -5
  81. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
@@ -1,8 +1,4 @@
1
- export * from "./averageLinearity.js";
2
- export * from "./ballsBasicProbas.js";
3
- export * from "./cardBasicProbas.js";
4
1
  export * from "./conditionalProbability.js";
5
- export * from "./diceBasicProbas.js";
6
2
  export * from "./probabilityTree.js";
7
3
  export * from "./stats1var/index.js";
8
4
  export * from "./stats2var/index.js";
@@ -13,12 +9,8 @@ export * from "./probaFromTableWithContext.js";
13
9
  export * from "./binomial/index.js";
14
10
  export * from "./basicStats/index.js";
15
11
  export * from "./randomVariable/index.js";
16
- export * from "./getMissingProbabilityValue.js";
17
- export * from "./getComplementaryProbability.js";
18
12
  export * from "./unionIntersectionProba.js";
19
- export * from "./calculateMeanFromFrequencies.js";
20
- export * from "./mostLeastProbable.js";
21
13
  export * from "./checkEquiprobability.js";
22
14
  export * from "./getSampleCountAndSize.js";
23
- export * from "./describeEvent.js";
24
- export * from "./cumulativeSum.js";
15
+ export * from "./events/index.js";
16
+ export * from "./basicProbas/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA6JF,KAAK,OAAO,GAAG,EAEd,CAAC;AA2JF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBpE,CAAC"}
1
+ {"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA6JF,KAAK,OAAO,GAAG,EAEd,CAAC;AA6HF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAkBpE,CAAC"}
@@ -117,8 +117,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
117
117
  keys: [],
118
118
  answerFormat: "tex",
119
119
  identifiers,
120
- // hint: getHint(identifiers),
121
- // correction: getCorrection(identifiers),
120
+ hint: getHint(identifiers),
121
+ correction: getCorrection(identifiers),
122
122
  };
123
123
  return question;
124
124
  };
@@ -150,12 +150,12 @@ const getHint = (identifiers) => {
150
150
  const { aBarreCapB, aBarreCapBBarre, aCapB, aCapBBarre, probaFrac, type, event, } = identifiers;
151
151
  switch (type) {
152
152
  case "singleEvent":
153
- return `Lit le total d'issues de l'évènement demandé, puis divise par le total des issues.`;
153
+ return `Lit le total d'élèves correspondant au cas demandé, puis divise par le total des élèves.`;
154
154
  case "union":
155
- return `Compte toutes les issues qui sont soit dans le premier événement, soit dans le second (ou à la fois dans les deux). Attention à ne pas compter certaines issues en double.`;
155
+ return `Compte tous les élèves qui sont soit dans le premier cas, soit dans le second (ou à la fois dans les deux). Attention à ne pas compter certains élèves en double.`;
156
156
  case "intersection":
157
157
  default:
158
- return `Lit la case qui correspond aux issues appartenant à la fois aux deux événements demandés.`;
158
+ return `Lit la case des élèves correspondant à la fois aux deux cas demandés.`;
159
159
  }
160
160
  };
161
161
  const getCorrection = (identifiers) => {
@@ -167,68 +167,51 @@ const getCorrection = (identifiers) => {
167
167
  switch (type) {
168
168
  case "singleEvent":
169
169
  const singleEvnmt = event === "une fille"
170
- ? "A"
170
+ ? "Filles"
171
171
  : event === "un garçon"
172
- ? "\\overline{A}"
172
+ ? "Garçons"
173
173
  : event === "un élève qui porte des lunettes"
174
- ? "B"
175
- : "\\overline{B}";
176
- return `On lit le total de la ligne $${singleEvnmt}$ : c'est $${probaFrac[0]}$. La probabilité recherchée vaut donc :
174
+ ? "Porte des lunettes"
175
+ : "Ne porte pas de lunettes";
176
+ const isLine = event === "une fille" || event === "un garçon";
177
+ return `On lit le total de la ${isLine ? "ligne" : "colonne"} "${singleEvnmt}" : c'est $${probaFrac[0]}$. La probabilité recherchée vaut donc :
177
178
 
178
179
  $$
179
180
  ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
180
181
  $$`;
181
182
  case "union":
182
- const unionEvements = event === "P(A\\cup B)"
183
- ? ["A", "B"]
184
- : event === "P(A\\cup \\overline B)"
185
- ? ["A", "\\overline{B}"]
186
- : event === "P(\\overline A \\cup B)"
187
- ? ["\\overline{A}", "B"]
188
- : ["\\overline{A}", "\\overline{B}"];
189
- const rowTotal = unionEvements[0] === "A" ? aTotal : aBarreTotal;
190
- const columnTotal = unionEvements[1] === "B" ? bTotal : bBarreTotal;
191
- return `On additionne les totaux de la ligne $${unionEvements[0]}$ et de la colonne $${unionEvements[1]}$ : cela donne $${rowTotal} + ${columnTotal} = ${rowTotal + columnTotal}$. On doit ensuite soustraire la case à l'intersection de la ligne $${unionEvements[0]}$ et de la colonne $${unionEvements[1]}$, car on l'a compté deux fois dans les totaux. Cela donne $${rowTotal + columnTotal} - ${rowTotal + columnTotal - probaFrac[0]} = ${probaFrac[0]}
183
+ const unionEvements = event.split(" ou ");
184
+ const rowTotal = unionEvements[0] === "une fille" ? aTotal : aBarreTotal;
185
+ const columnTotal = unionEvements[1] === "un élève qui porte des lunettes"
186
+ ? bTotal
187
+ : bBarreTotal;
188
+ unionEvements[0] = unionEvements[0]
189
+ .replace("une", "")
190
+ .replace("un", "")
191
+ .trim();
192
+ unionEvements[1] = unionEvements[1].replace("un élève qui ", "");
193
+ return `On additionne les totaux de la ligne "${unionEvements[0]}" et de la colonne "${unionEvements[1]}" : cela donne $${rowTotal} + ${columnTotal} = ${rowTotal + columnTotal}$.
194
+
195
+ On doit ensuite soustraire la case à l'intersection de la ligne "${unionEvements[0]}" et de la colonne "${unionEvements[1]}", car on l'a compté deux fois dans les totaux. Cela donne $${rowTotal + columnTotal} - ${rowTotal + columnTotal - probaFrac[0]} = ${probaFrac[0]}
192
196
  $.
193
197
 
194
- La probabilité $${event}$ vaut donc :
198
+ La probabilité de tomber sur ${event} vaut donc :
195
199
 
196
200
  $$
197
- ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
201
+ ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
198
202
  $$`;
199
203
  case "intersection":
200
204
  default:
201
- const interEvemnts = event === "P(A\\cup B)"
202
- ? ["A", "B"]
203
- : event === "P(A\\cup \\overline B)"
204
- ? ["A", "\\overline{B}"]
205
- : event === "P(\\overline A \\cup B)"
206
- ? ["\\overline{A}", "B"]
207
- : ["\\overline{A}", "\\overline{B}"];
208
- return `On lit la case à l'intersection de la colonne $${interEvemnts[1]}$ et de la ligne $${interEvemnts[0]}$ : c'est $${probaFrac[0]}$. La probabilité $${event}$ vaut donc :
205
+ const interEvemnts = event.split(" qui ");
206
+ return `On lit la case à l'intersection de la colonne "${interEvemnts[1]}" et de la ligne "${interEvemnts[0]
207
+ .replace("une", "")
208
+ .replace("un", "")
209
+ .trim()}s" : c'est $${probaFrac[0]}$.
210
+
211
+ La probabilité de tomber sur ${event} vaut donc :
209
212
 
210
213
  $$
211
- ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
212
- $$`;
213
- const condEvents = event === "P_A(B)"
214
- ? ["A", "B"]
215
- : event === "P_{\\overline A}(B)"
216
- ? ["\\overline{A}", "B"]
217
- : event === "P_A(\\overline B)"
218
- ? ["A", "\\overline{B}"]
219
- : event === "P_{\\overline B}(A)"
220
- ? ["\\overline{B}", "A"]
221
- : event === "P_B(A)"
222
- ? ["B", "A"]
223
- : event === "P_B(\\overline{A})"
224
- ? ["B", "\\overline{A}"]
225
- : event === "P_{\\overline A}(\\overline B)"
226
- ? ["\\overline{A}", "\\overline{B}"]
227
- : ["\\overline{B}", "\\overline{A}"];
228
- return `On cherche la probabilité de $${condEvents[1]}$ sachant que $${condEvents[0]}$ est vrai. On lit la case à l'intersection de $${condEvents[1]}$ et $${condEvents[0]}$ : c'est $${probaFrac[0]}$. On doit ensuite diviser par le total de l'évènement $${condEvents[0]}$. La probabilité $${event}$ vaut donc :
229
-
230
- $$
231
- ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
214
+ ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
232
215
  $$`;
233
216
  }
234
217
  };
@@ -244,5 +227,5 @@ export const probaFromTableWithContext = {
244
227
  isAnswerValid,
245
228
  subject: "Mathématiques",
246
229
  getQuestionFromIdentifiers,
247
- // hasHintAndCorrection: true,
230
+ hasHintAndCorrection: true,
248
231
  };
@@ -0,0 +1,16 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Operators = "multiplication" | "division" | "soustraction" | "addition";
3
+ type Identifiers = {
4
+ kind: "factor";
5
+ a: number;
6
+ operator: Operators;
7
+ factor: number;
8
+ } | {
9
+ kind: "series";
10
+ series: number[];
11
+ operator: Operators;
12
+ factor: number;
13
+ };
14
+ export declare const averageLinearity: Exercise<Identifiers>;
15
+ export {};
16
+ //# sourceMappingURL=averageLinearity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"averageLinearity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageLinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AAarC,KAAK,SAAS,GAAG,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAC7E,KAAK,WAAW,GACZ;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmON,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAkBlD,CAAC"}
@@ -0,0 +1,217 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { randint } from "../../../../math/utils/random/randint.js";
4
+ import { add } from "../../../../tree/nodes/operators/addNode.js";
5
+ import { divide } from "../../../../tree/nodes/operators/divideNode.js";
6
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
9
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
10
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
11
+ import { random } from "../../../../utils/alea/random.js";
12
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
13
+ const getPropositions = (n, { answer, ...identifiers }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer);
16
+ const moyenne = isSeriesQuestion(identifiers)
17
+ ? (identifiers.series[0] +
18
+ identifiers.series[1] +
19
+ identifiers.series[2] +
20
+ identifiers.series[3]) /
21
+ 4
22
+ : identifiers.a;
23
+ const { operator, factor } = identifiers;
24
+ switch (operator) {
25
+ case "addition":
26
+ tryToAddWrongProp(propositions, (moyenne + factor + 1).frenchify());
27
+ tryToAddWrongProp(propositions, (moyenne + factor - 1).frenchify());
28
+ tryToAddWrongProp(propositions, (moyenne + factor + factor).frenchify());
29
+ tryToAddWrongProp(propositions, (moyenne + factor - 2).frenchify());
30
+ break;
31
+ case "soustraction":
32
+ tryToAddWrongProp(propositions, (moyenne - factor + 1).frenchify());
33
+ tryToAddWrongProp(propositions, (moyenne - factor - 1).frenchify());
34
+ tryToAddWrongProp(propositions, (moyenne - factor - factor).frenchify());
35
+ tryToAddWrongProp(propositions, (moyenne - factor - 2).frenchify());
36
+ break;
37
+ case "multiplication":
38
+ tryToAddWrongProp(propositions, (moyenne * factor + 1).frenchify());
39
+ tryToAddWrongProp(propositions, (moyenne * factor - 1).frenchify());
40
+ tryToAddWrongProp(propositions, (moyenne * factor + 2).frenchify());
41
+ tryToAddWrongProp(propositions, (moyenne * factor - 2).frenchify());
42
+ break;
43
+ case "division":
44
+ tryToAddWrongProp(propositions, frac(moyenne + 1, factor).toTex());
45
+ tryToAddWrongProp(propositions, frac(moyenne - 1, factor).toTex());
46
+ tryToAddWrongProp(propositions, frac(moyenne, factor + 1).toTex());
47
+ tryToAddWrongProp(propositions, frac(moyenne, factor - 1).toTex());
48
+ break;
49
+ }
50
+ return shuffleProps(propositions, n);
51
+ };
52
+ const isSeriesQuestion = (identifiers) => {
53
+ return identifiers.kind === "series";
54
+ };
55
+ const getAnswer = (identifiers) => {
56
+ const moyenne = isSeriesQuestion(identifiers)
57
+ ? (identifiers.series[0] +
58
+ identifiers.series[1] +
59
+ identifiers.series[2] +
60
+ identifiers.series[3]) /
61
+ 4
62
+ : identifiers.a;
63
+ const { operator, factor } = identifiers;
64
+ switch (operator) {
65
+ case "addition":
66
+ return add(moyenne, factor).simplify().toTex();
67
+ case "soustraction":
68
+ return substract(moyenne, factor).simplify().toTex();
69
+ case "multiplication":
70
+ return multiply(moyenne, factor).simplify().toTex();
71
+ case "division":
72
+ default:
73
+ return frac(moyenne, factor).simplify().toTex();
74
+ }
75
+ };
76
+ const getInstruction = (identifiers) => {
77
+ if (isSeriesQuestion(identifiers)) {
78
+ const { series: [a, b, c, d], operator, factor, } = identifiers;
79
+ let factorResult = (x) => {
80
+ switch (operator) {
81
+ case "addition":
82
+ return x + factor;
83
+ case "soustraction":
84
+ return x - factor;
85
+ case "multiplication":
86
+ return x * factor;
87
+ case "division":
88
+ default:
89
+ return x / factor;
90
+ }
91
+ };
92
+ return `La moyenne de la série ${[a, b, c, d]
93
+ .map((x) => `$${x.frenchify()}$`)
94
+ .join(" ; ")} vaut $${((a + b + c + d) / 4).frenchify()}$.
95
+
96
+ Que vaut la moyenne de la série ${[a, b, c, d]
97
+ .map((x) => `$${factorResult(x).frenchify()}$`)
98
+ .join(" ; ")} ?`;
99
+ }
100
+ else {
101
+ const { a, operator, factor } = identifiers;
102
+ const text = operator === "division"
103
+ ? "divisées par"
104
+ : operator === "multiplication"
105
+ ? "multipliées par"
106
+ : operator === "soustraction"
107
+ ? "diminuées de"
108
+ : "augmentées de";
109
+ return `La moyenne d'une série statistique vaut $${a.frenchify()}$. Calculer la nouvelle moyenne de la série si toutes ses valeurs sont ${text} $${factor.frenchify()}$.`;
110
+ }
111
+ };
112
+ const getHint = (identifiers) => {
113
+ return `Si on effectue une ${identifiers.operator} sur toutes les valeurs d'une série par un nombre $a$, alors la nouvelle moyenne de la série est obtenue en faisant une ${identifiers.operator} par ce même nombre sur la moyenne précédente.`;
114
+ };
115
+ const getCorrection = (identifiers) => {
116
+ const moyenne = isSeriesQuestion(identifiers)
117
+ ? (identifiers.series[0] +
118
+ identifiers.series[1] +
119
+ identifiers.series[2] +
120
+ identifiers.series[3]) /
121
+ 4
122
+ : identifiers.a;
123
+ const { operator, factor } = identifiers;
124
+ let latexFormula = "";
125
+ switch (operator) {
126
+ case "addition":
127
+ latexFormula = `${add(moyenne, factor).toTex()} = ${(moyenne + factor).frenchify()}`;
128
+ break;
129
+ case "soustraction":
130
+ latexFormula = `${substract(moyenne, factor).toTex()} = ${(moyenne - factor).frenchify()}`;
131
+ break;
132
+ case "multiplication":
133
+ latexFormula = `${multiply(moyenne, factor).toTex()} = ${(moyenne * factor).frenchify()}`;
134
+ break;
135
+ case "division":
136
+ default:
137
+ latexFormula = `${divide(moyenne, factor).toTex()} = ${frac(moyenne, factor).toTex()}`;
138
+ break;
139
+ }
140
+ return `Il y a eu une ${operator} de $${factor.frenchify()}$ sur les valeurs de la série, donc la moyenne devient :
141
+
142
+ $$
143
+ ${latexFormula}
144
+ $$`;
145
+ };
146
+ const isAnswerValid = (ans, { answer }) => {
147
+ try {
148
+ const parsed = parseAlgebraic(ans);
149
+ return parsed.simplify().toTex() === answer;
150
+ }
151
+ catch (err) {
152
+ return handleVEAError(err);
153
+ }
154
+ };
155
+ const getAverageLinearityQuestion = (ops) => {
156
+ const isSeries = coinFlip();
157
+ if (isSeries) {
158
+ const a = randint(1, 10);
159
+ const b = randint(10, 20);
160
+ const c = randint(20, 30);
161
+ const d = randint(30, 40);
162
+ const operator = random([
163
+ "multiplication",
164
+ "division",
165
+ "soustraction",
166
+ "addition",
167
+ ]);
168
+ const factor = randint(2, 5);
169
+ const identifiers = {
170
+ kind: "series",
171
+ series: [a, b, c, d],
172
+ operator,
173
+ factor,
174
+ };
175
+ return getQuestionFromIdentifiers(identifiers);
176
+ }
177
+ else {
178
+ const a = randint(2, 20);
179
+ const operator = random([
180
+ "multiplication",
181
+ "division",
182
+ "soustraction",
183
+ "addition",
184
+ ]);
185
+ const factor = randint(2, 10, [a, 7, 9]);
186
+ const identifiers = { kind: "factor", a, operator, factor };
187
+ return getQuestionFromIdentifiers(identifiers);
188
+ }
189
+ };
190
+ const getQuestionFromIdentifiers = (identifiers) => {
191
+ return {
192
+ answer: getAnswer(identifiers),
193
+ instruction: getInstruction(identifiers),
194
+ keys: [],
195
+ answerFormat: "tex",
196
+ identifiers,
197
+ hint: getHint(identifiers),
198
+ correction: getCorrection(identifiers),
199
+ };
200
+ };
201
+ export const averageLinearity = {
202
+ id: "averageLinearity",
203
+ label: "Calculer la moyenne d'une série à partir de la moyenne d'une autre série en utilisant la linéarité de la moyenne",
204
+ isSingleStep: true,
205
+ generator: (nb, opts) => getDistinctQuestions(() => getAverageLinearityQuestion(opts), nb),
206
+ qcmTimer: 60,
207
+ freeTimer: 60,
208
+ getPropositions,
209
+ isAnswerValid,
210
+ subject: "Mathématiques",
211
+ getInstruction,
212
+ getHint,
213
+ getCorrection,
214
+ getAnswer,
215
+ getQuestionFromIdentifiers,
216
+ hasHintAndCorrection: true,
217
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ xValues: number[];
4
+ yValues: number[];
5
+ };
6
+ export declare const calculateMeanFromFrequencies: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=calculateMeanFromFrequencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateMeanFromFrequencies.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/calculateMeanFromFrequencies.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAwGF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAoB9D,CAAC"}
@@ -0,0 +1,108 @@
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
4
+ import { dollarize } from "../../../../utils/latex/dollarize.js";
5
+ import { mdTable } from "../../../../utils/markdown/mdTable.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
8
+ import { parseAlgebraic } from "../../../../tree/parsers/latexParser.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer);
12
+ while (propositions.length < n) {
13
+ const offset = randfloat(0.1, 1, 2);
14
+ tryToAddWrongProp(propositions, round(answer.unfrenchify() + offset, 2).frenchify());
15
+ }
16
+ return shuffleProps(propositions, n);
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { xValues, yValues } = identifiers;
20
+ const sum = xValues.reduce((sum, v, i) => sum + v * yValues[i], 0);
21
+ const mean = round(sum, 2);
22
+ return mean.frenchify();
23
+ };
24
+ const getInstruction = (identifiers) => {
25
+ const { xValues, yValues } = identifiers;
26
+ return `Un film a été noté par les spectateurs :
27
+
28
+
29
+ ${mdTable([
30
+ ["Note", ...xValues.map((v) => dollarize(v))],
31
+ ["Fréquence", ...yValues.map((v) => dollarize(`${round(v * 100, 2)} \\%`))],
32
+ ])}
33
+
34
+ Quelle est la note moyenne du film ?`;
35
+ };
36
+ const getHint = (identifiers) => {
37
+ return `Pour calculer la moyenne, multiplie chaque valeur $x_i$ par sa fréquence correspondante $f_i$, puis additionne ces produits.`;
38
+ };
39
+ const getCorrection = (identifiers) => {
40
+ const { xValues, yValues } = identifiers;
41
+ const products = xValues.map((v, i) => round(v * yValues[i], 2));
42
+ const total = getAnswer(identifiers);
43
+ return `On calcule les produits des notes par leur fréquence : \n\n
44
+
45
+ ${xValues
46
+ .map((v, i) => `$$
47
+ ${v} \\times ${yValues[i].frenchify()} = ${products[i].frenchify()}
48
+ $$`)
49
+ .join("\n\n")}
50
+
51
+ En additionnant ces produits, on obtient la moyenne $\\overline{x}$ :
52
+
53
+ $$
54
+ \\overline x = ${total}
55
+ $$`;
56
+ };
57
+ const getKeys = (identifiers) => {
58
+ return [];
59
+ };
60
+ const isAnswerValid = (ans, { answer }) => {
61
+ try {
62
+ const ansNode = parseAlgebraic(ans);
63
+ const answerNode = parseAlgebraic(answer);
64
+ return ansNode.simplify().equals(answerNode.simplify());
65
+ }
66
+ catch (err) {
67
+ return handleVEAError(err);
68
+ }
69
+ };
70
+ const getCalculateMeanFromFrequenciesQuestion = (ops) => {
71
+ const xValues = [0, 1, 2, 3, 4];
72
+ const raw = xValues.map(() => Math.random());
73
+ const total = raw.reduce((sum, v) => sum + v, 0);
74
+ const yValues = raw.map((v) => round(v / total, 2));
75
+ const sumRounded = yValues.reduce((sum, v) => sum + v, 0);
76
+ const diff = round(1 - sumRounded, 2);
77
+ yValues[yValues.length - 1] = round(yValues[yValues.length - 1] + diff, 2);
78
+ const identifiers = { xValues, yValues };
79
+ return getQuestionFromIdentifiers(identifiers);
80
+ };
81
+ const getQuestionFromIdentifiers = (identifiers) => {
82
+ return {
83
+ answer: getAnswer(identifiers),
84
+ instruction: getInstruction(identifiers),
85
+ keys: getKeys(identifiers),
86
+ answerFormat: "tex",
87
+ identifiers,
88
+ hint: getHint(identifiers),
89
+ correction: getCorrection(identifiers),
90
+ };
91
+ };
92
+ export const calculateMeanFromFrequencies = {
93
+ id: "calculateMeanFromFrequencies",
94
+ label: "Calculer une moyenne à partir de fréquences",
95
+ isSingleStep: true,
96
+ generator: (nb, opts) => getDistinctQuestions(() => getCalculateMeanFromFrequenciesQuestion(opts), nb),
97
+ qcmTimer: 60,
98
+ freeTimer: 60,
99
+ getPropositions,
100
+ isAnswerValid,
101
+ subject: "Mathématiques",
102
+ getInstruction,
103
+ getHint,
104
+ getCorrection,
105
+ getAnswer,
106
+ getQuestionFromIdentifiers,
107
+ hasHintAndCorrection: true,
108
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ labels: number[];
4
+ serie1: number[];
5
+ serie2: number[];
6
+ };
7
+ export declare const compareSeriesDispersion: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=compareSeriesDispersion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareSeriesDispersion.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/compareSeriesDispersion.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AA8JF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,CAqBzD,CAAC"}