math-exercises 3.0.188 → 3.0.189

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 (80) hide show
  1. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.d.ts.map +1 -1
  2. package/lib/exercises/math/derivation/derivative/valueDerivativeFromFunctionExpression.js +44 -37
  3. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.d.ts.map +1 -1
  4. package/lib/exercises/math/derivation/variations/findExtremaFromFunctionExpression.js +16 -61
  5. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
  6. package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +27 -35
  7. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts +8 -0
  8. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -0
  9. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +129 -0
  10. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts +8 -0
  11. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.d.ts.map +1 -0
  12. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentComplete.js +108 -0
  13. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts +8 -0
  14. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -0
  15. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +92 -0
  16. package/lib/exercises/math/functions/affines/adjustment/index.d.ts +4 -0
  17. package/lib/exercises/math/functions/affines/adjustment/index.d.ts.map +1 -0
  18. package/lib/exercises/math/functions/affines/adjustment/index.js +3 -0
  19. package/lib/exercises/math/functions/affines/index.d.ts +2 -4
  20. package/lib/exercises/math/functions/affines/index.d.ts.map +1 -1
  21. package/lib/exercises/math/functions/affines/index.js +2 -4
  22. package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts +10 -0
  23. package/lib/exercises/math/functions/affines/situations/affineFromExercise.d.ts.map +1 -0
  24. package/lib/exercises/math/functions/affines/situations/affineFromExercise.js +219 -0
  25. package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts +10 -0
  26. package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.d.ts.map +1 -0
  27. package/lib/exercises/math/functions/affines/situations/affineModelisationSituations.js +69 -0
  28. package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts +10 -0
  29. package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.d.ts.map +1 -0
  30. package/lib/exercises/math/functions/affines/situations/affineSituationComputeAntecedent.js +133 -0
  31. package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts +10 -0
  32. package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.d.ts.map +1 -0
  33. package/lib/exercises/math/functions/affines/situations/affineSituationComputeImage.js +229 -0
  34. package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts +10 -0
  35. package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.d.ts.map +1 -0
  36. package/lib/exercises/math/functions/affines/situations/affineSituationThreshold.js +166 -0
  37. package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts +9 -0
  38. package/lib/exercises/math/functions/affines/situations/affineSituationVariation.d.ts.map +1 -0
  39. package/lib/exercises/math/functions/affines/situations/affineSituationVariation.js +78 -0
  40. package/lib/exercises/math/functions/affines/situations/index.d.ts +6 -0
  41. package/lib/exercises/math/functions/affines/situations/index.d.ts.map +1 -0
  42. package/lib/exercises/math/functions/affines/situations/index.js +5 -0
  43. package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -7
  44. package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
  45. package/lib/exercises/math/probaStat/randomVariable/index.js +1 -7
  46. package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts +8 -0
  47. package/lib/exercises/math/probaStat/randomVariable/situations/index.d.ts.map +1 -0
  48. package/lib/exercises/math/probaStat/randomVariable/situations/index.js +7 -0
  49. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts +11 -0
  50. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.d.ts.map +1 -0
  51. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationAverage.js +112 -0
  52. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts +9 -0
  53. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.d.ts.map +1 -0
  54. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationComputeProbability.js +176 -0
  55. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts +8 -0
  56. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.d.ts.map +1 -0
  57. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationIsGameFavorable.js +94 -0
  58. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts +9 -0
  59. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.d.ts.map +1 -0
  60. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationProbabilityLaw.js +166 -0
  61. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts +8 -0
  62. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.d.ts.map +1 -0
  63. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.js +133 -0
  64. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts +8 -0
  65. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.d.ts.map +1 -0
  66. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.js +211 -0
  67. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts +8 -0
  68. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.d.ts.map +1 -0
  69. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.js +113 -0
  70. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts +41 -0
  71. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.d.ts.map +1 -0
  72. package/lib/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.js +173 -0
  73. package/lib/exercises/math/python/list/pyListMutationMix.d.ts.map +1 -1
  74. package/lib/exercises/math/python/list/pyListMutationMix.js +11 -6
  75. package/lib/index.d.ts +44 -24
  76. package/lib/index.d.ts.map +1 -1
  77. package/lib/tree/utilities/nodeUtils.d.ts +2 -0
  78. package/lib/tree/utilities/nodeUtils.d.ts.map +1 -1
  79. package/lib/tree/utilities/nodeUtils.js +40 -0
  80. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { RandomVariableSituationParams } from "./randomVariableSituations.js";
3
+ type Identifiers = {
4
+ params: RandomVariableSituationParams;
5
+ };
6
+ export declare const randomVariableSituationStandardDeviation: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=randomVariableSituationStandardDeviation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"randomVariableSituationStandardDeviation.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/situations/randomVariableSituationStandardDeviation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAGL,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,6BAA6B,CAAC;CACvC,CAAC;AA6HF,eAAO,MAAM,wCAAwC,EAAE,QAAQ,CAAC,WAAW,CAqB1E,CAAC"}
@@ -0,0 +1,133 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
4
+ import { RationalConstructor } from "../../../../../math/numbers/rationals/rational.js";
5
+ import { sqrt } from "../../../../../tree/nodes/functions/sqrtNode.js";
6
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
7
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
8
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
9
+ import { buildRandomVariableSituation, getRandomVariableSituation, } from "./randomVariableSituations.js";
10
+ const getPropositions = (n, { answer }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer);
13
+ propWhile(propositions, n, () => {
14
+ tryToAddWrongProp(propositions, sqrt(RationalConstructor.randomIrreductible(30).toTree())
15
+ .simplify()
16
+ .toTex());
17
+ });
18
+ return shuffleProps(propositions, n);
19
+ };
20
+ const getAnswer = (identifiers) => {
21
+ const { params } = identifiers;
22
+ const va = getRandomVariableSituation(params).getVA();
23
+ return va.getStandardDeviation().simplify().toTex();
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { params } = identifiers;
27
+ const context = getRandomVariableSituation(params).getContext();
28
+ return (context +
29
+ `
30
+
31
+ Que vaut l'écart-type $\\sigma(X)$ de $X$ ?
32
+
33
+ Donner la valeur exacte ou une valeur arrondie au centième.`);
34
+ };
35
+ const getHint = () => {
36
+ return `Dresse la loi de probabilité de $X$. Pour cela, détermine les valeurs possibles $x_i$ que peut prendre $X$, puis pour chaque valeur, calcule la probabilité $p_i$ associée.
37
+
38
+ Tu peux alors calculer l'espérance de $X$ par la formule :
39
+
40
+ $$
41
+ E(X) = x_1\\times p_1 + \\ldots + x_n\\times p_n
42
+ $$
43
+
44
+ La variance $V(X)$ s'obtient par la formule :
45
+
46
+ $$
47
+ V(X) = p_1(x_1-E(X))^2 + \\ldots + p_n(x_n-E(X))^2
48
+ $$
49
+
50
+ Et enfin, l'écart-type est la racine carrée de la variance :
51
+
52
+ $$
53
+ \\sigma(X) = \\sqrt{V(X)}
54
+ $$
55
+ `;
56
+ };
57
+ const getCorrection = (identifiers) => {
58
+ const { params } = identifiers;
59
+ const va = getRandomVariableSituation(params).getVA();
60
+ return `On dresse la loi de probabilité de $X$ :
61
+
62
+ ${va.getLawMdTable()}
63
+
64
+ Puis on calcule l'espérance :
65
+
66
+ ${alignTex([
67
+ ["E(X)", "=", va.getAverage().toTex()],
68
+ ["", "=", va.getAverage().simplify().toTex()],
69
+ ])}
70
+
71
+ Puis la variance :
72
+
73
+ ${alignTex([
74
+ ["V(X)", "=", va.getVariance().toTex()],
75
+ ["", "=", va.getVariance().simplify().toTex()],
76
+ ])}
77
+
78
+ Enfin, on en déduit l'écart type :
79
+
80
+ ${alignTex([
81
+ ["\\sigma(X)", "=", "\\sqrt{V(X)}"],
82
+ ["", "=", va.getStandardDeviation().simplify().toTex()],
83
+ ])}`;
84
+ };
85
+ const getKeys = () => {
86
+ return [];
87
+ };
88
+ const isAnswerValid = (ans, { answer }) => {
89
+ try {
90
+ const parsed = parseAlgebraic(ans);
91
+ if (!parsed)
92
+ return false;
93
+ return rationalVEA(ans, answer) || parsed.simplify().toTex() === answer;
94
+ }
95
+ catch (err) {
96
+ return handleVEAError(err);
97
+ }
98
+ };
99
+ const getRandomVariableSituationAverageQuestion = () => {
100
+ const params = buildRandomVariableSituation();
101
+ const identifiers = {
102
+ params,
103
+ };
104
+ return getQuestionFromIdentifiers(identifiers);
105
+ };
106
+ const getQuestionFromIdentifiers = (identifiers) => {
107
+ return {
108
+ answer: getAnswer(identifiers),
109
+ instruction: getInstruction(identifiers),
110
+ keys: getKeys(identifiers),
111
+ answerFormat: "tex",
112
+ identifiers,
113
+ hint: getHint(identifiers),
114
+ correction: getCorrection(identifiers),
115
+ };
116
+ };
117
+ export const randomVariableSituationStandardDeviation = {
118
+ id: "randomVariableSituationStandardDeviation",
119
+ connector: "=",
120
+ label: "Calculer l'écart-type $\\sigma(X)$ d'une variable aléatoire dans un contexte",
121
+ isSingleStep: true,
122
+ generator: (nb, opts) => getDistinctQuestions(() => getRandomVariableSituationAverageQuestion(opts), nb),
123
+ qcmTimer: 60,
124
+ freeTimer: 60,
125
+ getPropositions,
126
+ isAnswerValid,
127
+ subject: "Mathématiques",
128
+ getHint,
129
+ getCorrection,
130
+ getAnswer,
131
+ getQuestionFromIdentifiers,
132
+ hasHintAndCorrection: true,
133
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { RandomVariableSituationParams } from "./randomVariableSituations.js";
3
+ type Identifiers = {
4
+ params: RandomVariableSituationParams;
5
+ };
6
+ export declare const randomVariableSituationValues: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=randomVariableSituationValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"randomVariableSituationValues.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/situations/randomVariableSituationValues.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAaT,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAGL,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,6BAA6B,CAAC;CACvC,CAAC;AAuPF,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,WAAW,CAqB/D,CAAC"}
@@ -0,0 +1,211 @@
1
+ import { addValidProp, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { opposite } from "../../../../../tree/nodes/functions/oppositeNode.js";
4
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
5
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
6
+ import { DiscreteSetNode } from "../../../../../tree/nodes/sets/discreteSetNode.js";
7
+ import { discreteSetParser } from "../../../../../tree/parsers/discreteSetParser.js";
8
+ import { shuffle } from "../../../../../utils/alea/shuffle.js";
9
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
10
+ import { buildRandomVariableSituation, getRandomVariableSituation, } from "./randomVariableSituations.js";
11
+ const getAnswer = (identifiers) => {
12
+ const { params } = identifiers;
13
+ const va = getRandomVariableSituation(params).getVA();
14
+ return new DiscreteSetNode(va.xValues).simplify().toTex();
15
+ };
16
+ const getPropositions = (_n, { answer, params }) => {
17
+ const propositions = [];
18
+ addValidProp(propositions, answer);
19
+ switch (params.id) {
20
+ case "coin":
21
+ tryToAddWrongProp(propositions, new DiscreteSetNode([params.a.toTree(), params.b.toTree()])
22
+ .simplify()
23
+ .toTex());
24
+ tryToAddWrongProp(propositions, new DiscreteSetNode(["\\text{Pile}".toTree(), "\\text{Face}".toTree()])
25
+ .simplify()
26
+ .toTex());
27
+ tryToAddWrongProp(propositions, new DiscreteSetNode([params.a.toTree(), (-params.b).toTree()])
28
+ .simplify()
29
+ .toTex());
30
+ tryToAddWrongProp(propositions, new DiscreteSetNode([params.a.toTree(), params.b.toTree()])
31
+ .simplify()
32
+ .toTex());
33
+ break;
34
+ case "urne":
35
+ tryToAddWrongProp(propositions, new DiscreteSetNode([
36
+ "\\text{Blanche}".toTree(),
37
+ "\\text{Rouge}".toTree(),
38
+ "\\text{Noire}".toTree(),
39
+ ])
40
+ .simplify()
41
+ .toTex());
42
+ tryToAddWrongProp(propositions, new DiscreteSetNode([
43
+ params.b.toTree(),
44
+ params.r.toTree(),
45
+ params.n.toTree(),
46
+ ])
47
+ .simplify()
48
+ .toTex());
49
+ tryToAddWrongProp(propositions, new DiscreteSetNode([
50
+ params.gb.toTree(),
51
+ params.gr.toTree(),
52
+ (-params.gn).toTree(),
53
+ ])
54
+ .simplify()
55
+ .toTex());
56
+ break;
57
+ case "diceMultiple": {
58
+ const allValues = [...Array(params.n).keys()].map((i) => i + 1);
59
+ const multiples = [];
60
+ for (let i = 1; i < params.n; i++) {
61
+ if (i % params.winningMultiple === 0) {
62
+ multiples.push(i);
63
+ }
64
+ }
65
+ tryToAddWrongProp(propositions, new DiscreteSetNode(multiples.map((m) => m.toTree()))
66
+ .simplify()
67
+ .toTex());
68
+ tryToAddWrongProp(propositions, new DiscreteSetNode(allValues.map((v) => v.toTree()))
69
+ .simplify()
70
+ .toTex());
71
+ tryToAddWrongProp(propositions, new DiscreteSetNode([params.gain.toTree(), params.loss.toTree()])
72
+ .simplify()
73
+ .toTex());
74
+ }
75
+ }
76
+ return shuffle(propositions);
77
+ };
78
+ const getInstruction = (identifiers) => {
79
+ const { params } = identifiers;
80
+ const context = getRandomVariableSituation(params).getContext();
81
+ return (context +
82
+ `
83
+
84
+ Quel est l'ensemble des valeurs possibles pour $X$ ?`);
85
+ };
86
+ const getHint = (identifiers) => {
87
+ const { params } = identifiers;
88
+ switch (params.id) {
89
+ case "coin":
90
+ return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd des points) en fonction du résultat de ses lancers. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
91
+ case "urne":
92
+ return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd de l'argent) en fonction de la boule qu'il a tirée. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
93
+ case "diceMultiple":
94
+ return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd de l'argent) en fonction de la face obtenue. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
95
+ case "cards":
96
+ return `La variable aléatoire $X$ donne le gain algébrique du joueur (c'est à dire un gain qui peut être négatif si le joueur perd de l'argent) en fonction de la carte qu'il a tirée. Les valeurs $x_i$ qu'elle prend sont donc les valeurs de gain (ou de perte) possibles.`;
97
+ // case "diceSum":
98
+ // return `Chaque dé peut valoir $1$, $2$, $3$ ou $4$. Cela créé donc $16$ résultats possibles, par exemple $1+1=2$, $3+4=7$, etc... Détermine tous les résultats possibles.`;
99
+ }
100
+ };
101
+ const getCorrection = (identifiers) => {
102
+ const { params } = identifiers;
103
+ switch (params.id) {
104
+ case "coin":
105
+ return `On liste toutes les issues possibles :
106
+
107
+ - $2$ piles : le gain du joueur est alors $${multiply(2, params.a).toSimplificationTex()}$ points.
108
+ - $1$ pile, $1$ face : le gain du joueur est alors $${substract(params.a, params.b).toSimplificationTex()}$ points.
109
+ - $2$ faces: le gain du joueur est alors $${opposite(multiply(2, params.b)).toSimplificationTex()}$ points.
110
+
111
+ L'ensemble des valeurs possibles pour $X$ est donc :
112
+
113
+ $$
114
+ ${getAnswer(identifiers)}
115
+ $$
116
+ `;
117
+ case "urne":
118
+ return `Le gain pour chaque tirage vaut :
119
+
120
+ - $${params.gb}$ si on tire une boule blanche ;
121
+ - $${params.gr}$ si on tire une boule rouge ;
122
+ - $${params.gn}$ si on tire une boule noire.
123
+
124
+ L'ensemble des valeurs possibles pour $X$ est donc :
125
+
126
+ $$
127
+ ${getAnswer(identifiers)}
128
+ $$`;
129
+ case "diceMultiple":
130
+ return `Si on obtient un multiple de $${params.winningMultiple}$, on gagne $${params.gain}\\ €$, donc $X$ vaut $${params.gain}$ dans ce cas. Sinon, on perd $${params.loss}\\ €$, donc $X$ vaut $-${params.loss}$.
131
+
132
+ L'ensemble des valeurs possibles pour $X$ est donc :
133
+
134
+ $$
135
+ ${getAnswer(identifiers)}
136
+ $$`;
137
+ case "cards":
138
+ return `Le gain pour chaque tirage vaut :
139
+
140
+ - $${params.gAs}$ si on tire un as ;
141
+ - $${params.gFigure}$ si on tire une figure ;
142
+ - $${params.gOther}$ si on tire une autre carte.
143
+
144
+ L'ensemble des valeurs possibles pour $X$ est donc :
145
+
146
+ $$
147
+ ${getAnswer(identifiers)}
148
+ $$`;
149
+ // case "diceSum": {
150
+ // const results = [["\\ ", "1", "2", "3", "4"], ["1"], ["2"], ["3"], ["4"]];
151
+ // for (let i = 1; i < 5; i++) {
152
+ // for (let j = 1; j < 5; j++) {
153
+ // results[i][j] = (i + j).frenchify();
154
+ // }
155
+ // }
156
+ // return `Voici tous les résultats possibles en fonction du résultat de chaque dé :
157
+ // ${mdTable(results, true)}
158
+ // Les valeurs possibles pour $X$ sont donc :
159
+ // ${mdTable(getAnswerTable(identifiers), true)}`;
160
+ // }
161
+ }
162
+ };
163
+ const getKeys = () => {
164
+ return ["lbrace", "semicolon", "rbrace"];
165
+ };
166
+ const isAnswerValid = (ans, { answer }) => {
167
+ try {
168
+ const parsed = discreteSetParser(ans);
169
+ if (!parsed)
170
+ return false;
171
+ return parsed.simplify().toTex() === answer;
172
+ }
173
+ catch (err) {
174
+ return handleVEAError(err);
175
+ }
176
+ };
177
+ const getRandomVariableSituationValuesQuestion = () => {
178
+ const params = buildRandomVariableSituation();
179
+ const identifiers = {
180
+ params,
181
+ };
182
+ return getQuestionFromIdentifiers(identifiers);
183
+ };
184
+ const getQuestionFromIdentifiers = (identifiers) => {
185
+ return {
186
+ answer: getAnswer(identifiers),
187
+ instruction: getInstruction(identifiers),
188
+ keys: getKeys(identifiers),
189
+ answerFormat: "tex",
190
+ identifiers,
191
+ hint: getHint(identifiers),
192
+ correction: getCorrection(identifiers),
193
+ };
194
+ };
195
+ export const randomVariableSituationValues = {
196
+ id: "randomVariableSituationValues",
197
+ label: "Donner l'ensemble des valeurs possibles d'une variable aléatoire avec contexte",
198
+ isSingleStep: true,
199
+ generator: (nb, opts) => getDistinctQuestions(() => getRandomVariableSituationValuesQuestion(opts), nb),
200
+ qcmTimer: 60,
201
+ freeTimer: 60,
202
+ isAnswerValid,
203
+ getAnswer,
204
+ subject: "Mathématiques",
205
+ getInstruction,
206
+ getHint,
207
+ getCorrection,
208
+ getPropositions,
209
+ getQuestionFromIdentifiers,
210
+ hasHintAndCorrection: true,
211
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { RandomVariableSituationParams } from "./randomVariableSituations.js";
3
+ type Identifiers = {
4
+ params: RandomVariableSituationParams;
5
+ };
6
+ export declare const randomVariableSituationVariance: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=randomVariableSituationVariance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"randomVariableSituationVariance.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/situations/randomVariableSituationVariance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,6BAA6B,CAAC;CACvC,CAAC;AA4GF,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,WAAW,CAqBjE,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { rationalVEA } from "../../../../../exercises/vea/rationalVEA.js";
4
+ import { RationalConstructor } from "../../../../../math/numbers/rationals/rational.js";
5
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
6
+ import { alignTex } from "../../../../../utils/latex/alignTex.js";
7
+ import { buildRandomVariableSituation, getRandomVariableSituation, } from "./randomVariableSituations.js";
8
+ const getPropositions = (n, { answer }) => {
9
+ const propositions = [];
10
+ addValidProp(propositions, answer);
11
+ propWhile(propositions, n, () => {
12
+ tryToAddWrongProp(propositions, RationalConstructor.randomIrreductibleWithSign().toTree().toTex());
13
+ });
14
+ return shuffleProps(propositions, n);
15
+ };
16
+ const getAnswer = (identifiers) => {
17
+ const { params } = identifiers;
18
+ const va = getRandomVariableSituation(params).getVA();
19
+ return va.getVariance().simplify().toTex();
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ const { params } = identifiers;
23
+ const context = getRandomVariableSituation(params).getContext();
24
+ return (context +
25
+ `
26
+
27
+ Que vaut la variance $V(X)$ de $X$ ?
28
+
29
+ Donner la valeur exacte ou une valeur arrondie au centième.`);
30
+ };
31
+ const getHint = () => {
32
+ return `Dresse la loi de probabilité de $X$. Pour cela, détermine les valeurs possibles $x_i$ que peut prendre $X$, puis pour chaque valeur, calcule la probabilité $p_i$ associée.
33
+
34
+ Tu peux alors calculer l'espérance de $X$ par la formule :
35
+
36
+ $$
37
+ E(X) = x_1\\times p_1 + \\ldots + x_n\\times p_n
38
+ $$
39
+
40
+ La variance $V(X)$ s'obtient par la formule :
41
+
42
+ $$
43
+ V(X) = p_1(x_1-E(X))^2 + \\ldots + p_n(x_n-E(X))^2
44
+ $$
45
+ `;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { params } = identifiers;
49
+ const va = getRandomVariableSituation(params).getVA();
50
+ return `On dresse la loi de probabilité de $X$ :
51
+
52
+ ${va.getLawMdTable()}
53
+
54
+ Puis on calcule l'espérance :
55
+
56
+ ${alignTex([
57
+ ["E(X)", "=", va.getAverage().toTex()],
58
+ ["", "=", va.getAverage().simplify().toTex()],
59
+ ])}
60
+
61
+ Enfin, on calcule la variance :
62
+
63
+ ${alignTex([
64
+ ["V(X)", "=", va.getVariance().toTex()],
65
+ ["", "=", va.getVariance().simplify().toTex()],
66
+ ])}`;
67
+ };
68
+ const getKeys = () => {
69
+ return [];
70
+ };
71
+ const isAnswerValid = (ans, { answer }) => {
72
+ try {
73
+ return rationalVEA(ans, answer);
74
+ }
75
+ catch (err) {
76
+ return handleVEAError(err);
77
+ }
78
+ };
79
+ const getRandomVariableSituationAverageQuestion = () => {
80
+ const params = buildRandomVariableSituation();
81
+ const identifiers = {
82
+ params,
83
+ };
84
+ return getQuestionFromIdentifiers(identifiers);
85
+ };
86
+ const getQuestionFromIdentifiers = (identifiers) => {
87
+ return {
88
+ answer: getAnswer(identifiers),
89
+ instruction: getInstruction(identifiers),
90
+ keys: getKeys(identifiers),
91
+ answerFormat: "tex",
92
+ identifiers,
93
+ hint: getHint(identifiers),
94
+ correction: getCorrection(identifiers),
95
+ };
96
+ };
97
+ export const randomVariableSituationVariance = {
98
+ id: "randomVariableSituationVariance",
99
+ connector: "=",
100
+ label: "Calculer la variance $V(X)$ d'une variable aléatoire dans un contexte",
101
+ isSingleStep: true,
102
+ generator: (nb, opts) => getDistinctQuestions(() => getRandomVariableSituationAverageQuestion(opts), nb),
103
+ qcmTimer: 60,
104
+ freeTimer: 60,
105
+ getPropositions,
106
+ isAnswerValid,
107
+ subject: "Mathématiques",
108
+ getHint,
109
+ getCorrection,
110
+ getAnswer,
111
+ getQuestionFromIdentifiers,
112
+ hasHintAndCorrection: true,
113
+ };
@@ -0,0 +1,41 @@
1
+ import { RandomVariable } from "../../../../../math/probability/randomVariable.js";
2
+ type UrneParams = {
3
+ b: number;
4
+ r: number;
5
+ n: number;
6
+ gb: number;
7
+ gr: number;
8
+ gn: number;
9
+ };
10
+ type CoinParams = {
11
+ b: number;
12
+ a: number;
13
+ n: number;
14
+ };
15
+ type DiceMultipleParams = {
16
+ n: number;
17
+ winningMultiple: number;
18
+ gain: number;
19
+ loss: number;
20
+ };
21
+ type CardsParams = {
22
+ gAs: number;
23
+ gFigure: number;
24
+ gOther: number;
25
+ };
26
+ export type RandomVariableSituationParams = (UrneParams & {
27
+ id: "urne";
28
+ }) | (CoinParams & {
29
+ id: "coin";
30
+ }) | (DiceMultipleParams & {
31
+ id: "diceMultiple";
32
+ }) | (CardsParams & {
33
+ id: "cards";
34
+ });
35
+ export declare const getRandomVariableSituation: (params: RandomVariableSituationParams) => {
36
+ getContext: () => string;
37
+ getVA: () => RandomVariable;
38
+ };
39
+ export declare const buildRandomVariableSituation: () => RandomVariableSituationParams;
40
+ export {};
41
+ //# sourceMappingURL=randomVariableSituations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"randomVariableSituations.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/probaStat/randomVariable/situations/randomVariableSituations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAU1E,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAsDF,KAAK,UAAU,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmEF,KAAK,kBAAkB,GAAG;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAkCF,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA4BF,MAAM,MAAM,6BAA6B,GACrC,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7B,CAAC,UAAU,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7B,CAAC,kBAAkB,GAAG;IAAE,EAAE,EAAE,cAAc,CAAA;CAAE,CAAC,GAC7C,CAAC,WAAW,GAAG;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAIpC,eAAO,MAAM,0BAA0B,GACrC,QAAQ,6BAA6B;;;CActC,CAAC;AAEF,eAAO,MAAM,4BAA4B,QACnC,6BAkBH,CAAC"}