{"task_id": "bi-000", "category": "probability", "prompt": "Give the marginal distribution P(X) over X = 0, 1, 2. Return one row of three rationals, so six integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 2, 1, 4, 1, 4]]}"} {"task_id": "bi-001", "category": "probability", "prompt": "Give the marginal distribution P(Y) over Y = 0, 1. Return one row of two rationals, so four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 2, 1, 2]]}"} {"task_id": "bi-002", "category": "probability", "prompt": "Give the conditional distribution P(Y | X = 0) as two rationals, then P(Y | X = 1), then P(Y | X = 2). Return three rows of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 2, 1, 2], [1, 1, 0, 1], [0, 1, 1, 1]]}"} {"task_id": "bi-003", "category": "probability", "prompt": "Are X and Y independent? Answer 1 for yes or 0 for no, then give P(X=1, Y=0) and the product P(X=1)P(Y=0) as two rationals, in that order. Return one row of five integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[0, 1, 4, 1, 8]]}"} {"task_id": "bi-004", "category": "probability", "prompt": "For the diagnostic test, give P(+) and then P(D | +), as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[297, 10000, 1, 3]]}"} {"task_id": "bi-005", "category": "probability", "prompt": "For the diagnostic test, give P(not D | +) and P(D | -), as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[2, 3, 1, 9703]]}"} {"task_id": "bi-006", "category": "information-theory", "prompt": "Give H(X), H(Y) and H(X, Y) in bits, as three rationals. Return one row of six integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[3, 2, 1, 1, 2, 1]]}"} {"task_id": "bi-007", "category": "information-theory", "prompt": "Give H(Y | X) and then H(X | Y) in bits, each computed as an average of conditional entropies rather than as a difference of entropies. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 2, 1, 1]]}"} {"task_id": "bi-008", "category": "information-theory", "prompt": "Give I(X; Y) in bits. Return one row of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 2]]}"} {"task_id": "bi-009", "category": "information-theory", "prompt": "Give KL(P || Q) and KL(Q || P) in bits, in that order, as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[11, 16, 5, 8]]}"} {"task_id": "bi-010", "category": "information-theory", "prompt": "Give H(P) and H(Q) in bits, as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[15, 8, 9, 4]]}"} {"task_id": "bi-011", "category": "information-theory", "prompt": "Give the two cross entropies H(P, Q) = -sum_w P(w) log2 Q(w) and H(Q, P) = -sum_w Q(w) log2 P(w), in that order, as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[41, 16, 23, 8]]}"} {"task_id": "bi-012", "category": "regression", "prompt": "Give X^T X for the design matrix XR. Return two rows of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[5, 15], [15, 55]]}"} {"task_id": "bi-013", "category": "regression", "prompt": "Give X^T y for XR and yr. Return one row of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[20, 69]]}"} {"task_id": "bi-014", "category": "regression", "prompt": "Solve the normal equations for XR and yr. Give the two weights as rationals, intercept first. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[13, 10, 9, 10]]}"} {"task_id": "bi-015", "category": "regression", "prompt": "Give the five residuals y - Xw of the ordinary least-squares fit, as rationals, in order. Return one row of ten integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[-1, 5, -1, 10, 1, 1, -9, 10, 1, 5]]}"} {"task_id": "bi-016", "category": "regression", "prompt": "Give the ridge weights for lambda = 5, solving (X^T X + lambda I) w = X^T y, as two rationals, intercept first. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[11, 25, 26, 25]]}"} {"task_id": "bi-017", "category": "regression", "prompt": "Give the sum of squared residuals of the ordinary least-squares fit, as one rational. Return one row of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[19, 10]]}"} {"task_id": "bi-018", "category": "regression", "prompt": "Fit the quadratic through XQ and yq exactly. Give the three coefficients as rationals, constant term first. Return one row of six integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[2, 1, -2, 1, 1, 1]]}"} {"task_id": "bi-019", "category": "classification", "prompt": "Give the smoothed class priors p(A) and p(B), as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[7, 12, 5, 12]]}"} {"task_id": "bi-020", "category": "classification", "prompt": "Give the smoothed likelihoods p(f=1 | A) for the three features, then the same for B. Return two rows of six integers each.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[5, 8, 1, 4, 7, 8], [1, 3, 2, 3, 1, 2]]}"} {"task_id": "bi-021", "category": "classification", "prompt": "For the query x = (1, 0, 1), give the unnormalised joint scores p(A) p(x | A) and p(B) p(x | B), as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[245, 1024, 5, 216]]}"} {"task_id": "bi-022", "category": "classification", "prompt": "For the query x = (1, 0, 1), give the posterior p(A | x) and p(B | x), as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1323, 1451, 128, 1451]]}"} {"task_id": "bi-023", "category": "classification", "prompt": "For the query x = (1, 0, 1), give 0 if naive Bayes predicts class A and 1 if it predicts class B, then give the posterior odds p(A | x) / p(B | x) as a rational. Return one row of three integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[0, 1323, 128]]}"} {"task_id": "bi-024", "category": "bayesian-inference", "prompt": "Give the parameters of the Beta posterior after the observed successes and failures, as two integers a and b. Return one row of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[9, 6]]}"} {"task_id": "bi-025", "category": "bayesian-inference", "prompt": "Give the prior mean of the Bernoulli parameter, then its posterior mean, then the posterior variance ab / ((a+b)^2 (a+b+1)), as three rationals. Return one row of six integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[2, 5, 3, 5, 3, 200]]}"} {"task_id": "bi-026", "category": "bayesian-inference", "prompt": "Give the maximum a posteriori estimate of the Bernoulli parameter, that is (a-1)/(a+b-2) for the posterior Beta(a, b), and then the maximum likelihood estimate from the data alone. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[8, 13, 7, 10]]}"} {"task_id": "bi-027", "category": "bayesian-inference", "prompt": "Give the three parameters of the Dirichlet posterior as integers, then the posterior predictive distribution over the three outcomes as three rationals. Return one row of three integers and then one row of six integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[5, 2, 5], [5, 12, 1, 6, 5, 12]]}"} {"task_id": "bi-028", "category": "bayesian-inference", "prompt": "For the Gaussian with known variance, give the posterior precision and the posterior variance, as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[7, 4, 4, 7]]}"} {"task_id": "bi-029", "category": "bayesian-inference", "prompt": "For the Gaussian with known variance, give the posterior mean as a rational. Return one row of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[22, 7]]}"} {"task_id": "bi-030", "category": "mixtures-em", "prompt": "For each of the three data points in order, give the two responsibilities as rationals. Return three rows of four integers each.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 19, 18, 19], [9, 11, 2, 11], [1, 163, 162, 163]]}"} {"task_id": "bi-031", "category": "mixtures-em", "prompt": "Give the likelihood of x1 = (1,1,0,1) under component 1, then under component 2, as two rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[3, 256, 27, 256]]}"} {"task_id": "bi-032", "category": "mixtures-em", "prompt": "Give the mixture probability p(x) for each of the three data points in order, as three rationals. Return one row of six integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[19, 256, 11, 256, 163, 768]]}"} {"task_id": "bi-033", "category": "mixtures-em", "prompt": "Perform one M-step from those responsibilities. Give the two updated mixing coefficients as rationals. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[29875, 102201, 72326, 102201]]}"} {"task_id": "bi-034", "category": "mixtures-em", "prompt": "Perform one M-step from those responsibilities. Give the two updated component parameters as rationals, where each is the responsibility-weighted fraction of bits equal to 1. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[8522, 29875, 29806, 36163]]}"} {"task_id": "bi-035", "category": "mixtures-em", "prompt": "Run one k-means iteration from the given centroids. Give the six cluster assignments as 0 or 1, in point order. Return one row of six integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[0, 0, 0, 1, 1, 1]]}"} {"task_id": "bi-036", "category": "mixtures-em", "prompt": "Run one k-means iteration from the given centroids and give the two updated centroids, each as two rationals. Return two rows of four integers each.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 1, 4, 3], [28, 3, 8, 1]]}"} {"task_id": "bi-037", "category": "mixtures-em", "prompt": "Give the k-means distortion J after one iteration, that is the sum of squared distances from each point to its updated centroid under the updated assignment, as one rational. Return one row of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[40, 3]]}"} {"task_id": "bi-038", "category": "graphical-models", "prompt": "For the directed graph, answer each of these d-separation questions with 1 for d-separated and 0 for not, in order: A ⊥ B | {}; A ⊥ B | {C}; A ⊥ B | {D}; A ⊥ B | {F}. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 0, 0, 0]]}"} {"task_id": "bi-039", "category": "graphical-models", "prompt": "Same question for: A ⊥ E | {C, B}; D ⊥ E | {C}; D ⊥ E | {}; A ⊥ F | {E}. Return one row of four integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[1, 1, 0, 1]]}"} {"task_id": "bi-040", "category": "graphical-models", "prompt": "Give the number of nodes, the number of directed edges, and the number of colliders — nodes with two or more parents. Return one row of three integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[6, 6, 2]]}"} {"task_id": "bi-041", "category": "graphical-models", "prompt": "Give the descendants of C and then the descendants of B, each as a count. Then give the size of the Markov blanket of C, that is its parents, its children and its children's other parents. Return one row of three integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[3, 4, 4]]}"} {"task_id": "bi-042", "category": "graphical-models", "prompt": "Take every variable to be binary. Give the number of free parameters of the factorised distribution — the sum over nodes of 2 raised to the number of parents — and then the number of free parameters of an unrestricted joint over the same variables. Return one row of two integers.", "api_description": "The tasks refer to these fixed objects. Every number here is exact.\n\nJOINT DISTRIBUTION P(X, Y), with X in {0,1,2} and Y in {0,1}:\n\n Y=0 Y=1\n X=0 1/4 1/4\n X=1 1/4 0\n X=2 0 1/4\n\nEvery cell, every marginal and every conditional of this table is a power of two. That is on\npurpose: it is what makes each entropy below an exact rational rather than an irrational\nnumber. Use the convention 0 * log(0) = 0.\n\nTWO DISTRIBUTIONS over W in {0,1,2,3,4}:\n P = (1/2, 1/4, 1/8, 1/16, 1/16)\n Q = (1/8, 1/4, 1/4, 1/4, 1/8)\n\nALL LOGARITHMS ARE BASE 2 and every argument you will need is a power of two, so every\nlogarithm is an integer. Do not use math.log.\n\nA DIAGNOSTIC TEST: P(D) = 1/100, P(+ | D) = 99/100, P(+ | not D) = 2/100.\n\nLINEAR REGRESSION: design matrix XR (5x2, first column is the intercept) and targets yr\n\n XR = [[1,1],[1,2],[1,3],[1,4],[1,5]] yr = [2, 3, 5, 4, 6]\n\n Ridge penalty lambda = 5, and the intercept IS penalised (plain (X^T X + lambda I)).\n\nQUADRATIC FIT: XQ = [[1,1,1],[1,2,4],[1,3,9]] with yq = [1, 2, 5]\n\nNAIVE BAYES with three binary features and Laplace smoothing alpha = 1:\n class A occurs 6 times, and among those 6 the features are 1 in 4, 1 and 6 cases\n class B occurs 4 times, and among those 4 the features are 1 in 1, 3 and 2 cases\n Smoothing a binary feature means p(f=1 | c) = (ones + 1) / (class count + 2), and the\n class prior is smoothed the same way: p(c) = (class count + 1) / (10 + 2).\n The query point is x = (1, 0, 1).\n\nBERNOULLI MIXTURE over four iid bits, two components:\n mixing coefficients pi = (1/3, 2/3)\n component parameters p = (1/4, 3/4) -- probability that a bit is 1\n data: x1 = (1,1,0,1), x2 = (0,0,1,0), x3 = (1,1,1,1)\n\nK-MEANS on the six integer points\n (0,0), (1,0), (0,1), (8,8), (9,8), (8,9)\n initial centroids (0,0) and (9,9), squared Euclidean distance, ties to the lower index.\n\nCONJUGATE PRIORS:\n Beta(2, 3) prior, then 7 successes and 3 failures.\n Dirichlet prior alpha = (1, 2, 3), then counts (4, 0, 2).\n Gaussian with KNOWN variance sigma^2 = 4, prior mean 1 and prior variance 2, data\n (2, 4, 3, 5, 6).\n\nDIRECTED GRAPH (given as parents):\n A: - B: - C: A, B D: C E: C, B F: E\n\nCONVENTIONS FOR ANSWERS\n * Integer answers are plain Python ints.\n * Every rational is a two-element pair [numerator, denominator] in lowest terms with a\n positive denominator, so 3 is [3, 1] wherever a rational is requested.\n * A row of rationals is FLATTENED: the pair (1/2, 3) is the row [1, 2, 3, 1].\n * A yes/no answer is 1 for yes and 0 for no.\n\nAvailable imports: fractions (Fraction), itertools. Nothing else is needed — and in\nparticular numpy is NOT available, because its floating point would defeat the purpose.\nUse fractions.Fraction throughout and never float division.\n\nPut the requested values in `result` as a list of rows of plain integers.\n", "expected_output": "{\"rows\": [[14, 63]]}"}