math-exercises 3.0.208 → 3.0.209

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 (73) hide show
  1. package/lib/exercises/math/arithmetic/congruenceBasicComputation.d.ts +8 -0
  2. package/lib/exercises/math/arithmetic/congruenceBasicComputation.d.ts.map +1 -0
  3. package/lib/exercises/math/arithmetic/congruenceBasicComputation.js +93 -0
  4. package/lib/exercises/math/arithmetic/index.d.ts +2 -0
  5. package/lib/exercises/math/arithmetic/index.d.ts.map +1 -0
  6. package/lib/exercises/math/arithmetic/index.js +1 -0
  7. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.d.ts.map +1 -1
  8. package/lib/exercises/math/functions/affines/adjustment/affineAdjustment.js +15 -0
  9. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.d.ts.map +1 -1
  10. package/lib/exercises/math/functions/affines/adjustment/affineAdjustmentRsquared.js +15 -0
  11. package/lib/exercises/math/functions/logarithm/log10Simplifying.d.ts.map +1 -1
  12. package/lib/exercises/math/functions/logarithm/log10Simplifying.js +72 -33
  13. package/lib/exercises/math/functions/logarithm/logEquation.d.ts.map +1 -1
  14. package/lib/exercises/math/functions/logarithm/logEquation.js +40 -2
  15. package/lib/exercises/math/functions/logarithm/logPowerEquation.d.ts.map +1 -1
  16. package/lib/exercises/math/functions/logarithm/logPowerEquation.js +55 -6
  17. package/lib/exercises/math/functions/logarithm/logSimplifiying.d.ts.map +1 -1
  18. package/lib/exercises/math/functions/logarithm/logSimplifiying.js +45 -5
  19. package/lib/exercises/math/index.d.ts +1 -0
  20. package/lib/exercises/math/index.d.ts.map +1 -1
  21. package/lib/exercises/math/index.js +1 -0
  22. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts +8 -0
  23. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.d.ts.map +1 -0
  24. package/lib/exercises/math/probaStat/density/findParamToMakeDensity.js +127 -0
  25. package/lib/exercises/math/probaStat/density/index.d.ts +2 -0
  26. package/lib/exercises/math/probaStat/density/index.d.ts.map +1 -0
  27. package/lib/exercises/math/probaStat/density/index.js +1 -0
  28. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts +7 -0
  29. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.d.ts.map +1 -0
  30. package/lib/exercises/math/probaStat/exponential/exponentialLawAverage.js +95 -0
  31. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts +9 -0
  32. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.d.ts.map +1 -0
  33. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.js +115 -0
  34. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts +8 -0
  35. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.d.ts.map +1 -0
  36. package/lib/exercises/math/probaStat/exponential/exponentialLawComputeProba.js +110 -0
  37. package/lib/exercises/math/probaStat/exponential/index.d.ts +4 -0
  38. package/lib/exercises/math/probaStat/exponential/index.d.ts.map +1 -0
  39. package/lib/exercises/math/probaStat/exponential/index.js +3 -0
  40. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts +8 -0
  41. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.d.ts.map +1 -0
  42. package/lib/exercises/math/probaStat/geometric/geometricLawAverage.js +124 -0
  43. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts +9 -0
  44. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.d.ts.map +1 -0
  45. package/lib/exercises/math/probaStat/geometric/geometricLawComputeProba.js +121 -0
  46. package/lib/exercises/math/probaStat/geometric/index.d.ts +3 -0
  47. package/lib/exercises/math/probaStat/geometric/index.d.ts.map +1 -0
  48. package/lib/exercises/math/probaStat/geometric/index.js +2 -0
  49. package/lib/exercises/math/probaStat/index.d.ts +4 -0
  50. package/lib/exercises/math/probaStat/index.d.ts.map +1 -1
  51. package/lib/exercises/math/probaStat/index.js +4 -0
  52. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.d.ts.map +1 -1
  53. package/lib/exercises/math/probaStat/stats2var/fineAdjustementExercise.js +15 -0
  54. package/lib/exercises/math/probaStat/uniform/index.d.ts +3 -0
  55. package/lib/exercises/math/probaStat/uniform/index.d.ts.map +1 -0
  56. package/lib/exercises/math/probaStat/uniform/index.js +2 -0
  57. package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts +8 -0
  58. package/lib/exercises/math/probaStat/uniform/uniformAverage.d.ts.map +1 -0
  59. package/lib/exercises/math/probaStat/uniform/uniformAverage.js +100 -0
  60. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts +10 -0
  61. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.d.ts.map +1 -0
  62. package/lib/exercises/math/probaStat/uniform/uniformLawComputeProba.js +105 -0
  63. package/lib/index.d.ts +29 -1
  64. package/lib/index.d.ts.map +1 -1
  65. package/lib/latexTester.js +1 -0
  66. package/lib/tests/pdfs/formatMdToLatex.js +1 -1
  67. package/lib/tree/nodes/functions/log10Node.d.ts +1 -0
  68. package/lib/tree/nodes/functions/log10Node.d.ts.map +1 -1
  69. package/lib/tree/nodes/functions/log10Node.js +12 -1
  70. package/lib/tree/nodes/functions/logNode.d.ts +1 -0
  71. package/lib/tree/nodes/functions/logNode.d.ts.map +1 -1
  72. package/lib/tree/nodes/functions/logNode.js +12 -1
  73. package/package.json +1 -1
@@ -2,9 +2,11 @@ import { addValidProp, propWhile, 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 { LogNode } from "../../../../tree/nodes/functions/logNode.js";
5
+ import { logn, LogNode } from "../../../../tree/nodes/functions/logNode.js";
6
6
  import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
7
7
  import { AddNode } from "../../../../tree/nodes/operators/addNode.js";
8
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
9
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
8
10
  import { SubstractNode } from "../../../../tree/nodes/operators/substractNode.js";
9
11
  import { coinFlip } from "../../../../utils/alea/coinFlip.js";
10
12
  import { shuffle } from "../../../../utils/alea/shuffle.js";
@@ -21,7 +23,7 @@ const getStatementNode = (identifiers) => {
21
23
  }
22
24
  };
23
25
  const getInstruction = (identifiers) => {
24
- return `Écrire le nombre suivant sous la forme $\\ln\\left(a\\right)$ :
26
+ return `Écrire le nombre suivant sous la forme $\\ln\\left(a\\right)$, avec $a\\in \\mathbb{R}$ :
25
27
 
26
28
  $$
27
29
  ${getStatementNode(identifiers).toTex()}
@@ -36,15 +38,50 @@ const getAnswer = (identifiers) => {
36
38
  return new LogNode(new Rational(a, b).simplify().toTree()).toTex();
37
39
  }
38
40
  };
41
+ const getHint = () => {
42
+ return `Pour tous nombres réels $a$ et $b$ strictement positifs, on a :
43
+
44
+ - $\\ln(a) + \\ln(b) = \\ln(a\\times b)$
45
+ - $\\ln(a) - \\ln(b) = \\ln(\\frac{a}{b})$`;
46
+ };
47
+ const getCorrection = (identifiers) => {
48
+ const { a, b, pm } = identifiers;
49
+ if (pm === 1) {
50
+ return `On sait que pour tous nombres réels $a$ et $b$ strictement positifs, on a :
51
+
52
+ $$
53
+ \\ln(a) + \\ln(b) = \\ln(a\\times b)
54
+ $$
55
+
56
+ Ici on a donc :
57
+
58
+ $$
59
+ \\ln(${a}) + \\ln(${b}) = ${logn(multiply(a, b)).toSimplificationTex()}
60
+ $$`;
61
+ }
62
+ else {
63
+ return `On sait que pour tous nombres réels $a$ et $b$ strictement positifs, on a :
64
+
65
+ $$
66
+ \\ln(a) - \\ln(b) = \\ln(\\frac{a}{b})
67
+ $$
68
+
69
+ Ici on a donc :
70
+
71
+ $$
72
+ \\ln(${a}) - \\ln(${b}) = ${logn(frac(a, b)).toSimplificationTex()}
73
+ $$`;
74
+ }
75
+ };
39
76
  const getKeys = () => {
40
77
  return ["lnBrackets"];
41
78
  };
42
79
  const getExpSimplifiying = () => {
43
80
  const pm = coinFlip() ? 1 : -1;
44
- const a = randint(1, 10);
81
+ const a = randint(2, 10);
45
82
  let b;
46
83
  do {
47
- b = randint(1, 10);
84
+ b = randint(2, 10);
48
85
  } while (pm === -1 && a === b);
49
86
  const identifiers = { pm, a, b };
50
87
  return getQuestionFromIdentifiers(identifiers);
@@ -56,6 +93,8 @@ const getQuestionFromIdentifiers = (identifiers) => {
56
93
  keys: getKeys(identifiers),
57
94
  answerFormat: "tex",
58
95
  identifiers,
96
+ hint: getHint(identifiers),
97
+ correction: getCorrection(identifiers),
59
98
  };
60
99
  return question;
61
100
  };
@@ -85,7 +124,7 @@ const isAnswerValid = (ans, { a, b, pm }) => {
85
124
  export const logSimplifiying = {
86
125
  id: "logSimplifiying",
87
126
  connector: "\\iff",
88
- label: "Simplifier des expressions avec $\\ln$",
127
+ label: "Utiliser la propriété algébrique du logarithme népérien $\\ln(a) \\pm \\ln(b) = \\ln(ab)$",
89
128
  isSingleStep: false,
90
129
  generator: (nb) => getDistinctQuestions(getExpSimplifiying, nb),
91
130
  qcmTimer: 60,
@@ -94,4 +133,5 @@ export const logSimplifiying = {
94
133
  isAnswerValid,
95
134
  subject: "Mathématiques",
96
135
  getQuestionFromIdentifiers,
136
+ hasHintAndCorrection: true,
97
137
  };
@@ -26,4 +26,5 @@ export * from "./tests/index.js";
26
26
  export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
28
  export * from "./integration/index.js";
29
+ export * from "./arithmetic/index.js";
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,uBAAuB,CAAC"}
@@ -27,3 +27,4 @@ export * from "./pcExosInMath.js";
27
27
  export * from "./scratch/index.js";
28
28
  export * from "./integration/index.js";
29
29
  // export * from "./_debug/index.js";
30
+ export * from "./arithmetic/index.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ a: number;
4
+ b: number;
5
+ };
6
+ export declare const findParamToMakeDensity: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=findParamToMakeDensity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findParamToMakeDensity.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/density/findParamToMakeDensity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAUrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AAyHF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAmBxD,CAAC"}
@@ -0,0 +1,127 @@
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 { randint } from "../../../../math/utils/random/randint.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 { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
10
+ const getPropositions = (n, { answer }) => {
11
+ const propositions = [];
12
+ addValidProp(propositions, answer);
13
+ propWhile(propositions, n, () => {
14
+ tryToAddWrongProp(propositions, RationalConstructor.randomIrreductibleProba().toTree().toTex());
15
+ });
16
+ return shuffleProps(propositions, n);
17
+ };
18
+ const getAnswer = (identifiers) => {
19
+ const { a, b } = identifiers;
20
+ // k = 2/(b^2-a^2)
21
+ return frac(2, substract(b ** 2, a ** 2))
22
+ .simplify()
23
+ .toTex();
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const { a, b } = identifiers;
27
+ return `On considère la fonction $f$ définie sur $I = [${a};${b}]$ par :
28
+
29
+ $$
30
+ f(t) = kt
31
+ $$
32
+
33
+ où $k$ est un réel strictement positif.
34
+
35
+ Déterminer la valeur de $k$ pour que $f$ soit une densité de probabilité sur $I$.`;
36
+ };
37
+ const getHint = (identifiers) => {
38
+ const { a, b } = identifiers;
39
+ return `Une fonction $f$ est une densité de probabilité sur un intervalle $[a;b]$ si et seulement si $f$ est continue et positive sur $[a;b]$ et :
40
+
41
+ $$
42
+ \\int_{a}^{b} f(x)\\ \\mathrm{d}x = 1
43
+ $$
44
+
45
+ Ici, il faut donc vérifier que $f$ est continue et positive sur $[${a};${b}]$ et déterminer la valeur de $k$ pour laquelle :
46
+
47
+ $$
48
+ \\int_{${a}}^{${b}} kt\\ \\mathrm{d}t = 1
49
+ $$`;
50
+ };
51
+ const getCorrection = (identifiers) => {
52
+ const { a, b } = identifiers;
53
+ const k = frac(2, substract(b ** 2, a ** 2)).simplify();
54
+ return `$f$ est une fonction affine, elle est donc continue sur $[${a};${b}]$. Puisque $k$ est positif, $f$ est également positive sur $[${a};${b}]$.
55
+
56
+ Une primitive de $f$ sur $[${a};${b}]$ est :
57
+
58
+ $$
59
+ F(t) = \\frac{k}{2}t^2
60
+ $$
61
+
62
+ On intègre alors $f$ sur $[${a};${b}]$ :
63
+
64
+ $$
65
+ \\int_{${a}}^{${b}} f(t)\\ \\mathrm{d}t = F(${b})-F(${a}) = \\frac{k}{2}(${b}^2-${a}^2)
66
+ $$
67
+
68
+ On doit donc résoudre l'équation suivante :
69
+
70
+ $$
71
+ ${multiply(b ** 2 - a ** 2, frac("k", 2)).toTex()} = 1
72
+ $$
73
+
74
+ On trouve $k = ${k.toTex()}$.
75
+
76
+ La fonction $f$ définie par $f(t) = ${multiply(k, "t").toTex()}$ est donc une densité de probabilité sur $[${a};${b}]$.
77
+ `;
78
+ };
79
+ const getKeys = () => {
80
+ return [];
81
+ };
82
+ const isAnswerValid = (ans, { answer }) => {
83
+ try {
84
+ return rationalVEA(ans, answer);
85
+ }
86
+ catch (err) {
87
+ return handleVEAError(err);
88
+ }
89
+ };
90
+ const getFindParamToMakeDensityQuestion = () => {
91
+ const a = randint(1, 10);
92
+ const b = randint(a + 1, a + 8);
93
+ const identifiers = {
94
+ a,
95
+ b,
96
+ };
97
+ return getQuestionFromIdentifiers(identifiers);
98
+ };
99
+ const getQuestionFromIdentifiers = (identifiers) => {
100
+ return {
101
+ answer: getAnswer(identifiers),
102
+ instruction: getInstruction(identifiers),
103
+ keys: getKeys(identifiers),
104
+ answerFormat: "tex",
105
+ identifiers,
106
+ hint: getHint(identifiers),
107
+ correction: getCorrection(identifiers),
108
+ };
109
+ };
110
+ export const findParamToMakeDensity = {
111
+ id: "findParamToMakeDensity",
112
+ connector: "=",
113
+ label: "Déterminer un paramètre pour qu'une fonction soit une densité de probabilité",
114
+ isSingleStep: true,
115
+ generator: (nb, opts) => getDistinctQuestions(() => getFindParamToMakeDensityQuestion(opts), nb),
116
+ qcmTimer: 60,
117
+ freeTimer: 60,
118
+ getPropositions,
119
+ isAnswerValid,
120
+ subject: "Mathématiques",
121
+ getInstruction,
122
+ getHint,
123
+ getCorrection,
124
+ getAnswer,
125
+ getQuestionFromIdentifiers,
126
+ hasHintAndCorrection: true,
127
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./findParamToMakeDensity.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/density/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from "./findParamToMakeDensity.js";
@@ -0,0 +1,7 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lambda: number;
4
+ };
5
+ export declare const exponentialLawAverage: Exercise<Identifiers>;
6
+ export {};
7
+ //# sourceMappingURL=exponentialLawAverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exponentialLawAverage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/exponential/exponentialLawAverage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AASrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAgFF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAkBvD,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { round } from "../../../../math/utils/round.js";
6
+ import { frac } from "../../../../tree/nodes/operators/fractionNode.js";
7
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
8
+ import { approxOrEqual } from "../../../../utils/latex/approxOrEqual.js";
9
+ const getPropositions = (n, { answer }) => {
10
+ const propositions = [];
11
+ addValidProp(propositions, answer);
12
+ propWhile(propositions, n, () => {
13
+ tryToAddWrongProp(propositions, randfloat(0.01, 0.9, 2).frenchify());
14
+ });
15
+ return shuffleProps(propositions, n);
16
+ };
17
+ const getAnswer = (identifiers) => {
18
+ const { lambda } = identifiers;
19
+ return round(frac(1, lambda).evaluate(), 2).frenchify();
20
+ };
21
+ const getInstruction = (identifiers) => {
22
+ const { lambda } = identifiers;
23
+ return `Soit $X$ une variable aléatoire qui suit une loi exponentielle de paramètre $${lambda.frenchify()}$.
24
+
25
+ Quelle est l'espérance $E(X)$ de $X$ ? Donner une valeur arrondie au centième.`;
26
+ };
27
+ const getHint = () => {
28
+ return `L'espérance d'une variable aléatoire $X$ de loi exponentielle de paramètre $\\lambda>0$ est égale à :
29
+
30
+ $$
31
+ E(X) = \\frac{1}{\\lambda}
32
+ $$`;
33
+ };
34
+ const getCorrection = (identifiers) => {
35
+ const { lambda } = identifiers;
36
+ const ans = frac(1, lambda).evaluate();
37
+ return `L'espérance d'une variable aléatoire $X$ de loi exponentielle de paramètre $\\lambda>0$ est égale à :
38
+
39
+ $$
40
+ E(X) = \\frac{1}{\\lambda}
41
+ $$
42
+
43
+ Ici, on a donc :
44
+
45
+ $$
46
+ E(X) = ${frac(1, lambda).toTex()} ${approxOrEqual(ans, 2).join("")}
47
+ $$`;
48
+ };
49
+ const getKeys = () => {
50
+ return [];
51
+ };
52
+ const isAnswerValid = (ans, { answer }) => {
53
+ try {
54
+ return numberVEA(ans, answer);
55
+ }
56
+ catch (err) {
57
+ return handleVEAError(err);
58
+ }
59
+ };
60
+ const getExponentialLawAverageQuestion = () => {
61
+ const lambda = randfloat(0.01, 1, 2);
62
+ const identifiers = {
63
+ lambda,
64
+ };
65
+ return getQuestionFromIdentifiers(identifiers);
66
+ };
67
+ const getQuestionFromIdentifiers = (identifiers) => {
68
+ return {
69
+ answer: getAnswer(identifiers),
70
+ instruction: getInstruction(identifiers),
71
+ keys: getKeys(identifiers),
72
+ answerFormat: "tex",
73
+ identifiers,
74
+ hint: getHint(identifiers),
75
+ correction: getCorrection(identifiers),
76
+ };
77
+ };
78
+ export const exponentialLawAverage = {
79
+ id: "exponentialLawAverage",
80
+ connector: "=",
81
+ label: "Calculer l'espérance d'une loi exponentielle",
82
+ isSingleStep: true,
83
+ generator: (nb, opts) => getDistinctQuestions(() => getExponentialLawAverageQuestion(opts), nb),
84
+ qcmTimer: 60,
85
+ freeTimer: 60,
86
+ getPropositions,
87
+ isAnswerValid,
88
+ subject: "Mathématiques",
89
+ getInstruction,
90
+ getHint,
91
+ getCorrection,
92
+ getAnswer,
93
+ getQuestionFromIdentifiers,
94
+ hasHintAndCorrection: true,
95
+ };
@@ -0,0 +1,9 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lambda: number;
4
+ a: number;
5
+ b: number;
6
+ };
7
+ export declare const exponentialLawComputeIntervalProba: Exercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=exponentialLawComputeIntervalProba.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exponentialLawComputeIntervalProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/exponential/exponentialLawComputeIntervalProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AA8GF,eAAO,MAAM,kCAAkC,EAAE,QAAQ,CAAC,WAAW,CAmBpE,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
+ import { exp } from "../../../../tree/nodes/functions/expNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
+ const getPropositions = (n, { answer }) => {
12
+ const propositions = [];
13
+ addValidProp(propositions, answer);
14
+ propWhile(propositions, n, () => {
15
+ tryToAddWrongProp(propositions, randfloat(0.01, 0.9, 2).frenchify());
16
+ });
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { a, b, lambda } = identifiers;
21
+ return round(substract(exp(-a * lambda), exp(-b * lambda)).evaluate(), 2).frenchify();
22
+ };
23
+ const getInstruction = (identifiers) => {
24
+ const { a, b, lambda } = identifiers;
25
+ return `Soit $X$ une variable aléatoire qui suit une loi exponentielle de paramètre $${lambda.frenchify()}$.
26
+
27
+ Calculer $P(${a}\\leq X\\leq ${b})$.
28
+
29
+ Donner une valeur approchée au centième.`;
30
+ };
31
+ const getHint = () => {
32
+ return `Si $X$ suit une loi exponentielle de paramètre $\\lambda$, alors pour tous réels
33
+ $c$ et $d$ positifs tels que $c\\leq d$, on a :
34
+
35
+ $$
36
+ P(a\\leq X\\leq b) = e^{-\\lambda a} - e^{-\\lambda b}
37
+ $$`;
38
+ };
39
+ const getCorrection = (identifiers) => {
40
+ const { a, b, lambda } = identifiers;
41
+ return `Si $X$ suit une loi exponentielle de paramètre $\\lambda$, alors pour tous réels
42
+ $c$ et $d$ positifs tels que $c\\leq d$, on a :
43
+
44
+ $$
45
+ P(a\\leq X\\leq b) = e^{-\\lambda a} - e^{-\\lambda b}
46
+ $$
47
+
48
+ Ici, on a donc :
49
+
50
+ $$
51
+ P(${a}\\leq X\\leq ${b}) = e^{${multiply(-lambda, a).toTex()}}-e^{${multiply(-lambda, b).toTex()}} \\approx ${getAnswer(identifiers)}
52
+ $$`;
53
+ };
54
+ const getKeys = () => {
55
+ return [];
56
+ };
57
+ const isAnswerValid = (ans, { answer }) => {
58
+ try {
59
+ return numberVEA(ans, answer);
60
+ }
61
+ catch (err) {
62
+ return handleVEAError(err);
63
+ }
64
+ };
65
+ const getExponentialLawComputeProbaQuestion = () => {
66
+ let lambda;
67
+ let a;
68
+ let b;
69
+ let rounded;
70
+ let counter = 0;
71
+ do {
72
+ counter++;
73
+ if (counter > 1000)
74
+ throw new Error("too many iterations in exponentialLawComputeProba");
75
+ lambda = randfloat(0.01, 1, 2);
76
+ a = randint(2, 20);
77
+ b = randint(a + 5, a + 15);
78
+ rounded = round(substract(exp(-a * lambda), exp(-b * lambda)).evaluate(), 2);
79
+ } while (rounded === 0);
80
+ const identifiers = {
81
+ lambda,
82
+ a,
83
+ b,
84
+ };
85
+ return getQuestionFromIdentifiers(identifiers);
86
+ };
87
+ const getQuestionFromIdentifiers = (identifiers) => {
88
+ return {
89
+ answer: getAnswer(identifiers),
90
+ instruction: getInstruction(identifiers),
91
+ keys: getKeys(identifiers),
92
+ answerFormat: "tex",
93
+ identifiers,
94
+ hint: getHint(identifiers),
95
+ correction: getCorrection(identifiers),
96
+ };
97
+ };
98
+ export const exponentialLawComputeIntervalProba = {
99
+ id: "exponentialLawComputeIntervalProba",
100
+ connector: "=",
101
+ label: "Calculer une probabilité du type $P(a\\leq X\\leq b)$ pour une loi exponentielle",
102
+ isSingleStep: true,
103
+ generator: (nb, opts) => getDistinctQuestions(() => getExponentialLawComputeProbaQuestion(opts), nb),
104
+ qcmTimer: 60,
105
+ freeTimer: 60,
106
+ getPropositions,
107
+ isAnswerValid,
108
+ subject: "Mathématiques",
109
+ getInstruction,
110
+ getHint,
111
+ getCorrection,
112
+ getAnswer,
113
+ getQuestionFromIdentifiers,
114
+ hasHintAndCorrection: true,
115
+ };
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ type Identifiers = {
3
+ lambda: number;
4
+ k: number;
5
+ };
6
+ export declare const exponentialLawComputeProba: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=exponentialLawComputeProba.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exponentialLawComputeProba.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/exponential/exponentialLawComputeProba.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAWrC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;CAEX,CAAC;AAkGF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAmB5D,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { addValidProp, shuffleProps, propWhile, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { numberVEA } from "../../../../exercises/vea/numberVEA.js";
4
+ import { randfloat } from "../../../../math/utils/random/randfloat.js";
5
+ import { randint } from "../../../../math/utils/random/randint.js";
6
+ import { round } from "../../../../math/utils/round.js";
7
+ import { exp } from "../../../../tree/nodes/functions/expNode.js";
8
+ import { multiply } from "../../../../tree/nodes/operators/multiplyNode.js";
9
+ import { substract } from "../../../../tree/nodes/operators/substractNode.js";
10
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
11
+ const getPropositions = (n, { answer }) => {
12
+ const propositions = [];
13
+ addValidProp(propositions, answer);
14
+ propWhile(propositions, n, () => {
15
+ tryToAddWrongProp(propositions, randfloat(0.01, 0.9, 2).frenchify());
16
+ });
17
+ return shuffleProps(propositions, n);
18
+ };
19
+ const getAnswer = (identifiers) => {
20
+ const { k, lambda } = identifiers;
21
+ return round(substract(1, exp(-k * lambda)).evaluate(), 2).frenchify();
22
+ };
23
+ const getInstruction = (identifiers) => {
24
+ const { k, lambda } = identifiers;
25
+ return `Soit $X$ une variable aléatoire qui suit une loi exponentielle de paramètre $${lambda.frenchify()}$.
26
+
27
+ Calculer $P(X\\leq ${k})$.
28
+
29
+ Donner une valeur approchée au centième.`;
30
+ };
31
+ const getHint = () => {
32
+ return `Si $X$ suit une loi exponentielle de paramètre $\\lambda$, alors pour tout réel $t\\geq 0$, on a :
33
+
34
+ $$
35
+ P(X\\leq t) = 1-e^{-\\lambda t}
36
+ $$`;
37
+ };
38
+ const getCorrection = (identifiers) => {
39
+ const { k, lambda } = identifiers;
40
+ return `Si $X$ suit une loi exponentielle de paramètre $\\lambda$, alors pour tout réel $t\\geq 0$, on a :
41
+
42
+ $$
43
+ P(X\\leq t) = 1-e^{-\\lambda t}
44
+ $$
45
+
46
+ Ici, on a donc :
47
+
48
+ $$
49
+ P(X\\leq ${k}) = 1-e^{${multiply(-lambda, k).toTex()}} \\approx ${getAnswer(identifiers)}
50
+ $$`;
51
+ };
52
+ const getKeys = () => {
53
+ return [];
54
+ };
55
+ const isAnswerValid = (ans, { answer }) => {
56
+ try {
57
+ return numberVEA(ans, answer);
58
+ }
59
+ catch (err) {
60
+ return handleVEAError(err);
61
+ }
62
+ };
63
+ const getExponentialLawComputeProbaQuestion = () => {
64
+ let lambda;
65
+ let k;
66
+ let rounded;
67
+ let counter = 0;
68
+ do {
69
+ counter++;
70
+ if (counter > 1000)
71
+ throw new Error("too many iterations in exponentialLawComputeProba");
72
+ lambda = randfloat(0.01, 1, 2);
73
+ k = randint(2, 20);
74
+ rounded = round(substract(1, exp(-k * lambda)).evaluate(), 2);
75
+ } while (rounded === 1);
76
+ const identifiers = {
77
+ lambda,
78
+ k,
79
+ };
80
+ return getQuestionFromIdentifiers(identifiers);
81
+ };
82
+ const getQuestionFromIdentifiers = (identifiers) => {
83
+ return {
84
+ answer: getAnswer(identifiers),
85
+ instruction: getInstruction(identifiers),
86
+ keys: getKeys(identifiers),
87
+ answerFormat: "tex",
88
+ identifiers,
89
+ hint: getHint(identifiers),
90
+ correction: getCorrection(identifiers),
91
+ };
92
+ };
93
+ export const exponentialLawComputeProba = {
94
+ id: "exponentialLawComputeProba",
95
+ connector: "=",
96
+ label: "Calculer une probabilité du type $P(X\\leq t)$ pour une loi exponentielle",
97
+ isSingleStep: true,
98
+ generator: (nb, opts) => getDistinctQuestions(() => getExponentialLawComputeProbaQuestion(opts), nb),
99
+ qcmTimer: 60,
100
+ freeTimer: 60,
101
+ getPropositions,
102
+ isAnswerValid,
103
+ subject: "Mathématiques",
104
+ getInstruction,
105
+ getHint,
106
+ getCorrection,
107
+ getAnswer,
108
+ getQuestionFromIdentifiers,
109
+ hasHintAndCorrection: true,
110
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./exponentialLawComputeProba.js";
2
+ export * from "./exponentialLawComputeIntervalProba.js";
3
+ export * from "./exponentialLawAverage.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/exponential/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./exponentialLawComputeProba.js";
2
+ export * from "./exponentialLawComputeIntervalProba.js";
3
+ export * from "./exponentialLawAverage.js";
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { NodeIdentifiers } from "../../../../tree/nodes/nodeConstructor.js";
3
+ type Identifiers = {
4
+ pIds: NodeIdentifiers;
5
+ };
6
+ export declare const geometricLawAverage: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=geometricLawAverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometricLawAverage.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/geometric/geometricLawAverage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAeT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EACL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAW7C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AA8GF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}