math-exercises 3.0.75 → 3.0.77

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 (113) hide show
  1. package/lib/exercises/math/calcul/arithmetics/calculateDistanceBetweenNumbers.d.ts +8 -0
  2. package/lib/exercises/math/calcul/arithmetics/calculateDistanceBetweenNumbers.d.ts.map +1 -0
  3. package/lib/exercises/math/calcul/arithmetics/calculateDistanceBetweenNumbers.js +102 -0
  4. package/lib/exercises/math/calcul/arithmetics/compareInverseValues.d.ts +10 -0
  5. package/lib/exercises/math/calcul/arithmetics/compareInverseValues.d.ts.map +1 -0
  6. package/lib/exercises/math/calcul/arithmetics/compareInverseValues.js +136 -0
  7. package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.d.ts +9 -0
  8. package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.d.ts.map +1 -0
  9. package/lib/exercises/math/calcul/arithmetics/compareSquaredValues.js +143 -0
  10. package/lib/exercises/math/calcul/arithmetics/index.d.ts +3 -0
  11. package/lib/exercises/math/calcul/arithmetics/index.d.ts.map +1 -1
  12. package/lib/exercises/math/calcul/arithmetics/index.js +3 -0
  13. package/lib/exercises/math/calcul/sign/index.d.ts +1 -0
  14. package/lib/exercises/math/calcul/sign/index.d.ts.map +1 -1
  15. package/lib/exercises/math/calcul/sign/index.js +1 -0
  16. package/lib/exercises/math/calcul/sign/inverseOrOpposite.d.ts +8 -0
  17. package/lib/exercises/math/calcul/sign/inverseOrOpposite.d.ts.map +1 -0
  18. package/lib/exercises/math/calcul/sign/inverseOrOpposite.js +89 -0
  19. package/lib/exercises/math/functions/cube/compareCubeValues.d.ts +8 -0
  20. package/lib/exercises/math/functions/cube/compareCubeValues.d.ts.map +1 -0
  21. package/lib/exercises/math/functions/cube/compareCubeValues.js +113 -0
  22. package/lib/exercises/math/functions/cube/index.d.ts +1 -0
  23. package/lib/exercises/math/functions/cube/index.d.ts.map +1 -1
  24. package/lib/exercises/math/functions/cube/index.js +1 -0
  25. package/lib/exercises/math/functions/index.d.ts +1 -0
  26. package/lib/exercises/math/functions/index.d.ts.map +1 -1
  27. package/lib/exercises/math/functions/index.js +1 -0
  28. package/lib/exercises/math/functions/parity/parityFromGraph.d.ts.map +1 -1
  29. package/lib/exercises/math/functions/parity/parityFromGraph.js +16 -0
  30. package/lib/exercises/math/functions/sqrt/compareSqrtValues.d.ts +8 -0
  31. package/lib/exercises/math/functions/sqrt/compareSqrtValues.d.ts.map +1 -0
  32. package/lib/exercises/math/functions/sqrt/compareSqrtValues.js +83 -0
  33. package/lib/exercises/math/functions/sqrt/index.d.ts +2 -0
  34. package/lib/exercises/math/functions/sqrt/index.d.ts.map +1 -0
  35. package/lib/exercises/math/functions/sqrt/index.js +1 -0
  36. package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.d.ts.map +1 -1
  37. package/lib/exercises/math/geometry/cartesian/placeAbscissOnLine.js +26 -1
  38. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -1
  39. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +47 -13
  40. package/lib/exercises/math/geometry/lines/linesRelativePositions.d.ts.map +1 -1
  41. package/lib/exercises/math/geometry/lines/linesRelativePositions.js +29 -5
  42. package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.d.ts +8 -0
  43. package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.d.ts.map +1 -0
  44. package/lib/exercises/math/probaStat/calculateMeanFromFrequencies.js +108 -0
  45. package/lib/exercises/math/probaStat/getComplementaryProbability.d.ts +7 -0
  46. package/lib/exercises/math/probaStat/getComplementaryProbability.d.ts.map +1 -0
  47. package/lib/exercises/math/probaStat/getComplementaryProbability.js +90 -0
  48. package/lib/exercises/math/probaStat/getMissingProbabilityValue.d.ts +9 -0
  49. package/lib/exercises/math/probaStat/getMissingProbabilityValue.d.ts.map +1 -0
  50. package/lib/exercises/math/probaStat/getMissingProbabilityValue.js +109 -0
  51. package/lib/exercises/math/probaStat/index.d.ts +4 -0
  52. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  53. package/lib/exercises/math/probaStat/index.js +4 -0
  54. package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
  55. package/lib/exercises/math/probaStat/probaFromTableNoContext.js +1 -1
  56. package/lib/exercises/math/probaStat/probaFromTableWithContext.js +87 -127
  57. package/lib/exercises/math/probaStat/unionIntersectionProba.d.ts +11 -0
  58. package/lib/exercises/math/probaStat/unionIntersectionProba.d.ts.map +1 -0
  59. package/lib/exercises/math/probaStat/unionIntersectionProba.js +164 -0
  60. package/lib/exercises/math/python/conditionIf.d.ts.map +1 -1
  61. package/lib/exercises/math/python/conditionIf.js +32 -1
  62. package/lib/exercises/math/python/conditionIfElifElse.d.ts +9 -0
  63. package/lib/exercises/math/python/conditionIfElifElse.d.ts.map +1 -0
  64. package/lib/exercises/math/python/conditionIfElifElse.js +121 -0
  65. package/lib/exercises/math/python/conditionIfElse.d.ts +10 -0
  66. package/lib/exercises/math/python/conditionIfElse.d.ts.map +1 -0
  67. package/lib/exercises/math/python/conditionIfElse.js +119 -0
  68. package/lib/exercises/math/python/forLoop.d.ts.map +1 -1
  69. package/lib/exercises/math/python/forLoop.js +28 -0
  70. package/lib/exercises/math/python/inOutCalcul.d.ts.map +1 -1
  71. package/lib/exercises/math/python/inOutCalcul.js +31 -4
  72. package/lib/exercises/math/python/index.d.ts +3 -0
  73. package/lib/exercises/math/python/index.d.ts.map +1 -1
  74. package/lib/exercises/math/python/index.js +3 -0
  75. package/lib/exercises/math/python/pyForLoop1Exercise.d.ts.map +1 -1
  76. package/lib/exercises/math/python/pyForLoop1Exercise.js +29 -0
  77. package/lib/exercises/math/python/pyNestedForLoopExercise.d.ts.map +1 -1
  78. package/lib/exercises/math/python/pyNestedForLoopExercise.js +26 -10
  79. package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts +0 -1
  80. package/lib/exercises/math/python/pyWhileLoop1Exercise.d.ts.map +1 -1
  81. package/lib/exercises/math/python/pyWhileLoop1Exercise.js +54 -30
  82. package/lib/exercises/math/python/pythonFunctionTrinom.d.ts.map +1 -1
  83. package/lib/exercises/math/python/pythonFunctionTrinom.js +24 -2
  84. package/lib/exercises/math/python/variableAffectation.d.ts +10 -0
  85. package/lib/exercises/math/python/variableAffectation.d.ts.map +1 -0
  86. package/lib/exercises/math/python/variableAffectation.js +144 -0
  87. package/lib/exercises/math/python/whileLoop.d.ts +0 -1
  88. package/lib/exercises/math/python/whileLoop.d.ts.map +1 -1
  89. package/lib/exercises/math/python/whileLoop.js +37 -6
  90. package/lib/exercises/math/python/whileLoopCount.js +3 -3
  91. package/lib/exercises/math/sequences/explicitFormulaUsage.js +3 -3
  92. package/lib/exercises/math/sequences/genericSequenceVariations.js +2 -2
  93. package/lib/exercises/math/sets/index.d.ts +1 -0
  94. package/lib/exercises/math/sets/index.d.ts.map +1 -1
  95. package/lib/exercises/math/sets/index.js +1 -0
  96. package/lib/exercises/math/sets/nameOfNumberSets.d.ts +8 -0
  97. package/lib/exercises/math/sets/nameOfNumberSets.d.ts.map +1 -0
  98. package/lib/exercises/math/sets/nameOfNumberSets.js +125 -0
  99. package/lib/index.d.ts +55 -7
  100. package/lib/index.d.ts.map +1 -1
  101. package/lib/latexTester.d.ts.map +1 -1
  102. package/lib/latexTester.js +24 -7
  103. package/lib/math/polynomials/affine.d.ts +2 -1
  104. package/lib/math/polynomials/affine.d.ts.map +1 -1
  105. package/lib/math/polynomials/affine.js +5 -2
  106. package/lib/tree/nodes/functions/oppositeNode.d.ts +2 -2
  107. package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
  108. package/lib/tree/nodes/functions/oppositeNode.js +4 -2
  109. package/lib/tree/nodes/node.d.ts +2 -0
  110. package/lib/tree/nodes/node.d.ts.map +1 -1
  111. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  112. package/lib/tree/nodes/operators/fractionNode.js +8 -7
  113. package/package.json +1 -1
@@ -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,7 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ pA: number;
4
+ };
5
+ export declare const getComplementaryProbability: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=getComplementaryProbability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getComplementaryProbability.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/getComplementaryProbability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAiFF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,CAoB7D,CAAC"}
@@ -0,0 +1,90 @@
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 { randfloat } from "../../../math/utils/random/randfloat.js";
5
+ import { round } from "../../../math/utils/round.js";
6
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
7
+ const getPropositions = (n, { answer }) => {
8
+ const propositions = [];
9
+ addValidProp(propositions, answer);
10
+ while (propositions.length < n) {
11
+ const wrongVal = randfloat(0.1, 0.95, 2);
12
+ tryToAddWrongProp(propositions, wrongVal.frenchify());
13
+ }
14
+ return shuffleProps(propositions, n);
15
+ };
16
+ const getAnswer = ({ pA }) => {
17
+ return round(1 - pA, 2).frenchify();
18
+ };
19
+ const getInstruction = ({ pA }) => {
20
+ return `Soit $A$ un événement tel que $P(A) = ${pA.frenchify()}$.
21
+
22
+ Que vaut la probabilité $P(\\overline A)$ ?`;
23
+ };
24
+ const getHint = () => {
25
+ return `La probabilité de l'évènement complémentaire $\\overline{A}$ s'obtient par la formule :
26
+
27
+ $$
28
+ P(\\overline A) = 1 - P(A)
29
+ $$`;
30
+ };
31
+ const getCorrection = ({ pA }) => {
32
+ const answer = getAnswer({ pA });
33
+ return `La probabilité de l'évènement complémentaire $\\overline{A}$ s'obtient par la formule :
34
+
35
+ $$
36
+ P(\\overline A) = 1 - P(A)
37
+ $$
38
+
39
+ Ici, on a donc :
40
+
41
+ $$
42
+ P(\\overline A) = 1 - ${pA.frenchify()} = ${answer}
43
+ $$`;
44
+ };
45
+ const getKeys = () => {
46
+ return [];
47
+ };
48
+ const isAnswerValid = (ans, { answer }) => {
49
+ try {
50
+ const ansNode = parseAlgebraic(ans);
51
+ const answerNode = parseAlgebraic(answer);
52
+ return ansNode.simplify().equals(answerNode.simplify());
53
+ }
54
+ catch (err) {
55
+ return handleVEAError(err);
56
+ }
57
+ };
58
+ const getGetComplementaryProbabilityQuestion = () => {
59
+ const pA = randfloat(0.1, 0.99, 2);
60
+ const identifiers = { pA };
61
+ return getQuestionFromIdentifiers(identifiers);
62
+ };
63
+ const getQuestionFromIdentifiers = (identifiers) => {
64
+ return {
65
+ answer: getAnswer(identifiers),
66
+ instruction: getInstruction(identifiers),
67
+ keys: getKeys(identifiers),
68
+ answerFormat: "tex",
69
+ identifiers,
70
+ hint: getHint(identifiers),
71
+ correction: getCorrection(identifiers),
72
+ };
73
+ };
74
+ export const getComplementaryProbability = {
75
+ id: "getComplementaryProbability",
76
+ label: "Calculer la probabilité d'un évènement complémentaire",
77
+ isSingleStep: true,
78
+ generator: (nb, opts) => getDistinctQuestions(() => getGetComplementaryProbabilityQuestion(opts), nb),
79
+ qcmTimer: 60,
80
+ freeTimer: 60,
81
+ getPropositions,
82
+ isAnswerValid,
83
+ subject: "Mathématiques",
84
+ getInstruction,
85
+ getHint,
86
+ getCorrection,
87
+ getAnswer,
88
+ getQuestionFromIdentifiers,
89
+ hasHintAndCorrection: true,
90
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ labels: string[];
4
+ pValues: number[];
5
+ missingIndex: number;
6
+ };
7
+ export declare const getMissingProbabilityValue: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=getMissingProbabilityValue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMissingProbabilityValue.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/getMissingProbabilityValue.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAiHF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAiB5D,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { addValidProp, tryToAddWrongProp, shuffleProps, } from "../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
+ import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
4
+ import { randfloat } from "../../../math/utils/random/randfloat.js";
5
+ import { round } from "../../../math/utils/round.js";
6
+ import { dollarize } from "../../../utils/latex/dollarize.js";
7
+ import { mdTable } from "../../../utils/markdown/mdTable.js";
8
+ import { parseAlgebraic } from "../../../tree/parsers/latexParser.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const props = [];
11
+ addValidProp(props, answer);
12
+ while (props.length < n) {
13
+ const numeric = answer.unfrenchify();
14
+ const offset = randfloat(-0.2, 0.2, 2);
15
+ const candidate = round(numeric + offset, 2).frenchify();
16
+ tryToAddWrongProp(props, candidate);
17
+ }
18
+ return shuffleProps(props, n);
19
+ };
20
+ const getAnswer = ({ pValues, missingIndex }) => {
21
+ return pValues[missingIndex].frenchify();
22
+ };
23
+ const getInstruction = ({ labels, pValues, missingIndex, }) => {
24
+ return `Quelle est la valeur manquante dans la loi de probabilité suivante ?
25
+
26
+ ${mdTable([
27
+ ["Issue", ...labels.map((l) => dollarize(l))],
28
+ [
29
+ "Probabilité",
30
+ ...pValues.map((p, i) => i === missingIndex ? "..." : dollarize(p.frenchify())),
31
+ ],
32
+ ])}`;
33
+ };
34
+ const getHint = () => {
35
+ return `La somme des probabilités d'une loi de probabilité est égale à $1$.`;
36
+ };
37
+ const getCorrection = ({ labels, pValues, missingIndex, }) => {
38
+ const knownTerms = labels
39
+ .map((l, i) => (i === missingIndex ? null : pValues[i].frenchify()))
40
+ .filter(Boolean)
41
+ .join("+");
42
+ const sumKnown = round(pValues.filter((_, i) => i !== missingIndex).reduce((s, v) => s + v, 0), 2);
43
+ const missing = round(1 - sumKnown, 2);
44
+ return `
45
+ On additionne les probabilités connues :
46
+
47
+ $$
48
+ ${knownTerms} = ${sumKnown.frenchify()}
49
+ $$
50
+
51
+ Puisque la somme des probabilités d'une loi de probabilité vaut $1$, on peut en déduire la probabilité manquante :
52
+
53
+
54
+ $$
55
+ P(${labels[missingIndex]}) = 1 - ${sumKnown.frenchify()} = ${missing.frenchify()}.
56
+ $$
57
+ `;
58
+ };
59
+ const getKeys = () => {
60
+ return [];
61
+ };
62
+ const isAnswerValid = (ans, { answer }) => {
63
+ try {
64
+ const a = parseAlgebraic(ans);
65
+ const b = parseAlgebraic(answer);
66
+ return a.simplify().equals(b.simplify());
67
+ }
68
+ catch (err) {
69
+ return handleVEAError(err);
70
+ }
71
+ };
72
+ const getGetMissingProbabilityValueQuestion = () => {
73
+ const labels = ["A", "B", "C", "D", "E"];
74
+ const raw = labels.map(() => Math.random());
75
+ const total = raw.reduce((s, v) => s + v, 0);
76
+ let pValues = raw.map((v) => round(v / total, 2));
77
+ // ajustement pour que la somme fasse exactement 1
78
+ const sumRounded = pValues.reduce((s, v) => s + v, 0);
79
+ const diff = round(1 - sumRounded, 2);
80
+ pValues[pValues.length - 1] = round(pValues[pValues.length - 1] + diff, 2);
81
+ const missingIndex = Math.floor(Math.random() * labels.length);
82
+ return getQuestionFromIdentifiers({ labels, pValues, missingIndex });
83
+ };
84
+ const getQuestionFromIdentifiers = (identifiers) => ({
85
+ answer: getAnswer(identifiers),
86
+ instruction: getInstruction(identifiers),
87
+ keys: getKeys(identifiers),
88
+ answerFormat: "tex",
89
+ identifiers,
90
+ hint: getHint(identifiers),
91
+ correction: getCorrection(identifiers),
92
+ });
93
+ export const getMissingProbabilityValue = {
94
+ id: "getMissingProbabilityValue",
95
+ label: "Calculer une valeur manquante dans une loi de probabilité",
96
+ isSingleStep: true,
97
+ generator: (nb, opts) => getDistinctQuestions(() => getGetMissingProbabilityValueQuestion(opts), nb),
98
+ qcmTimer: 60,
99
+ freeTimer: 60,
100
+ getPropositions,
101
+ isAnswerValid,
102
+ subject: "Mathématiques",
103
+ getInstruction,
104
+ getHint,
105
+ getCorrection,
106
+ getAnswer,
107
+ getQuestionFromIdentifiers,
108
+ hasHintAndCorrection: true,
109
+ };
@@ -12,4 +12,8 @@ export * from "./probaFromTableWithContext.js";
12
12
  export * from "./binomial/index.js";
13
13
  export * from "./basicStats/index.js";
14
14
  export * from "./randomVariable/index.js";
15
+ export * from "./getMissingProbabilityValue.js";
16
+ export * from "./getComplementaryProbability.js";
17
+ export * from "./unionIntersectionProba.js";
18
+ export * from "./calculateMeanFromFrequencies.js";
15
19
  //# sourceMappingURL=index.d.ts.map
@@ -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,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/index.ts"],"names":[],"mappings":"AAAA,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"}
@@ -12,3 +12,7 @@ export * from "./probaFromTableWithContext.js";
12
12
  export * from "./binomial/index.js";
13
13
  export * from "./basicStats/index.js";
14
14
  export * from "./randomVariable/index.js";
15
+ export * from "./getMissingProbabilityValue.js";
16
+ export * from "./getComplementaryProbability.js";
17
+ export * from "./unionIntersectionProba.js";
18
+ export * from "./calculateMeanFromFrequencies.js";
@@ -1 +1 @@
1
- {"version":3,"file":"probaFromTableNoContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableNoContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,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;AAuTF,KAAK,OAAO,GAAG;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAuBF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBlE,CAAC"}
1
+ {"version":3,"file":"probaFromTableNoContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableNoContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAiBT,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;AAyTF,KAAK,OAAO,GAAG;IAEb,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAuBF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBlE,CAAC"}
@@ -149,7 +149,7 @@ const getCorrection = (identifiers) => {
149
149
  : event === "P(\\overline A)"
150
150
  ? "\\overline{A}"
151
151
  : "\\overline{B}";
152
- return `On lit le total de la ligne $${singleEvnmt}$ : c'est $${probaFrac[0]}$. La probabilité $${event}$ vaut donc :
152
+ return `On lit le total de la ${singleEvnmt.includes("A") ? "ligne" : "colonne"} $${singleEvnmt}$ : c'est $${probaFrac[0]}$. La probabilité $${event}$ vaut donc :
153
153
 
154
154
  $$
155
155
  ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
@@ -2,6 +2,7 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../exercis
2
2
  import { getDistinctQuestions } from "../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Rational } from "../../../math/numbers/rationals/rational.js";
4
4
  import { randint } from "../../../math/utils/random/randint.js";
5
+ import { frac } from "../../../tree/nodes/operators/fractionNode.js";
5
6
  import { rationalParser } from "../../../tree/parsers/rationalParser.js";
6
7
  import { random } from "../../../utils/alea/random.js";
7
8
  import { handleVEAError } from "../../../utils/errors/handleVEAError.js";
@@ -145,133 +146,92 @@ const isAnswerValid = (ans, { answer, probaFrac }, options) => {
145
146
  return handleVEAError(err);
146
147
  }
147
148
  };
148
- // const getHint: GetHint<Identifiers> = (identifiers) => {
149
- // const {
150
- // aBarreCapB,
151
- // aBarreCapBBarre,
152
- // aCapB,
153
- // aCapBBarre,
154
- // probaFrac,
155
- // type,
156
- // event,
157
- // } = identifiers;
158
- // switch (type) {
159
- // case "singleEvent":
160
- // return `Lit le total d'issues de l'évènement demandé, puis divise par le total des issues.`;
161
- // case "union":
162
- // 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.`;
163
- // case "intersection":
164
- // default:
165
- // return `Lit la case qui correspond aux issues appartenant à la fois aux deux événements demandés.`;
166
- // }
167
- // };
168
- // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {
169
- // const {
170
- // aBarreCapB,
171
- // aBarreCapBBarre,
172
- // aCapB,
173
- // aCapBBarre,
174
- // probaFrac,
175
- // type,
176
- // event,
177
- // } = identifiers;
178
- // const aTotal = aCapB + aCapBBarre;
179
- // const bTotal = aCapB + aBarreCapB;
180
- // const aBarreTotal = aBarreCapB + aBarreCapBBarre;
181
- // const bBarreTotal = aBarreCapBBarre + aCapBBarre;
182
- // switch (type) {
183
- // case "singleEvent":
184
- // const singleEvnmt =
185
- // event === "P(A)"
186
- // ? "A"
187
- // : event === "P(B)"
188
- // ? "B"
189
- // : event === "P(\\overline A)"
190
- // ? "\\overline{A}"
191
- // : "\\overline{B}";
192
- // return `On lit le total de la ligne $${singleEvnmt}$ : c'est $${
193
- // probaFrac[0]
194
- // }$. La probabilité $${event}$ vaut donc :
195
- // $$
196
- // ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
197
- // $$`;
198
- // case "union":
199
- // const unionEvements =
200
- // event === "P(A\\cup B)"
201
- // ? ["A", "B"]
202
- // : event === "P(A\\cup \\overline B)"
203
- // ? ["A", "\\overline{B}"]
204
- // : event === "P(\\overline A \\cup B)"
205
- // ? ["\\overline{A}", "B"]
206
- // : ["\\overline{A}", "\\overline{B}"];
207
- // const rowTotal = unionEvements[0] === "A" ? aTotal : aBarreTotal;
208
- // const columnTotal = unionEvements[1] === "B" ? bTotal : bBarreTotal;
209
- // return `On additionne les totaux de la ligne $${
210
- // unionEvements[0]
211
- // }$ et de la colonne $${
212
- // unionEvements[1]
213
- // }$ : cela donne $${rowTotal} + ${columnTotal} = ${
214
- // rowTotal + columnTotal
215
- // }$. On doit ensuite soustraire la case à l'intersection de la ligne $${
216
- // unionEvements[0]
217
- // }$ et de la colonne $${
218
- // unionEvements[1]
219
- // }$, car on l'a compté deux fois dans les totaux. Cela donne $${
220
- // rowTotal + columnTotal
221
- // } - ${rowTotal + columnTotal - probaFrac[0]} = ${probaFrac[0]}
222
- // $.
223
- // La probabilité $${event}$ vaut donc :
224
- // $$
225
- // ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
226
- // $$`;
227
- // case "intersection":
228
- // default:
229
- // const interEvemnts =
230
- // event === "P(A\\cup B)"
231
- // ? ["A", "B"]
232
- // : event === "P(A\\cup \\overline B)"
233
- // ? ["A", "\\overline{B}"]
234
- // : event === "P(\\overline A \\cup B)"
235
- // ? ["\\overline{A}", "B"]
236
- // : ["\\overline{A}", "\\overline{B}"];
237
- // return `On lit la case à l'intersection de la colonne $${
238
- // interEvemnts[1]
239
- // }$ et de la ligne $${interEvemnts[0]}$ : c'est $${
240
- // probaFrac[0]
241
- // }$. La probabilité $${event}$ vaut donc :
242
- // $$
243
- // ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
244
- // $$`;
245
- // const condEvents =
246
- // event === "P_A(B)"
247
- // ? ["A", "B"]
248
- // : event === "P_{\\overline A}(B)"
249
- // ? ["\\overline{A}", "B"]
250
- // : event === "P_A(\\overline B)"
251
- // ? ["A", "\\overline{B}"]
252
- // : event === "P_{\\overline B}(A)"
253
- // ? ["\\overline{B}", "A"]
254
- // : event === "P_B(A)"
255
- // ? ["B", "A"]
256
- // : event === "P_B(\\overline{A})"
257
- // ? ["B", "\\overline{A}"]
258
- // : event === "P_{\\overline A}(\\overline B)"
259
- // ? ["\\overline{A}", "\\overline{B}"]
260
- // : ["\\overline{B}", "\\overline{A}"];
261
- // return `On cherche la probabilité de $${condEvents[1]}$ sachant que $${
262
- // condEvents[0]
263
- // }$ est vrai. On lit la case à l'intersection de $${
264
- // condEvents[1]
265
- // }$ et $${condEvents[0]}$ : c'est $${
266
- // probaFrac[0]
267
- // }$. On doit ensuite diviser par le total de l'évènement $${
268
- // condEvents[0]
269
- // }$. La probabilité $${event}$ vaut donc :
270
- // $$
271
- // ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
272
- // $$`;
273
- // }
274
- // };
149
+ const getHint = (identifiers) => {
150
+ const { aBarreCapB, aBarreCapBBarre, aCapB, aCapBBarre, probaFrac, type, event, } = identifiers;
151
+ switch (type) {
152
+ case "singleEvent":
153
+ return `Lit le total d'issues de l'évènement demandé, puis divise par le total des issues.`;
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.`;
156
+ case "intersection":
157
+ default:
158
+ return `Lit la case qui correspond aux issues appartenant à la fois aux deux événements demandés.`;
159
+ }
160
+ };
161
+ const getCorrection = (identifiers) => {
162
+ const { aBarreCapB, aBarreCapBBarre, aCapB, aCapBBarre, probaFrac, type, event, } = identifiers;
163
+ const aTotal = aCapB + aCapBBarre;
164
+ const bTotal = aCapB + aBarreCapB;
165
+ const aBarreTotal = aBarreCapB + aBarreCapBBarre;
166
+ const bBarreTotal = aBarreCapBBarre + aCapBBarre;
167
+ switch (type) {
168
+ case "singleEvent":
169
+ const singleEvnmt = event === "une fille"
170
+ ? "A"
171
+ : event === "un garçon"
172
+ ? "\\overline{A}"
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 :
177
+
178
+ $$
179
+ ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
180
+ $$`;
181
+ 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]}
192
+ $.
193
+
194
+ La probabilité $${event}$ vaut donc :
195
+
196
+ $$
197
+ ${event} = ${frac(probaFrac[0], probaFrac[1]).toSimplificationTex()}
198
+ $$`;
199
+ case "intersection":
200
+ 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 :
209
+
210
+ $$
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()}
232
+ $$`;
233
+ }
234
+ };
275
235
  export const probaFromTableWithContext = {
276
236
  id: "probaFromTableWithContext",
277
237
  connector: "=",
@@ -0,0 +1,11 @@
1
+ import { Exercise } from "../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ pA: number;
4
+ pB: number;
5
+ pUnion: number;
6
+ pIntersection: number;
7
+ target: "pA" | "pB" | "pUnion" | "pIntersection";
8
+ };
9
+ export declare const unionIntersectionProba: Exercise<Identifiers>;
10
+ export {};
11
+ //# sourceMappingURL=unionIntersectionProba.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unionIntersectionProba.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/unionIntersectionProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAYrC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,QAAQ,GAAG,eAAe,CAAC;CAClD,CAAC;AAsKF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAkBxD,CAAC"}