{"id":6913,"date":"2026-08-30T18:40:45","date_gmt":"2026-08-30T23:40:45","guid":{"rendered":"https:\/\/ykim.synology.me\/wordpress\/design-of-experiments-6913\/"},"modified":"2026-11-26T22:36:15","modified_gmt":"2026-11-27T04:36:15","slug":"design-of-experiments","status":"publish","type":"post","link":"https:\/\/ykim.synology.me\/wordpress\/design-of-experiments-6913\/","title":{"rendered":"Design of Experiments"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/yBarn1\/Images\/main\/shipping\/plywood-shipping-crate-hinged.jpg\" alt=\"\" style=\"width:auto;height:500px\"\/><\/figure>\n\n\n<style>.kt-tabs-id6913_34a217-d3 > .kt-tabs-content-wrap > .wp-block-kadence-tab{border-top:3px solid #0a6689;border-right:0px solid #0a6689;border-bottom:0px solid #0a6689;border-left:0px solid #0a6689;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;padding-top:var(--global-kb-spacing-sm, 1.5rem);padding-right:var(--global-kb-spacing-sm, 1.5rem);padding-bottom:var(--global-kb-spacing-sm, 1.5rem);padding-left:var(--global-kb-spacing-sm, 1.5rem);background:var(--global-palette9, #ffffff);}.wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-title-list li{margin-top:0px;margin-right:8px;margin-bottom:0px;margin-left:0px;}.wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-title-list li:last-child{margin-right:0px;}.wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-title-list li .kt-tab-title, .wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-content-wrap > .kt-tabs-accordion-title .kt-tab-title{line-height:1.4em;font-weight:regular;font-style:normal;border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:0px;border-bottom-left-radius:0px;padding-top:8px;padding-right:20px;padding-bottom:8px;padding-left:20px;border-color:var(--global-palette7, #eeeeee);color:var(--global-palette4, #2D3748);background:var(--global-palette7, #eeeeee);}.wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-content-wrap > .kt-tabs-accordion-title .kt-tab-title{margin-top:0px;margin-right:8px;margin-bottom:0px;margin-left:0px;}.wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-title-list li .kt-tab-title:hover, .wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-content-wrap > .kt-tabs-accordion-title .kt-tab-title:hover{border-color:var(--global-palette7, #eeeeee);color:var(--global-palette3, #1A202C);background:var(--global-palette8, #F7FAFC);}.wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-title-list li.kt-tab-title-active .kt-tab-title, .wp-block-kadence-tabs .kt-tabs-id6913_34a217-d3 > .kt-tabs-content-wrap > .kt-tabs-accordion-title.kt-tab-title-active .kt-tab-title{border-color:var(--global-palette7, #eeeeee);color:#ffffff;background:#0a6689;}@media all and (max-width: 1024px){.kt-tabs-id6913_34a217-d3 > .kt-tabs-content-wrap > .wp-block-kadence-tab{border-top:3px solid #0a6689;border-right:0px solid #0a6689;border-bottom:0px solid #0a6689;border-left:0px solid #0a6689;}}@media all and (max-width: 767px){.kt-tabs-id6913_34a217-d3 > .kt-tabs-content-wrap > .wp-block-kadence-tab{border-top:3px solid #0a6689;border-right:0px solid #0a6689;border-bottom:0px solid #0a6689;border-left:0px solid #0a6689;}}<\/style>\n<div class=\"wp-block-kadence-tabs alignnone\"><div class=\"kt-tabs-wrap kt-tabs-id6913_34a217-d3 kt-tabs-has-2-tabs kt-active-tab-2 kt-tabs-layout-tabs kt-tabs-tablet-layout-inherit kt-tabs-mobile-layout-inherit kt-tab-alignment-left \"><ul class=\"kt-tabs-title-list\"><li id=\"tab-english\" class=\"kt-title-item kt-title-item-1 kt-tabs-svg-show-always kt-tabs-icon-side-right kt-tab-title-inactive\"><a href=\"#tab-english\" data-tab=\"1\" class=\"kt-tab-title kt-tab-title-1 \"><span class=\"kt-title-text\">English<\/span><\/a><\/li><li id=\"tab-korean\" class=\"kt-title-item kt-title-item-2 kt-tabs-svg-show-always kt-tabs-icon-side-right kt-tab-title-active\"><a href=\"#tab-korean\" data-tab=\"2\" class=\"kt-tab-title kt-tab-title-2 \"><span class=\"kt-title-text\">Korean<\/span><\/a><\/li><\/ul><div class=\"kt-tabs-content-wrap\">\n<div class=\"wp-block-kadence-tab kt-tab-inner-content kt-inner-tab-1 kt-inner-tab6913_38dcfb-30\"><div class=\"kt-tab-inner-content-inner\"><p><div class=\"github-readme-container markdown-body\"><div id=\"file\" class=\"md\" data-path=\"DOE\/design-of-experiments.md\"><article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><div class=\"markdown-heading\" dir=\"auto\"><h1 class=\"heading-element\" dir=\"auto\">Design of Experiments<\/h1><a id=\"user-content-design-of-experiments\" class=\"anchor\" aria-label=\"Permalink: Design of Experiments\" href=\"#design-of-experiments\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Version 12 | Created: 2026-08-30 | Updated: 2026-11-07 13:46 UTC<\/p>\n<ul dir=\"auto\">\n<li><a href=\"#1-purpose\">1. Purpose<\/a><\/li>\n<li><a href=\"#2-summary\">2. Summary<\/a><\/li>\n<li><a href=\"#3-taxonomy-and-its-hierarchy\">3. Taxonomy and its Hierarchy<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#31-comparison\">3.1 Comparison<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#4-principle\">4. Principle<\/a><\/li>\n<li><a href=\"#5-full-factorial-designs\">5. Full Factorial Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#51-multilevel-designs\">5.1 Multilevel Designs<\/a><\/li>\n<li><a href=\"#52-two-level-designs\">5.2 Two-Level Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#6-fractional-factorial-designs\">6. Fractional Factorial Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#61-confounding-and-resolution\">6.1 Confounding and Resolution<\/a><\/li>\n<li><a href=\"#62-plackett-burman-designs\">6.2 Plackett-Burman Designs<\/a><\/li>\n<li><a href=\"#63-general-fractional-designs\">6.3 General Fractional Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#7-response-surface-designs\">7. Response Surface Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#71-quadratic-model\">7.1 Quadratic Model<\/a><\/li>\n<li><a href=\"#72-central-composite-designs\">7.2 Central Composite Designs<\/a><\/li>\n<li><a href=\"#73-box-behnken-designs\">7.3 Box-Behnken Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#8-d-optimal-designs\">8. D-Optimal Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#81-d-efficiency\">8.1 D-Efficiency<\/a><\/li>\n<li><a href=\"#82-generating-d-optimal-designs\">8.2 Generating D-Optimal Designs<\/a><\/li>\n<li><a href=\"#83-augmenting-d-optimal-designs\">8.3 Augmenting D-Optimal Designs<\/a><\/li>\n<li><a href=\"#84-specifying-fixed-covariate-factors\">8.4 Specifying Fixed Covariate Factors<\/a><\/li>\n<li><a href=\"#85-specifying-categorical-factors\">8.5 Specifying Categorical Factors<\/a><\/li>\n<li><a href=\"#86-specifying-candidate-sets\">8.6 Specifying Candidate Sets<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#references\">References<\/a><\/li>\n<li><a href=\"#appendix-a-terminology\">Appendix A. Terminology<\/a><\/li>\n<li><a href=\"#appendix-b-python-implementation\">Appendix B. Python Implementation<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#b1-common-header\">B.1 Common Header<\/a><\/li>\n<li><a href=\"#b2-full-factorial-designs\">B.2 Full Factorial Designs<\/a><\/li>\n<li><a href=\"#b3-fractional-factorial-designs\">B.3 Fractional Factorial Designs<\/a><\/li>\n<li><a href=\"#b4-response-surface-designs\">B.4 Response Surface Designs<\/a><\/li>\n<li><a href=\"#b5-d-optimal-designs\">B.5 D-Optimal Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">1. Purpose<\/h2><a id=\"user-content-1-purpose\" class=\"anchor\" aria-label=\"Permalink: 1. Purpose\" href=\"#1-purpose\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li><strong>Problem Statement<\/strong>: In passively collected data several factors explain the same change in the response, so a model fitted to that data cannot separate the effect of each factor.<\/li>\n<li><strong>Goal<\/strong>: Build a DOE User's Guide. A reader who finishes it can pick the design that fits the target model, the run budget and the constraints on the factor space, and can state its assumptions and limits.<\/li>\n<li><strong>Non-Goal<\/strong>: The analysis after the experiment (ANOVA, model fitting and testing) and the use of any particular software are out of scope.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">2. Summary<\/h2><a id=\"user-content-2-summary\" class=\"anchor\" aria-label=\"Permalink: 2. Summary\" href=\"#2-summary\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Designing an experiment is choosing the rows of the design matrix so that the covariance of the coefficient estimates is small within a run budget.\nThe target model picks the design: a full factorial for every effect, a fractional factorial for screening many factors,\na response surface design for optimisation with curvature, and a D-optimal design for irregular budgets, constraints and covariates.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">3. Taxonomy and its Hierarchy<\/h2><a id=\"user-content-3-taxonomy-and-its-hierarchy\" class=\"anchor\" aria-label=\"Permalink: 3. Taxonomy and its Hierarchy\" href=\"#3-taxonomy-and-its-hierarchy\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Design families differ in what they assume about the model, and the stronger the assumption the fewer runs they need. This\ndocument follows the four families of the MathWorks Statistics and Machine Learning Toolbox [<a href=\"#ref-1\">1<\/a>].<\/p>\n<p dir=\"auto\">The five axes that separate designs are shown in <a href=\"#fig-1\">Fig 1<\/a>.<\/p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Axis               Values\n-----------------  ----------------------------------------------------------------------\nTarget model       all effects | main effects + some interactions | main effects only\n                   | full quadratic | any stated model\nLevels per factor  2 | 3 | any\nRun count          product of levels | power of 2 | multiple of 4 | set by geometry | any\nFactor space       regular cube | constrained region\nFactor type        continuous and set | categorical | recorded covariate\"><pre lang=\"text\" class=\"notranslate\"><code>Axis               Values\n-----------------  ----------------------------------------------------------------------\nTarget model       all effects | main effects + some interactions | main effects only\n                   | full quadratic | any stated model\nLevels per factor  2 | 3 | any\nRun count          product of levels | power of 2 | multiple of 4 | set by geometry | any\nFactor space       regular cube | constrained region\nFactor type        continuous and set | categorical | recorded covariate\n<\/code><\/pre><\/div>\n<p dir=\"auto\"><a id=\"user-content-fig-1\"><\/a>\nFig 1. Axes of the design taxonomy<\/p>\n<p dir=\"auto\">The five axes are independent. With the same full quadratic target model, a cubic factor space calls for a response\nsurface design and a constrained region calls for a D-optimal design.<\/p>\n<p dir=\"auto\">What each design assumes about the model, and what it pays for that, follows the hierarchy in <a href=\"#fig-2\">Fig 2<\/a>.<\/p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Family \/ design          Assumes                              Gives up\n-----------------------  -----------------------------------  ---------------------------------------\nFull factorial           nothing about the model              small run count: N1 x ... x Nk runs\n+- General fractional    high-order interactions are small    separation of confounded effects\n   +- Plackett-Burman    only main effects matter             every interaction (resolution III)\nResponse surface         response is at most quadratic        terms above second order\n+- Central composite     settings at +\/-alpha are reachable   fewest runs: embeds a full 2^k\n+- Box-Behnken           three or more factors                corner runs and an embedded factorial\nD-optimal                the stated model is correct          regular geometry and orthogonality\"><pre lang=\"text\" class=\"notranslate\"><code>Family \/ design          Assumes                              Gives up\n-----------------------  -----------------------------------  ---------------------------------------\nFull factorial           nothing about the model              small run count: N1 x ... x Nk runs\n+- General fractional    high-order interactions are small    separation of confounded effects\n   +- Plackett-Burman    only main effects matter             every interaction (resolution III)\nResponse surface         response is at most quadratic        terms above second order\n+- Central composite     settings at +\/-alpha are reachable   fewest runs: embeds a full 2^k\n+- Box-Behnken           three or more factors                corner runs and an embedded factorial\nD-optimal                the stated model is correct          regular geometry and orthogonality\n<\/code><\/pre><\/div>\n<p dir=\"auto\"><a id=\"user-content-fig-2\"><\/a>\nFig 2. Hierarchy of design families<\/p>\n<p dir=\"auto\">Each step down from the full factorial adds an assumption about the model and removes runs. A general fractional design\nsaves runs by treating high-order interactions as small, and a Plackett-Burman design by treating every interaction as\nsmall. The response surface family caps the model at second order and adds a third level to estimate curvature. A\nD-optimal design chooses its runs for one stated model, so it needs neither a cubic factor space nor a fixed run count.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.1 Comparison<\/h3><a id=\"user-content-31-comparison\" class=\"anchor\" aria-label=\"Permalink: 3.1 Comparison\" href=\"#31-comparison\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Table 1 gives the criteria for choosing a design.<\/p>\n<p dir=\"auto\">Table 1. Comparison of designs<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Design<\/th>\n<th align=\"center\">Model aimed at<\/th>\n<th align=\"center\">Run count<\/th>\n<th align=\"center\">Use when<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">Full factorial<\/td>\n<td align=\"center\">All effects and interactions<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$N_1 \\times \\cdots \\times N_k$<\/math-renderer><\/td>\n<td align=\"center\">Few factors, every combination affordable<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">General fractional<\/td>\n<td align=\"center\">Main effects, some interactions<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^{b}$<\/math-renderer><\/td>\n<td align=\"center\">Screening many factors with a chosen resolution<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Plackett-Burman<\/td>\n<td align=\"center\">Main effects<\/td>\n<td align=\"center\">Smallest multiple of 4 above <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$k$<\/math-renderer>\n<\/td>\n<td align=\"center\">Main-effect screening needing a run count between powers of 2<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Central composite<\/td>\n<td align=\"center\">Full quadratic model<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^k + 2k + n_c$<\/math-renderer><\/td>\n<td align=\"center\">Optimisation near a known operating point<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Box-Behnken<\/td>\n<td align=\"center\">Full quadratic model<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$4\\binom{k}{2} + n_c$<\/math-renderer><\/td>\n<td align=\"center\">Optimisation of a process that cannot set every factor to an extreme at once<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">D-optimal<\/td>\n<td align=\"center\">Any stated model<\/td>\n<td align=\"center\">Set to the budget<\/td>\n<td align=\"center\">Irregular budgets, constraints, covariates or categorical factors<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$k$<\/math-renderer> is the number of factors, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$b$<\/math-renderer> the number of basic factors, and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$n_c$<\/math-renderer> the number of centre runs.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">4. Principle<\/h2><a id=\"user-content-4-principle\" class=\"anchor\" aria-label=\"Permalink: 4. Principle\" href=\"#4-principle\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The design fixes the precision of the coefficient estimates before any response is measured. Write <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\mathbf{y}$<\/math-renderer> for the\nvector of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$n$<\/math-renderer> measured responses, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\mathbf{X}$<\/math-renderer> for the model matrix built from the factor settings, and\n<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\boldsymbol{\\beta}$<\/math-renderer> for the coefficients; the least squares estimate and its covariance are given by equation (1).<\/p>\n<math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$$\\hat{\\boldsymbol{\\beta}} = \\left( \\mathbf{X}^{\\top}\\mathbf{X} \\right)^{-1} \\mathbf{X}^{\\top}\\mathbf{y}, \\qquad \\mathrm{Cov}\\left[ \\hat{\\boldsymbol{\\beta}} \\right] = \\sigma^{2} \\left( \\mathbf{X}^{\\top}\\mathbf{X} \\right)^{-1} \\hspace{19em} (1)$$<\/math-renderer>\n<p dir=\"auto\">The covariance in equation (1) contains no <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\mathbf{y}$<\/math-renderer>, so once <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\sigma^2$<\/math-renderer> is given it follows from the design alone. A\ndesigned experiment sets the factor values deliberately, so the factors move independently of each other and the effect\nof each one on the response is estimated apart. The design families differ in which model they aim at and in how they\nspend the run budget (Table 1).<\/p>\n<p dir=\"auto\">Two-level factors are coded as <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$-1$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$+1$<\/math-renderer> throughout, and continuous factors are scaled so that their working range is\n<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$[-1, 1]$<\/math-renderer>. Terms used without definition are in <a href=\"#appendix-a-terminology\">Appendix A<\/a>, and the Python implementation and\noutput of every design are in <a href=\"#appendix-b-python-implementation\">Appendix B<\/a>.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">5. Full Factorial Designs<\/h2><a id=\"user-content-5-full-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: 5. Full Factorial Designs\" href=\"#5-full-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A full factorial design measures the response at every combination of the factor levels and estimates every effect and\ninteraction the factors can produce. With <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$N_1, \\ldots, N_k$<\/math-renderer> levels it needs <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$N_1 \\times \\cdots \\times N_k$<\/math-renderer> runs, one per\ntreatment.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Assumption<\/strong>: Few factors and levels, so a run at every combination is affordable.<\/li>\n<li>\n<strong>Settings<\/strong>: The level count <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$N_i$<\/math-renderer> of each factor.<\/li>\n<li>\n<strong>Breaks when<\/strong>: More factors multiply the run count by their level counts; even at two levels <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^k$<\/math-renderer> exceeds the budget.<\/li>\n<li>\n<strong>Used for<\/strong>: Experiments with few factors, and the starting point of the fractional and response surface families.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">5.1 Multilevel Designs<\/h3><a id=\"user-content-51-multilevel-designs\" class=\"anchor\" aria-label=\"Permalink: 5.1 Multilevel Designs\" href=\"#51-multilevel-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Factors need not share a level count. The design is the cartesian product of the level sets, listed so that the first\ncolumn varies fastest. One two-level factor and one three-level factor give six runs\n(<a href=\"#b2-full-factorial-designs\">Appendix B.2<\/a>).<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">5.2 Two-Level Designs<\/h3><a id=\"user-content-52-two-level-designs\" class=\"anchor\" aria-label=\"Permalink: 5.2 Two-Level Designs\" href=\"#52-two-level-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">When every factor has two levels the design has <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^k$<\/math-renderer> runs. The columns are orthogonal and balanced, so every effect is\nestimated independently of the others and with the smallest variance the run count allows. The fractional and response\nsurface families start from this design.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">6. Fractional Factorial Designs<\/h2><a id=\"user-content-6-fractional-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: 6. Fractional Factorial Designs\" href=\"#6-fractional-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A fractional factorial design measures a subset of the treatments, chosen so that the effects believed to matter stay\nestimable. Most of the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^k$<\/math-renderer> runs of a full factorial go to high-order interactions that are rarely large.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">6.1 Confounding and Resolution<\/h3><a id=\"user-content-61-confounding-and-resolution\" class=\"anchor\" aria-label=\"Permalink: 6.1 Confounding and Resolution\" href=\"#61-confounding-and-resolution\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The price of fewer runs is confounding. Each retained column carries the sum of several effects, and no experiment run on\nthat design can tell them apart. The resolution names the degree of confounding and is the length of the shortest word in\nthe defining relation.<\/p>\n<p dir=\"auto\">Table 2. Design resolution [<a href=\"#ref-2\">2<\/a>]<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Resolution<\/th>\n<th align=\"center\">Main effects confounded with<\/th>\n<th align=\"center\">Two-way interactions confounded with<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">III<\/td>\n<td align=\"center\">Two-way interactions<\/td>\n<td align=\"center\">Each other<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">IV<\/td>\n<td align=\"center\">Three-way interactions<\/td>\n<td align=\"center\">Each other<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">V<\/td>\n<td align=\"center\">Four-way interactions<\/td>\n<td align=\"center\">Three-way interactions<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">Under resolution III the main effects hold only if two-way interactions are small; resolution IV estimates the main\neffects apart from two-way interactions; resolution V estimates both the main effects and the two-way interactions apart\nfrom every other effect of second order or lower.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">6.2 Plackett-Burman Designs<\/h3><a id=\"user-content-62-plackett-burman-designs\" class=\"anchor\" aria-label=\"Permalink: 6.2 Plackett-Burman Designs\" href=\"#62-plackett-burman-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">When only main effects are considered significant, a Plackett-Burman design gives a resolution III design whose run count\nis a multiple of 4 rather than a power of 2, and so fills the gaps between the two-level factorials [<a href=\"#ref-3\">3<\/a>]. Eleven\nfactors are screened in 12 runs instead of 16.<\/p>\n<p dir=\"auto\">The design is built from a Hadamard matrix. Where the run count is a power of 2 the columns of the Hadamard matrix are\nused directly; otherwise a final row of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$-1$<\/math-renderer> is placed under the circulant of a known generator row. The 11 columns of the\n12-run design are mutually orthogonal (<a href=\"#b3-fractional-factorial-designs\">Appendix B.3<\/a>).<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Assumption<\/strong>: Interactions are negligible and only main effects are significant.<\/li>\n<li>\n<strong>Settings<\/strong>: The number of factors <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$k$<\/math-renderer>. The run count is the smallest multiple of 4 above <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$k$<\/math-renderer>, and needs a generator row when it is not a power of 2.<\/li>\n<li>\n<strong>Breaks when<\/strong>: A large two-way interaction is confounded with a main effect, so the main-effect estimate carries that interaction.<\/li>\n<li>\n<strong>Used for<\/strong>: Screening many factors.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">6.3 General Fractional Designs<\/h3><a id=\"user-content-63-general-fractional-designs\" class=\"anchor\" aria-label=\"Permalink: 6.3 General Fractional Designs\" href=\"#63-general-fractional-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A general fractional design starts from a full factorial in a set of basic factors and defines the remaining factors as\nproducts of them.<\/p>\n<blockquote>\n<p dir=\"auto\"><strong>Definition: Generator<\/strong><br>\nWhen a factor is defined as a product of basic factors, that product is the generator of the factor.<\/p>\n<\/blockquote>\n<p dir=\"auto\">The generators fix both the design and its confounding. The generators <code>a b c abc<\/code> handle four factors in eight runs, half of the sixteen a full factorial needs.<\/p>\n<p dir=\"auto\">The defining relation is generated by the words that the generators imply, and the resolution is the length of the\nshortest word in the subgroup those words generate. Table 3 gives the resolution of four generator sets.<\/p>\n<p dir=\"auto\">Table 3. Resolution of four generator sets<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Generators<\/th>\n<th align=\"center\">Runs<\/th>\n<th align=\"center\">Resolution<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">a b ab<\/td>\n<td align=\"center\">4<\/td>\n<td align=\"center\">III<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">a b c ab<\/td>\n<td align=\"center\">8<\/td>\n<td align=\"center\">III<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">a b c abc<\/td>\n<td align=\"center\">8<\/td>\n<td align=\"center\">IV<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">a b c d abcd<\/td>\n<td align=\"center\">16<\/td>\n<td align=\"center\">V<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">The two eight-run designs cost the same and differ only in the generator, yet <code>a b c ab<\/code> confounds main effects with\ntwo-way interactions and <code>a b c abc<\/code> does not. At a fixed run count the generator sets the resolution.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Assumption<\/strong>: The interactions that the resolution confounds are small (Table 2).<\/li>\n<li>\n<strong>Settings<\/strong>: The number of basic factors <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$b$<\/math-renderer> (run count <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^{b}$<\/math-renderer>) and a generator for each added factor.<\/li>\n<li>\n<strong>Breaks when<\/strong>: A large confounded interaction makes the column estimate a sum of effects that cannot be told apart.<\/li>\n<li>\n<strong>Used for<\/strong>: Screening many factors when the run count stays a power of 2 and the resolution must be chosen.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">7. Response Surface Designs<\/h2><a id=\"user-content-7-response-surface-designs\" class=\"anchor\" aria-label=\"Permalink: 7. Response Surface Designs\" href=\"#7-response-surface-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A response surface design adds a third level to each factor to fit a full quadratic model, which carries curvature. Once\nthe factors that matter are known and the goal is optimisation, the model needs curvature: an optimum is a stationary\npoint, and a first-order model has none.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">7.1 Quadratic Model<\/h3><a id=\"user-content-71-quadratic-model\" class=\"anchor\" aria-label=\"Permalink: 7.1 Quadratic Model\" href=\"#71-quadratic-model\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The full quadratic model in <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$k$<\/math-renderer> factors is equation (2) and has <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$(k+1)(k+2)\/2$<\/math-renderer> coefficients.<\/p>\n<math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$$y = \\beta_0 + \\sum_{i=1}^{k} \\beta_i x_i + \\sum_{i \\lt j} \\beta_{ij} x_i x_j + \\sum_{i=1}^{k} \\beta_{ii} x_i^{2} + \\varepsilon \\hspace{19em} (2)$$<\/math-renderer>\n<p dir=\"auto\">A two-level design cannot fit equation (2). The square term <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$x_i^2$<\/math-renderer> takes the same value 1 at <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$-1$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$+1$<\/math-renderer>. The two\ndesigns below add the third level in different ways.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">7.2 Central Composite Designs<\/h3><a id=\"user-content-72-central-composite-designs\" class=\"anchor\" aria-label=\"Permalink: 7.2 Central Composite Designs\" href=\"#72-central-composite-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A central composite design consists of a two-level factorial at the corners of a cube, star points on the factor axes at\na distance <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\alpha$<\/math-renderer> from the centre, and one or more centre runs. Choosing <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\alpha = (2^k)^{1\/4}$<\/math-renderer> makes the design\nrotatable, so the prediction variance depends on the distance from the centre and not on the direction.<\/p>\n<p dir=\"auto\">The three variants differ in where the star points sit.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Circumscribed<\/strong>: Star points outside the cube at <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\pm\\alpha$<\/math-renderer>, which needs factor settings beyond the two-level range.<\/li>\n<li>\n<strong>Faced<\/strong>: Star points on the faces of the cube at <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\alpha = 1$<\/math-renderer>.<\/li>\n<li>\n<strong>Inscribed<\/strong>: The circumscribed shape rescaled so that the star points, not the corners, sit at <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\pm 1$<\/math-renderer>.<\/li>\n<\/ul>\n<p dir=\"auto\">A circumscribed design in two factors with one centre run has nine runs, with the star points at <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\pm 1.4142$<\/math-renderer>\n(<a href=\"#b4-response-surface-designs\">Appendix B.4<\/a>).<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Assumption<\/strong>: Near the operating point the response is approximated by a full quadratic model, and there are two or more factors.<\/li>\n<li>\n<strong>Settings<\/strong>: <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\alpha$<\/math-renderer> (<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$(2^k)^{1\/4}$<\/math-renderer> for rotatable, 1 for faced), the variant, and the centre run count <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$n_c \\ge 1$<\/math-renderer>. The run count is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^k + 2k + n_c$<\/math-renderer>.<\/li>\n<li>\n<strong>Breaks when<\/strong>: The process cannot reach the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\pm\\alpha$<\/math-renderer> settings, which rules out the circumscribed design in favour of faced or inscribed.<\/li>\n<li>\n<strong>Used for<\/strong>: Optimisation near a known operating point.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">7.3 Box-Behnken Designs<\/h3><a id=\"user-content-73-box-behnken-designs\" class=\"anchor\" aria-label=\"Permalink: 7.3 Box-Behnken Designs\" href=\"#73-box-behnken-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A Box-Behnken design fits the full quadratic model without ever setting two factors to an extreme at the same time\n[<a href=\"#ref-4\">4<\/a>]. It puts a two-level factorial in each pair of factors with the rest held at the centre, so its points sit at\nthe midpoints of the edges of the design space and at the centre. The corners of the cube are left out, so no run\ncombines the extremes of every factor, and there is no embedded factorial design.<\/p>\n<p dir=\"auto\">Table 4. Run counts of the two response surface designs, three centre runs each<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Factors<\/th>\n<th align=\"center\">Quadratic terms<\/th>\n<th align=\"center\">Box-Behnken<\/th>\n<th align=\"center\">Central composite<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">3<\/td>\n<td align=\"center\">10<\/td>\n<td align=\"center\">15<\/td>\n<td align=\"center\">17<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">4<\/td>\n<td align=\"center\">15<\/td>\n<td align=\"center\">27<\/td>\n<td align=\"center\">27<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">5<\/td>\n<td align=\"center\">21<\/td>\n<td align=\"center\">43<\/td>\n<td align=\"center\">45<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">The pairwise construction reproduces the published Box-Behnken designs for three to five factors. Beyond five the\npublished designs use a balanced incomplete block design and are smaller than every pair taken in turn. The pairwise\nconstruction stays valid there but is no longer minimal.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Assumption<\/strong>: The response is approximated by a full quadratic model, and there are three or more factors.<\/li>\n<li>\n<strong>Settings<\/strong>: The centre run count <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$n_c$<\/math-renderer> (default 3 in the Appendix B implementation). The run count is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$4\\binom{k}{2} + n_c$<\/math-renderer>.<\/li>\n<li>\n<strong>Breaks when<\/strong>: Beyond five factors the pairwise construction does not give the minimum run count.<\/li>\n<li>\n<strong>Used for<\/strong>: Optimising a process that cannot set every factor to an extreme at once.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">8. D-Optimal Designs<\/h2><a id=\"user-content-8-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: 8. D-Optimal Designs\" href=\"#8-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A D-optimal design takes the model and the run budget as given and searches for the set of runs that minimises the\ncovariance of the coefficients by maximising the determinant of the information matrix <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\mathbf{X}^{\\top}\\mathbf{X}$<\/math-renderer>.\nThe cube of factor settings, the run count that is a power of 2 or a multiple of 4, and the factors free to move, all\npresumed by the families above, are not required by a D-optimal design.<\/p>\n<ul dir=\"auto\">\n<li><strong>Assumption<\/strong>: The stated model describes the response correctly. The design is optimal only for the coefficients of that model.<\/li>\n<li><strong>Settings<\/strong>: The model (linear, interaction, quadratic), the run count, the grid level count of continuous factors, the number of random starts, and the candidate set.<\/li>\n<li><strong>Breaks when<\/strong>: Fewer runs than model terms cannot estimate the model. With too few starts the search can stop at a design short of the optimum.<\/li>\n<li><strong>Used for<\/strong>: Irregular run budgets, augmentation of staged experiments, recorded covariates, categorical factors, and constrained factor spaces.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.1 D-Efficiency<\/h3><a id=\"user-content-81-d-efficiency\" class=\"anchor\" aria-label=\"Permalink: 8.1 D-Efficiency\" href=\"#81-d-efficiency\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">D-efficiency normalises the determinant of the information matrix so that designs of different sizes can be compared. In\nequation (3) <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$p$<\/math-renderer> is the number of model terms; D-efficiency is 1 for an orthogonal design and smaller otherwise.<\/p>\n<math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$$D = \\frac{\\left| \\mathbf{X}^{\\top}\\mathbf{X} \\right|^{1\/p}}{n} \\hspace{19em} (3)$$<\/math-renderer>\n<p dir=\"auto\">The two-level full factorial reaches a D-efficiency of 1 for the linear model. When an orthogonal design exists, a\nD-optimal search cannot find a better one.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.2 Generating D-Optimal Designs<\/h3><a id=\"user-content-82-generating-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: 8.2 Generating D-Optimal Designs\" href=\"#82-generating-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A D-optimal design comes from an iterative search. The coordinate-exchange algorithm starts from a random design and\nrepeats one move until nothing improves: take one factor of one run, try every value on a grid, and keep the best\n[<a href=\"#ref-5\">5<\/a>]. The result depends on where the search starts, so the search is repeated from several random starts and the\nbest design is kept.<\/p>\n<p dir=\"auto\">Twelve runs requested for a quadratic model in three factors give a design with D-efficiency 0.4498\n(<a href=\"#b5-d-optimal-designs\">Appendix B.5<\/a>). That is three runs fewer than the smallest Box-Behnken design of Table 4 and two\nabove the ten coefficients the model has.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.3 Augmenting D-Optimal Designs<\/h3><a id=\"user-content-83-augmenting-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: 8.3 Augmenting D-Optimal Designs\" href=\"#83-augmenting-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">An experiment often runs in stages, and the runs already performed cannot be chosen again. Augmentation holds the\nperformed runs fixed and searches only for the new ones, so the added runs fill what the existing design is missing. The\nsearch uses row exchange, which swaps whole runs against rows of a candidate set rather than single coordinates; when the\nruns are drawn from a fixed list, exchanging rows is the fitting move.<\/p>\n<p dir=\"auto\">The four corner runs alone cannot fit the six-term quadratic model. Two more runs make it estimable, and the search puts\nboth of them off the corners, where the existing design has nothing, at <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$(0, 1)$<\/math-renderer> and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$(-1, 0)$<\/math-renderer>.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.4 Specifying Fixed Covariate Factors<\/h3><a id=\"user-content-84-specifying-fixed-covariate-factors\" class=\"anchor\" aria-label=\"Permalink: 8.4 Specifying Fixed Covariate Factors\" href=\"#84-specifying-fixed-covariate-factors\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A covariate is a factor that the experimenter records rather than sets, such as ambient temperature, the operator on\nshift, or the age of a batch. Its values are known in advance for each run but cannot be chosen. The design problem is\nthen to choose the controlled factors given the covariate column, so that the model separates the controlled effects\nfrom the covariate effect.<\/p>\n<p dir=\"auto\">When the covariate drifts evenly from <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$-1$<\/math-renderer> to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$+1$<\/math-renderer> across eight runs, the search places a pattern balanced against that\ndrift in the two controlled columns, so neither controlled effect is confounded with the covariate.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.5 Specifying Categorical Factors<\/h3><a id=\"user-content-85-specifying-categorical-factors\" class=\"anchor\" aria-label=\"Permalink: 8.5 Specifying Categorical Factors\" href=\"#85-specifying-categorical-factors\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A categorical factor has no numeric scale, so its levels cannot be pushed towards <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\pm 1$<\/math-renderer>. A factor with <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$L$<\/math-renderer> levels enters\nthe model as <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$L - 1$<\/math-renderer> columns through effect coding, and the search runs on those columns.<\/p>\n<p dir=\"auto\">Three categorical factors at three levels each give 27 candidate treatments. Asked for nine runs, the search returns a\ndesign in which every level of every factor appears three times and every pair of levels from two factors appears exactly\nonce.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.6 Specifying Candidate Sets<\/h3><a id=\"user-content-86-specifying-candidate-sets\" class=\"anchor\" aria-label=\"Permalink: 8.6 Specifying Candidate Sets\" href=\"#86-specifying-candidate-sets\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Row exchange takes a candidate set, the list of runs it may choose from. Where the factor space is a cube, the candidate\nset is a grid over it.<\/p>\n<p dir=\"auto\">Passing the candidate set explicitly handles factor spaces that are not cubes. A mixture whose components must sum to\none, a pair of settings that cannot be high together, and a machine that cannot run cold and fast are all constraints that\nremove rows from the grid. The search never proposes a run that is not on the list, so deleting those rows from the\ncandidate set carries the constraint into the design.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">References<\/h2><a id=\"user-content-references\" class=\"anchor\" aria-label=\"Permalink: References\" href=\"#references\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><a id=\"user-content-ref-1\"><\/a>\n[1] MathWorks. <a href=\"https:\/\/kr.mathworks.com\/help\/stats\/design-of-experiments.html\" rel=\"nofollow\">Design of Experiments \u2014 Statistics and Machine Learning Toolbox Documentation<\/a>.<br>\n<a id=\"user-content-ref-2\"><\/a>\n[2] Montgomery, D. C. (2019). <em>Design and Analysis of Experiments<\/em> (10th ed.). Wiley.\nISBN 978-1-119-49249-8.<br>\n<a id=\"user-content-ref-3\"><\/a>\n[3] Plackett, R. L., &amp; Burman, J. P. (1946). <a href=\"https:\/\/doi.org\/10.1093\/biomet\/33.4.305\" rel=\"nofollow\">The Design of Optimum Multifactorial Experiments<\/a>.\n<em>Biometrika<\/em>, 33(4), 305\u2013325.<br>\n<a id=\"user-content-ref-4\"><\/a>\n[4] Box, G. E. P., &amp; Behnken, D. W. (1960). <a href=\"https:\/\/doi.org\/10.1080\/00401706.1960.10489912\" rel=\"nofollow\">Some New Three Level Designs for the Study of\nQuantitative Variables<\/a>. <em>Technometrics<\/em>, 2(4), 455\u2013475.<br>\n<a id=\"user-content-ref-5\"><\/a>\n[5] Meyer, R. K., &amp; Nachtsheim, C. J. (1995). <a href=\"https:\/\/doi.org\/10.1080\/00401706.1995.10485889\" rel=\"nofollow\">The Coordinate-Exchange Algorithm for Constructing\nExact Optimal Experimental Designs<\/a>. <em>Technometrics<\/em>, 37(1), 60\u201369.<\/p>\n<hr>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix A. Terminology<\/h2><a id=\"user-content-appendix-a-terminology\" class=\"anchor\" aria-label=\"Permalink: Appendix A. Terminology\" href=\"#appendix-a-terminology\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li>\n<strong>Basic factor<\/strong>: a factor whose column comes from the full factorial a fractional design starts\nfrom, rather than from a generator.<\/li>\n<li>\n<strong>Candidate set<\/strong>: the list of factor settings from which a D-optimal search may choose runs.<\/li>\n<li>\n<strong>Centre run<\/strong>: a run with every continuous factor at the middle of its range.<\/li>\n<li>\n<strong>Confounding<\/strong>: two effects carried by the same design column, so that no analysis of the\nexperiment can separate them.<\/li>\n<li>\n<strong>Covariate<\/strong>: a factor that the experimenter records for each run rather than sets.<\/li>\n<li>\n<strong>Defining relation<\/strong>: the set of products of factor columns that equal the column of ones in a\nfractional factorial design; its shortest word gives the resolution.<\/li>\n<li>\n<strong>Effect coding<\/strong>: coding of a categorical factor with <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$L$<\/math-renderer> levels into <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$L - 1$<\/math-renderer> columns, with the last level set to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$-1$<\/math-renderer> in every column.<\/li>\n<li>\n<strong>Factor<\/strong>: an input whose value the experimenter sets or records.<\/li>\n<li>\n<strong>Generator<\/strong>: the product of basic factors that defines an added factor in a fractional\nfactorial design.<\/li>\n<li>\n<strong>Hadamard matrix<\/strong>: a square matrix of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\pm 1$<\/math-renderer> entries whose columns are mutually orthogonal.<\/li>\n<li>\n<strong>Interaction<\/strong>: the extent to which the effect of one factor depends on the level of another.<\/li>\n<li>\n<strong>Level<\/strong>: one of the values a factor takes in a design.<\/li>\n<li>\n<strong>Main effect<\/strong>: the change in the response when one factor changes level, averaged over the other factors.<\/li>\n<li>\n<strong>Response<\/strong>: the measured output of a run.<\/li>\n<li>\n<strong>Rotatable<\/strong>: a design whose prediction variance depends only on the distance from the centre of\nthe factor space.<\/li>\n<li>\n<strong>Run<\/strong>: one execution of the experiment at one combination of factor levels; one row of a design.<\/li>\n<li>\n<strong>Screening<\/strong>: an experiment that picks out, from many factors, those with a significant effect on the response.<\/li>\n<li>\n<strong>Star point<\/strong>: a run of a central composite design that moves one factor off the centre and\nholds the rest at it.<\/li>\n<li>\n<strong>Treatment<\/strong>: a combination of factor levels.<\/li>\n<li>\n<strong>Word<\/strong>: a group of factor names whose product is the column of ones in the defining relation; its length is the number of factors in it.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix B. Python Implementation<\/h2><a id=\"user-content-appendix-b-python-implementation\" class=\"anchor\" aria-label=\"Permalink: Appendix B. Python Implementation\" href=\"#appendix-b-python-implementation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The Python blocks of this appendix are meant to run in order. Each one uses the names defined before it, on top of the\nheader in B.1, and the <code>text<\/code> block right after it holds its output. Running them needs numpy and scipy.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.1 Common Header<\/h3><a id=\"user-content-b1-common-header\" class=\"anchor\" aria-label=\"Permalink: B.1 Common Header\" href=\"#b1-common-header\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\nimport itertools\nfrom typing import Sequence\n\nimport numpy as np\nfrom scipy.linalg import hadamard\n\nnp.set_printoptions(linewidth=100, suppress=True, precision=4)\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">itertools<\/span>\n<span class=\"pl-k\">from<\/span> <span class=\"pl-s1\">typing<\/span> <span class=\"pl-k\">import<\/span> <span class=\"pl-v\">Sequence<\/span>\n\n<span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">numpy<\/span> <span class=\"pl-k\">as<\/span> <span class=\"pl-s1\">np<\/span>\n<span class=\"pl-k\">from<\/span> <span class=\"pl-s1\">scipy<\/span>.<span class=\"pl-s1\">linalg<\/span> <span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">hadamard<\/span>\n\n<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">set_printoptions<\/span>(<span class=\"pl-s1\">linewidth<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">100<\/span>, <span class=\"pl-s1\">suppress<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">True<\/span>, <span class=\"pl-s1\">precision<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">4<\/span>)<\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.2 Full Factorial Designs<\/h3><a id=\"user-content-b2-full-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: B.2 Full Factorial Designs\" href=\"#b2-full-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Multilevel Designs<\/h4><a id=\"user-content-multilevel-designs\" class=\"anchor\" aria-label=\"Permalink: Multilevel Designs\" href=\"#multilevel-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The cartesian product construction of section 5.1, making six runs from a two-level and a three-level factor.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef full_factorial(levels: Sequence[int]) -&gt; np.ndarray:\n    &quot;&quot;&quot;Full factorial design. Column i takes levels 0..levels[i]-1; the first column varies fastest.&quot;&quot;&quot;\n    levels = list(levels)\n    if any(v &lt; 2 for v in levels):\n        raise ValueError(f&quot;every factor needs at least 2 levels; got {levels}&quot;)\n    grids = np.meshgrid(*[np.arange(v) for v in levels], indexing='ij')\n    return np.column_stack([g.ravel(order='F') for g in grids])\n\n\nprint(full_factorial([2, 3]))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">full_factorial<\/span>(<span class=\"pl-s1\">levels<\/span>: <span class=\"pl-v\">Sequence<\/span>&#91;<span class=\"pl-smi\">int<\/span>&#93;) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Full factorial design. Column i takes levels 0..levels&#91;i&#93;-1; the first column varies fastest.\"\"\"<\/span>\n    <span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">levels<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">any<\/span>(<span class=\"pl-s1\">v<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">v<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">levels<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"every factor needs at least 2 levels; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">levels<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">grids<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">meshgrid<\/span>(<span class=\"pl-c1\">*<\/span>&#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">arange<\/span>(<span class=\"pl-s1\">v<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">v<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">levels<\/span>&#93;, <span class=\"pl-s1\">indexing<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'ij'<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">column_stack<\/span>(&#91;<span class=\"pl-s1\">g<\/span>.<span class=\"pl-c1\">ravel<\/span>(<span class=\"pl-s1\">order<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'F'<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">g<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">grids<\/span>&#93;)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">full_factorial<\/span>(&#91;<span class=\"pl-c1\">2<\/span>, <span class=\"pl-c1\">3<\/span>&#93;))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[0 0]\n [1 0]\n [0 1]\n [1 1]\n [0 2]\n [1 2]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;0 0&#93;\n &#91;1 0&#93;\n &#91;0 1&#93;\n &#91;1 1&#93;\n &#91;0 2&#93;\n &#91;1 2&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Two-Level Designs<\/h4><a id=\"user-content-two-level-designs\" class=\"anchor\" aria-label=\"Permalink: Two-Level Designs\" href=\"#two-level-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$2^k$<\/math-renderer> design of section 5.2, coded as <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"2421204870784d53fb91e11d948178c5\">$\\pm 1$<\/math-renderer>.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef two_level_factorial(n_factors: int) -&gt; np.ndarray:\n    &quot;&quot;&quot;Two-level full factorial design coded as -1 and +1.&quot;&quot;&quot;\n    if n_factors &lt; 1:\n        raise ValueError(f&quot;n_factors must be at least 1; got {n_factors}&quot;)\n    return 2.0 * full_factorial([2] * n_factors) - 1.0\n\n\nprint(two_level_factorial(3))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Two-level full factorial design coded as -1 and +1.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_factors must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">2.0<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-en\">full_factorial<\/span>(&#91;<span class=\"pl-c1\">2<\/span>&#93; <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">n_factors<\/span>) <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1.0<\/span>\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">3<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1. -1. -1.]\n [ 1. -1. -1.]\n [-1.  1. -1.]\n [ 1.  1. -1.]\n [-1. -1.  1.]\n [ 1. -1.  1.]\n [-1.  1.  1.]\n [ 1.  1.  1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1. -1. -1.&#93;\n &#91; 1. -1. -1.&#93;\n &#91;-1.  1. -1.&#93;\n &#91; 1.  1. -1.&#93;\n &#91;-1. -1.  1.&#93;\n &#91; 1. -1.  1.&#93;\n &#91;-1.  1.  1.&#93;\n &#91; 1.  1.  1.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.3 Fractional Factorial Designs<\/h3><a id=\"user-content-b3-fractional-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: B.3 Fractional Factorial Designs\" href=\"#b3-fractional-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Plackett-Burman Designs<\/h4><a id=\"user-content-plackett-burman-designs\" class=\"anchor\" aria-label=\"Permalink: Plackett-Burman Designs\" href=\"#plackett-burman-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The construction of section 6.2. The last line checks that the 11 columns of the 12-run design are mutually orthogonal. A\nrun count that is neither a power of 2 nor covered by a generator raises instead of falling back on a different design.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\nPB_GENERATORS = {\n    12: '++-+++---+-',\n    20: '++--++++-+-+----++-',\n    24: '+++++-+-++--++--+-+----',\n}\n\n\ndef plackett_burman(n_factors: int) -&gt; np.ndarray:\n    &quot;&quot;&quot;Plackett-Burman design with the smallest run count that is a multiple of 4 and exceeds n_factors.&quot;&quot;&quot;\n    if n_factors &lt; 1:\n        raise ValueError(f&quot;n_factors must be at least 1; got {n_factors}&quot;)\n    n_runs = 4 * int(np.ceil((n_factors + 1) \/ 4))\n    if n_runs &amp; (n_runs - 1) == 0:\n        design = hadamard(n_runs)[:, 1:] * 1.0\n    elif n_runs in PB_GENERATORS:\n        row = np.array([1.0 if c == '+' else -1.0 for c in PB_GENERATORS[n_runs]])\n        design = np.vstack([np.roll(row, k) for k in range(n_runs - 1)] + [-np.ones(n_runs - 1)])\n    else:\n        raise ValueError(f&quot;no Plackett-Burman construction available for {n_runs} runs&quot;)\n    return design[:, :n_factors]\n\n\ndesign = plackett_burman(11)\nprint(design.shape, np.allclose(design.T @ design, 12 * np.eye(11)))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-c1\">PB_GENERATORS<\/span> <span class=\"pl-c1\">=<\/span> {\n    <span class=\"pl-c1\">12<\/span>: <span class=\"pl-s\">'++-+++---+-'<\/span>,\n    <span class=\"pl-c1\">20<\/span>: <span class=\"pl-s\">'++--++++-+-+----++-'<\/span>,\n    <span class=\"pl-c1\">24<\/span>: <span class=\"pl-s\">'+++++-+-++--++--+-+----'<\/span>,\n}\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">plackett_burman<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Plackett-Burman design with the smallest run count that is a multiple of 4 and exceeds n_factors.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_factors must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">4<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-en\">int<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ceil<\/span>((<span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-c1\">4<\/span>))\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">&amp;<\/span> (<span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">0<\/span>:\n        <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">hadamard<\/span>(<span class=\"pl-s1\">n_runs<\/span>)&#91;:, <span class=\"pl-c1\">1<\/span>:&#93; <span class=\"pl-c1\">*<\/span> <span class=\"pl-c1\">1.0<\/span>\n    <span class=\"pl-k\">elif<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-c1\">PB_GENERATORS<\/span>:\n        <span class=\"pl-s1\">row<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(&#91;<span class=\"pl-c1\">1.0<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'+'<\/span> <span class=\"pl-k\">else<\/span> <span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-c1\">PB_GENERATORS<\/span>&#91;<span class=\"pl-s1\">n_runs<\/span>&#93;&#93;)\n        <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">roll<\/span>(<span class=\"pl-s1\">row<\/span>, <span class=\"pl-s1\">k<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">k<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>)&#93; <span class=\"pl-c1\">+<\/span> &#91;<span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ones<\/span>(<span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>)&#93;)\n    <span class=\"pl-k\">else<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"no Plackett-Burman construction available for <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_runs<\/span><span class=\"pl-kos\">}<\/span><\/span> runs\"<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">design<\/span>&#91;:, :<span class=\"pl-s1\">n_factors<\/span>&#93;\n\n\n<span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">plackett_burman<\/span>(<span class=\"pl-c1\">11<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">shape<\/span>, <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">allclose<\/span>(<span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">T<\/span> @ <span class=\"pl-s1\">design<\/span>, <span class=\"pl-c1\">12<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">eye<\/span>(<span class=\"pl-c1\">11<\/span>)))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"(12, 11) True\"><pre lang=\"text\" class=\"notranslate\"><code>(12, 11) True\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">General Fractional Designs<\/h4><a id=\"user-content-general-fractional-designs\" class=\"anchor\" aria-label=\"Permalink: General Fractional Designs\" href=\"#general-fractional-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The generator construction of section 6.3, making the eight-run design in four factors from the generators <code>a b c abc<\/code>.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef fractional_factorial(generators: str) -&gt; np.ndarray:\n    &quot;&quot;&quot;Fractional factorial design from generators such as 'a b c abc'. Single letters are the basic factors.&quot;&quot;&quot;\n    terms = generators.split()\n    basic = ''.join(t for t in terms if len(t) == 1)\n    if not basic:\n        raise ValueError(f&quot;generators must contain at least one single-letter basic factor; got {generators!r}&quot;)\n    if len(set(basic)) != len(basic):\n        raise ValueError(f&quot;basic factors must be distinct; got {basic!r}&quot;)\n    base = two_level_factorial(len(basic))\n    columns = []\n    for term in terms:\n        unknown = set(term) - set(basic)\n        if unknown:\n            raise ValueError(f&quot;term {term!r} uses factors {sorted(unknown)} that are not basic factors&quot;)\n        columns.append(np.prod(base[:, [basic.index(c) for c in term]], axis=1))\n    return np.column_stack(columns)\n\n\nprint(fractional_factorial('a b c abc'))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">fractional_factorial<\/span>(<span class=\"pl-s1\">generators<\/span>: <span class=\"pl-smi\">str<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Fractional factorial design from generators such as 'a b c abc'. Single letters are the basic factors.\"\"\"<\/span>\n    <span class=\"pl-s1\">terms<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">generators<\/span>.<span class=\"pl-c1\">split<\/span>()\n    <span class=\"pl-s1\">basic<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">''<\/span>.<span class=\"pl-c1\">join<\/span>(<span class=\"pl-s1\">t<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">t<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">terms<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">t<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">1<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-c1\">not<\/span> <span class=\"pl-s1\">basic<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"generators must contain at least one single-letter basic factor; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">generators<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-en\">set<\/span>(<span class=\"pl-s1\">basic<\/span>)) <span class=\"pl-c1\">!=<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">basic<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"basic factors must be distinct; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">basic<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">base<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">basic<\/span>))\n    <span class=\"pl-s1\">columns<\/span> <span class=\"pl-c1\">=<\/span> &#91;&#93;\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">term<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">terms<\/span>:\n        <span class=\"pl-s1\">unknown<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">set<\/span>(<span class=\"pl-s1\">term<\/span>) <span class=\"pl-c1\">-<\/span> <span class=\"pl-en\">set<\/span>(<span class=\"pl-s1\">basic<\/span>)\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">unknown<\/span>:\n            <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"term <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">term<\/span>!r<span class=\"pl-kos\">}<\/span><\/span> uses factors <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">sorted<\/span>(<span class=\"pl-s1\">unknown<\/span>)<span class=\"pl-kos\">}<\/span><\/span> that are not basic factors\"<\/span>)\n        <span class=\"pl-s1\">columns<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">prod<\/span>(<span class=\"pl-s1\">base<\/span>&#91;:, &#91;<span class=\"pl-s1\">basic<\/span>.<span class=\"pl-c1\">index<\/span>(<span class=\"pl-s1\">c<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">term<\/span>&#93;&#93;, <span class=\"pl-s1\">axis<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>))\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">column_stack<\/span>(<span class=\"pl-s1\">columns<\/span>)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">fractional_factorial<\/span>(<span class=\"pl-s\">'a b c abc'<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1. -1. -1. -1.]\n [ 1. -1. -1.  1.]\n [-1.  1. -1.  1.]\n [ 1.  1. -1. -1.]\n [-1. -1.  1.  1.]\n [ 1. -1.  1. -1.]\n [-1.  1.  1. -1.]\n [ 1.  1.  1.  1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1. -1. -1. -1.&#93;\n &#91; 1. -1. -1.  1.&#93;\n &#91;-1.  1. -1.  1.&#93;\n &#91; 1.  1. -1. -1.&#93;\n &#91;-1. -1.  1.  1.&#93;\n &#91; 1. -1.  1. -1.&#93;\n &#91;-1.  1.  1. -1.&#93;\n &#91; 1.  1.  1.  1.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Design Resolution<\/h4><a id=\"user-content-design-resolution\" class=\"anchor\" aria-label=\"Permalink: Design Resolution\" href=\"#design-resolution\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Computes the resolution of Table 3 as the shortest word in the subgroup generated by the words the generators imply.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef design_resolution(generators: str) -&gt; int:\n    &quot;&quot;&quot;Resolution of a fractional factorial design: the length of the shortest word in the defining relation.&quot;&quot;&quot;\n    terms = generators.split()\n    basic = ''.join(t for t in terms if len(t) == 1)\n    names = [chr(ord('A') + i) for i in range(len(terms))]\n    words = []\n    for name, term in zip(names, terms):\n        if len(term) == 1:\n            continue\n        words.append(frozenset([names[basic.index(c)] for c in term] + [name]))\n    if not words:\n        return len(terms) + 1  # a full factorial has no defining relation, so no effect is confounded\n    subgroup = set()\n    for size in range(1, len(words) + 1):\n        for combination in itertools.combinations(words, size):\n            word = frozenset()\n            for w in combination:\n                word = word.symmetric_difference(w)\n            if word:\n                subgroup.add(word)\n    return min(len(w) for w in subgroup)\n\n\nfor spec in ['a b ab', 'a b c ab', 'a b c abc', 'a b c d abcd']:\n    print(f'{spec:16s} runs={len(fractional_factorial(spec)):2d} resolution={design_resolution(spec)}')\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">design_resolution<\/span>(<span class=\"pl-s1\">generators<\/span>: <span class=\"pl-smi\">str<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">int<\/span>:\n    <span class=\"pl-s\">\"\"\"Resolution of a fractional factorial design: the length of the shortest word in the defining relation.\"\"\"<\/span>\n    <span class=\"pl-s1\">terms<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">generators<\/span>.<span class=\"pl-c1\">split<\/span>()\n    <span class=\"pl-s1\">basic<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">''<\/span>.<span class=\"pl-c1\">join<\/span>(<span class=\"pl-s1\">t<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">t<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">terms<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">t<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">1<\/span>)\n    <span class=\"pl-s1\">names<\/span> <span class=\"pl-c1\">=<\/span> &#91;<span class=\"pl-en\">chr<\/span>(<span class=\"pl-en\">ord<\/span>(<span class=\"pl-s\">'A'<\/span>) <span class=\"pl-c1\">+<\/span> <span class=\"pl-s1\">i<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">terms<\/span>))&#93;\n    <span class=\"pl-s1\">words<\/span> <span class=\"pl-c1\">=<\/span> &#91;&#93;\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">name<\/span>, <span class=\"pl-s1\">term<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">zip<\/span>(<span class=\"pl-s1\">names<\/span>, <span class=\"pl-s1\">terms<\/span>):\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">term<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">1<\/span>:\n            <span class=\"pl-k\">continue<\/span>\n        <span class=\"pl-s1\">words<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-en\">frozenset<\/span>(&#91;<span class=\"pl-s1\">names<\/span>&#91;<span class=\"pl-s1\">basic<\/span>.<span class=\"pl-c1\">index<\/span>(<span class=\"pl-s1\">c<\/span>)&#93; <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">term<\/span>&#93; <span class=\"pl-c1\">+<\/span> &#91;<span class=\"pl-s1\">name<\/span>&#93;))\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-c1\">not<\/span> <span class=\"pl-s1\">words<\/span>:\n        <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">terms<\/span>) <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>  <span class=\"pl-c\"># a full factorial has no defining relation, so no effect is confounded<\/span>\n    <span class=\"pl-s1\">subgroup<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">set<\/span>()\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">size<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-c1\">1<\/span>, <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">words<\/span>) <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>):\n        <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">combination<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">combinations<\/span>(<span class=\"pl-s1\">words<\/span>, <span class=\"pl-s1\">size<\/span>):\n            <span class=\"pl-s1\">word<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">frozenset<\/span>()\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">w<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">combination<\/span>:\n                <span class=\"pl-s1\">word<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">word<\/span>.<span class=\"pl-c1\">symmetric_difference<\/span>(<span class=\"pl-s1\">w<\/span>)\n            <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">word<\/span>:\n                <span class=\"pl-s1\">subgroup<\/span>.<span class=\"pl-c1\">add<\/span>(<span class=\"pl-s1\">word<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">min<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">w<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">w<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">subgroup<\/span>)\n\n\n<span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">spec<\/span> <span class=\"pl-c1\">in<\/span> &#91;<span class=\"pl-s\">'a b ab'<\/span>, <span class=\"pl-s\">'a b c ab'<\/span>, <span class=\"pl-s\">'a b c abc'<\/span>, <span class=\"pl-s\">'a b c d abcd'<\/span>&#93;:\n    <span class=\"pl-en\">print<\/span>(<span class=\"pl-s\">f'<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">spec<\/span>:16s<span class=\"pl-kos\">}<\/span><\/span> runs=<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">len<\/span>(<span class=\"pl-en\">fractional_factorial<\/span>(<span class=\"pl-s1\">spec<\/span>)):2d<span class=\"pl-kos\">}<\/span><\/span> resolution=<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">design_resolution<\/span>(<span class=\"pl-s1\">spec<\/span>)<span class=\"pl-kos\">}<\/span><\/span>'<\/span>)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"a b ab           runs= 4 resolution=3\na b c ab         runs= 8 resolution=3\na b c abc        runs= 8 resolution=4\na b c d abcd     runs=16 resolution=5\"><pre lang=\"text\" class=\"notranslate\"><code>a b ab           runs= 4 resolution=3\na b c ab         runs= 8 resolution=3\na b c abc        runs= 8 resolution=4\na b c d abcd     runs=16 resolution=5\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.4 Response Surface Designs<\/h3><a id=\"user-content-b4-response-surface-designs\" class=\"anchor\" aria-label=\"Permalink: B.4 Response Surface Designs\" href=\"#b4-response-surface-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Central Composite Designs<\/h4><a id=\"user-content-central-composite-designs\" class=\"anchor\" aria-label=\"Permalink: Central Composite Designs\" href=\"#central-composite-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The three variants of section 7.2, chosen by <code>kind<\/code>. An invalid <code>kind<\/code> raises instead of falling back on a default, so a\nmisspelled variant cannot produce a design the caller did not ask for.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef central_composite(n_factors: int, n_center: int = 1, kind: str = 'circumscribed') -&gt; np.ndarray:\n    &quot;&quot;&quot;Central composite design. kind is 'circumscribed', 'inscribed' or 'faced'.&quot;&quot;&quot;\n    if n_factors &lt; 2:\n        raise ValueError(f&quot;a central composite design needs at least 2 factors; got {n_factors}&quot;)\n    if n_center &lt; 1:\n        raise ValueError(f&quot;n_center must be at least 1; got {n_center}&quot;)\n    if kind not in ('circumscribed', 'inscribed', 'faced'):\n        raise ValueError(f&quot;kind must be 'circumscribed', 'inscribed' or 'faced'; got {kind!r}&quot;)\n    cube = two_level_factorial(n_factors)\n    alpha = 1.0 if kind == 'faced' else (2.0 ** n_factors) ** 0.25\n    star = np.zeros((2 * n_factors, n_factors))\n    for i in range(n_factors):\n        star[2 * i, i] = alpha\n        star[2 * i + 1, i] = -alpha\n    if kind == 'inscribed':\n        cube, star = cube \/ alpha, star \/ alpha\n    return np.vstack([cube, star, np.zeros((n_center, n_factors))])\n\n\nprint(central_composite(2, n_center=1))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">central_composite<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_center<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">1<\/span>, <span class=\"pl-s1\">kind<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'circumscribed'<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Central composite design. kind is 'circumscribed', 'inscribed' or 'faced'.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"a central composite design needs at least 2 factors; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_center<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_center must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_center<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">kind<\/span> <span class=\"pl-c1\"><span class=\"pl-c1\">not<\/span> <span class=\"pl-c1\">in<\/span><\/span> (<span class=\"pl-s\">'circumscribed'<\/span>, <span class=\"pl-s\">'inscribed'<\/span>, <span class=\"pl-s\">'faced'<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"kind must be 'circumscribed', 'inscribed' or 'faced'; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">kind<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">cube<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-s1\">n_factors<\/span>)\n    <span class=\"pl-s1\">alpha<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">1.0<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">kind<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'faced'<\/span> <span class=\"pl-k\">else<\/span> (<span class=\"pl-c1\">2.0<\/span> <span class=\"pl-c1\">**<\/span> <span class=\"pl-s1\">n_factors<\/span>) <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">0.25<\/span>\n    <span class=\"pl-s1\">star<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-c1\">2<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">n_factors<\/span>, <span class=\"pl-s1\">n_factors<\/span>))\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n        <span class=\"pl-s1\">star<\/span>&#91;<span class=\"pl-c1\">2<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">alpha<\/span>\n        <span class=\"pl-s1\">star<\/span>&#91;<span class=\"pl-c1\">2<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">alpha<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">kind<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'inscribed'<\/span>:\n        <span class=\"pl-s1\">cube<\/span>, <span class=\"pl-s1\">star<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">cube<\/span> <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">alpha<\/span>, <span class=\"pl-s1\">star<\/span> <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">alpha<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">cube<\/span>, <span class=\"pl-s1\">star<\/span>, <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-s1\">n_center<\/span>, <span class=\"pl-s1\">n_factors<\/span>))&#93;)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">central_composite<\/span>(<span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">n_center<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1.     -1.    ]\n [ 1.     -1.    ]\n [-1.      1.    ]\n [ 1.      1.    ]\n [ 1.4142  0.    ]\n [-1.4142  0.    ]\n [ 0.      1.4142]\n [ 0.     -1.4142]\n [ 0.      0.    ]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1.     -1.    &#93;\n &#91; 1.     -1.    &#93;\n &#91;-1.      1.    &#93;\n &#91; 1.      1.    &#93;\n &#91; 1.4142  0.    &#93;\n &#91;-1.4142  0.    &#93;\n &#91; 0.      1.4142&#93;\n &#91; 0.     -1.4142&#93;\n &#91; 0.      0.    &#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Box-Behnken Designs<\/h4><a id=\"user-content-box-behnken-designs\" class=\"anchor\" aria-label=\"Permalink: Box-Behnken Designs\" href=\"#box-behnken-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The pairwise construction of section 7.3, making the fifteen runs of Table 4 from three factors and three centre runs.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef box_behnken(n_factors: int, n_center: int = 3) -&gt; np.ndarray:\n    &quot;&quot;&quot;Box-Behnken design: a two-level factorial in each pair of factors with the rest held at the centre.&quot;&quot;&quot;\n    if n_factors &lt; 3:\n        raise ValueError(f&quot;a Box-Behnken design needs at least 3 factors; got {n_factors}&quot;)\n    if n_center &lt; 1:\n        raise ValueError(f&quot;n_center must be at least 1; got {n_center}&quot;)\n    block = two_level_factorial(2)\n    rows = []\n    for i, j in itertools.combinations(range(n_factors), 2):\n        edge = np.zeros((len(block), n_factors))\n        edge[:, [i, j]] = block\n        rows.append(edge)\n    return np.vstack(rows + [np.zeros((n_center, n_factors))])\n\n\nprint(box_behnken(3, n_center=3))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">box_behnken<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_center<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Box-Behnken design: a two-level factorial in each pair of factors with the rest held at the centre.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">3<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"a Box-Behnken design needs at least 3 factors; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_center<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_center must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_center<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">block<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">2<\/span>)\n    <span class=\"pl-s1\">rows<\/span> <span class=\"pl-c1\">=<\/span> &#91;&#93;\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">j<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">combinations<\/span>(<span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>), <span class=\"pl-c1\">2<\/span>):\n        <span class=\"pl-s1\">edge<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">block<\/span>), <span class=\"pl-s1\">n_factors<\/span>))\n        <span class=\"pl-s1\">edge<\/span>&#91;:, &#91;<span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">j<\/span>&#93;&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">block<\/span>\n        <span class=\"pl-s1\">rows<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">edge<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(<span class=\"pl-s1\">rows<\/span> <span class=\"pl-c1\">+<\/span> &#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-s1\">n_center<\/span>, <span class=\"pl-s1\">n_factors<\/span>))&#93;)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">box_behnken<\/span>(<span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">n_center<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1. -1.  0.]\n [ 1. -1.  0.]\n [-1.  1.  0.]\n [ 1.  1.  0.]\n [-1.  0. -1.]\n [ 1.  0. -1.]\n [-1.  0.  1.]\n [ 1.  0.  1.]\n [ 0. -1. -1.]\n [ 0.  1. -1.]\n [ 0. -1.  1.]\n [ 0.  1.  1.]\n [ 0.  0.  0.]\n [ 0.  0.  0.]\n [ 0.  0.  0.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1. -1.  0.&#93;\n &#91; 1. -1.  0.&#93;\n &#91;-1.  1.  0.&#93;\n &#91; 1.  1.  0.&#93;\n &#91;-1.  0. -1.&#93;\n &#91; 1.  0. -1.&#93;\n &#91;-1.  0.  1.&#93;\n &#91; 1.  0.  1.&#93;\n &#91; 0. -1. -1.&#93;\n &#91; 0.  1. -1.&#93;\n &#91; 0. -1.  1.&#93;\n &#91; 0.  1.  1.&#93;\n &#91; 0.  0.  0.&#93;\n &#91; 0.  0.  0.&#93;\n &#91; 0.  0.  0.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.5 D-Optimal Designs<\/h3><a id=\"user-content-b5-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: B.5 D-Optimal Designs\" href=\"#b5-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">D-Efficiency<\/h4><a id=\"user-content-d-efficiency\" class=\"anchor\" aria-label=\"Permalink: D-Efficiency\" href=\"#d-efficiency\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Computes equation (3) and checks the scale with the D-efficiency of 1 that the two-level full factorial reaches for the\nlinear model. Fewer runs than model terms raise an error.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef model_matrix(design: np.ndarray, model: str = 'linear') -&gt; np.ndarray:\n    &quot;&quot;&quot;Model matrix with an intercept. model is 'linear', 'interaction' or 'quadratic'.&quot;&quot;&quot;\n    if model not in ('linear', 'interaction', 'quadratic'):\n        raise ValueError(f&quot;model must be 'linear', 'interaction' or 'quadratic'; got {model!r}&quot;)\n    design = np.atleast_2d(design)\n    n_runs, n_factors = design.shape\n    columns = [np.ones(n_runs), *design.T]\n    if model in ('interaction', 'quadratic'):\n        for i, j in itertools.combinations(range(n_factors), 2):\n            columns.append(design[:, i] * design[:, j])\n    if model == 'quadratic':\n        for i in range(n_factors):\n            columns.append(design[:, i] ** 2)\n    return np.column_stack(columns)\n\n\ndef d_efficiency(design: np.ndarray, model: str = 'linear') -&gt; float:\n    &quot;&quot;&quot;D-efficiency, the normalised determinant of the information matrix. Larger is better; 1 is the maximum.&quot;&quot;&quot;\n    x = model_matrix(design, model=model)\n    n_runs, n_terms = x.shape\n    if n_runs &lt; n_terms:\n        raise ValueError(f&quot;{n_runs} runs cannot fit {n_terms} model terms&quot;)\n    determinant = np.linalg.det(x.T @ x)\n    if determinant &lt;= 0:\n        return 0.0\n    return determinant ** (1.0 \/ n_terms) \/ n_runs\n\n\nprint(round(d_efficiency(two_level_factorial(2), model='linear'), 4))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">model_matrix<\/span>(<span class=\"pl-s1\">design<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Model matrix with an intercept. model is 'linear', 'interaction' or 'quadratic'.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">model<\/span> <span class=\"pl-c1\"><span class=\"pl-c1\">not<\/span> <span class=\"pl-c1\">in<\/span><\/span> (<span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s\">'interaction'<\/span>, <span class=\"pl-s\">'quadratic'<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"model must be 'linear', 'interaction' or 'quadratic'; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">model<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">atleast_2d<\/span>(<span class=\"pl-s1\">design<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">shape<\/span>\n    <span class=\"pl-s1\">columns<\/span> <span class=\"pl-c1\">=<\/span> &#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ones<\/span>(<span class=\"pl-s1\">n_runs<\/span>), <span class=\"pl-c1\">*<\/span><span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">T<\/span>&#93;\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">model<\/span> <span class=\"pl-c1\">in<\/span> (<span class=\"pl-s\">'interaction'<\/span>, <span class=\"pl-s\">'quadratic'<\/span>):\n        <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">j<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">combinations<\/span>(<span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>), <span class=\"pl-c1\">2<\/span>):\n            <span class=\"pl-s1\">columns<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">design<\/span>&#91;:, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">design<\/span>&#91;:, <span class=\"pl-s1\">j<\/span>&#93;)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">model<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'quadratic'<\/span>:\n        <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n            <span class=\"pl-s1\">columns<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">design<\/span>&#91;:, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">2<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">column_stack<\/span>(<span class=\"pl-s1\">columns<\/span>)\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"D-efficiency, the normalised determinant of the information matrix. Larger is better; 1 is the maximum.\"\"\"<\/span>\n    <span class=\"pl-s1\">x<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">model_matrix<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_terms<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">x<\/span>.<span class=\"pl-c1\">shape<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-s1\">n_terms<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_runs<\/span><span class=\"pl-kos\">}<\/span><\/span> runs cannot fit <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_terms<\/span><span class=\"pl-kos\">}<\/span><\/span> model terms\"<\/span>)\n    <span class=\"pl-s1\">determinant<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linalg<\/span>.<span class=\"pl-c1\">det<\/span>(<span class=\"pl-s1\">x<\/span>.<span class=\"pl-c1\">T<\/span> @ <span class=\"pl-s1\">x<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">determinant<\/span> <span class=\"pl-c1\">&lt;=<\/span> <span class=\"pl-c1\">0<\/span>:\n        <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">0.0<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">determinant<\/span> <span class=\"pl-c1\">**<\/span> (<span class=\"pl-c1\">1.0<\/span> <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">n_terms<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">n_runs<\/span>\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">round<\/span>(<span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">2<\/span>), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'linear'<\/span>), <span class=\"pl-c1\">4<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"1.0\"><pre lang=\"text\" class=\"notranslate\"><code>1.0\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Coordinate Exchange<\/h4><a id=\"user-content-coordinate-exchange\" class=\"anchor\" aria-label=\"Permalink: Coordinate Exchange\" href=\"#coordinate-exchange\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The search of section 8.2, choosing twelve runs for a quadratic model in three factors. The first output line is the\nD-efficiency.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef coordinate_exchange(n_runs: int, n_factors: int, model: str = 'linear', n_levels: int = 3,\n                        n_tries: int = 5, seed: int = None) -&gt; np.ndarray:\n    &quot;&quot;&quot;D-optimal design by coordinate exchange over a grid of n_levels values spanning [-1, 1].&quot;&quot;&quot;\n    if n_levels &lt; 2:\n        raise ValueError(f&quot;n_levels must be at least 2; got {n_levels}&quot;)\n    rng = np.random.default_rng(seed)\n    grid = np.linspace(-1.0, 1.0, n_levels)\n    best, best_score = None, -np.inf\n    for _ in range(n_tries):\n        design = rng.choice(grid, size=(n_runs, n_factors))\n        score = d_efficiency(design, model=model)\n        improved = True\n        while improved:\n            improved = False\n            for run in range(n_runs):\n                for factor in range(n_factors):\n                    current = design[run, factor]\n                    for value in grid:\n                        design[run, factor] = value\n                        trial = d_efficiency(design, model=model)\n                        if trial &gt; score + 1e-12:\n                            score, current, improved = trial, value, True\n                    design[run, factor] = current\n        if score &gt; best_score:\n            best, best_score = design.copy(), score\n    return best\n\n\ndesign = coordinate_exchange(n_runs=12, n_factors=3, model='quadratic', n_levels=3, n_tries=5, seed=1)\nprint(round(d_efficiency(design, model='quadratic'), 4))\nprint(design)\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">coordinate_exchange<\/span>(<span class=\"pl-s1\">n_runs<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>,\n                        <span class=\"pl-s1\">n_tries<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"D-optimal design by coordinate exchange over a grid of n_levels values spanning &#91;-1, 1&#93;.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_levels must be at least 2; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_levels<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">rng<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">random<\/span>.<span class=\"pl-c1\">default_rng<\/span>(<span class=\"pl-s1\">seed<\/span>)\n    <span class=\"pl-s1\">grid<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-s1\">n_levels<\/span>)\n    <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">inf<\/span>\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">_<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_tries<\/span>):\n        <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">rng<\/span>.<span class=\"pl-c1\">choice<\/span>(<span class=\"pl-s1\">grid<\/span>, <span class=\"pl-s1\">size<\/span><span class=\"pl-c1\">=<\/span>(<span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_factors<\/span>))\n        <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n        <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">True<\/span>\n        <span class=\"pl-k\">while<\/span> <span class=\"pl-s1\">improved<\/span>:\n            <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">False<\/span>\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">run<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span>):\n                <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">factor<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n                    <span class=\"pl-s1\">current<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">design<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93;\n                    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">value<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">grid<\/span>:\n                        <span class=\"pl-s1\">design<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">value<\/span>\n                        <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n                        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1e-12<\/span>:\n                            <span class=\"pl-s1\">score<\/span>, <span class=\"pl-s1\">current<\/span>, <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">trial<\/span>, <span class=\"pl-s1\">value<\/span>, <span class=\"pl-c1\">True<\/span>\n                    <span class=\"pl-s1\">design<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">current<\/span>\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">best_score<\/span>:\n            <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-s1\">score<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">best<\/span>\n\n\n<span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">coordinate_exchange<\/span>(<span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">12<\/span>, <span class=\"pl-s1\">n_factors<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>, <span class=\"pl-s1\">n_levels<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">round<\/span>(<span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>), <span class=\"pl-c1\">4<\/span>))\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">design<\/span>)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"0.4498\n[[ 1.  1.  1.]\n [-1. -1. -1.]\n [ 1.  1. -1.]\n [-1.  1.  1.]\n [-1.  1. -1.]\n [-1.  0.  0.]\n [ 0.  0. -1.]\n [ 0.  1.  0.]\n [ 1. -1.  1.]\n [ 1. -1. -1.]\n [ 1.  0.  1.]\n [-1. -1.  1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>0.4498\n&#91;&#91; 1.  1.  1.&#93;\n &#91;-1. -1. -1.&#93;\n &#91; 1.  1. -1.&#93;\n &#91;-1.  1.  1.&#93;\n &#91;-1.  1. -1.&#93;\n &#91;-1.  0.  0.&#93;\n &#91; 0.  0. -1.&#93;\n &#91; 0.  1.  0.&#93;\n &#91; 1. -1.  1.&#93;\n &#91; 1. -1. -1.&#93;\n &#91; 1.  0.  1.&#93;\n &#91;-1. -1.  1.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Row Exchange and Augmentation<\/h4><a id=\"user-content-row-exchange-and-augmentation\" class=\"anchor\" aria-label=\"Permalink: Row Exchange and Augmentation\" href=\"#row-exchange-and-augmentation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The search of section 8.3; rows passed in <code>fixed<\/code> are not exchanged. Two runs are added to the four corner runs.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef row_exchange(candidates: np.ndarray, n_runs: int, model: str = 'linear', n_tries: int = 5,\n                 seed: int = None, fixed: np.ndarray = None) -&gt; np.ndarray:\n    &quot;&quot;&quot;D-optimal design chosen from a candidate set by row exchange. Rows in fixed are kept and not exchanged.&quot;&quot;&quot;\n    if n_runs &lt; 1:\n        raise ValueError(f&quot;n_runs must be at least 1; got {n_runs}&quot;)\n    rng = np.random.default_rng(seed)\n    fixed = np.empty((0, candidates.shape[1])) if fixed is None else np.atleast_2d(fixed)\n    best, best_score = None, -np.inf\n    for _ in range(n_tries):\n        chosen = candidates[rng.choice(len(candidates), size=n_runs, replace=True)]\n        score = d_efficiency(np.vstack([fixed, chosen]), model=model)\n        improved = True\n        while improved:\n            improved = False\n            for run in range(n_runs):\n                current = chosen[run].copy()\n                for row in candidates:\n                    chosen[run] = row\n                    trial = d_efficiency(np.vstack([fixed, chosen]), model=model)\n                    if trial &gt; score + 1e-12:\n                        score, current, improved = trial, row.copy(), True\n                chosen[run] = current\n        if score &gt; best_score:\n            best, best_score = chosen.copy(), score\n    return best\n\n\nexisting = two_level_factorial(2)\nallowed = np.array(list(itertools.product([-1.0, 0.0, 1.0], repeat=2)))[:, ::-1]\nadded = row_exchange(allowed, n_runs=2, model='quadratic', n_tries=5, seed=3, fixed=existing)\nprint(added)\nprint(round(d_efficiency(np.vstack([existing, added]), model='quadratic'), 4))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-s1\">candidates<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">n_runs<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_tries<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">5<\/span>,\n                 <span class=\"pl-s1\">seed<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">fixed<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"D-optimal design chosen from a candidate set by row exchange. Rows in fixed are kept and not exchanged.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_runs must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_runs<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">rng<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">random<\/span>.<span class=\"pl-c1\">default_rng<\/span>(<span class=\"pl-s1\">seed<\/span>)\n    <span class=\"pl-s1\">fixed<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">empty<\/span>((<span class=\"pl-c1\">0<\/span>, <span class=\"pl-s1\">candidates<\/span>.<span class=\"pl-c1\">shape<\/span>&#91;<span class=\"pl-c1\">1<\/span>&#93;)) <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">fixed<\/span> <span class=\"pl-c1\">is<\/span> <span class=\"pl-c1\">None<\/span> <span class=\"pl-k\">else<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">atleast_2d<\/span>(<span class=\"pl-s1\">fixed<\/span>)\n    <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">inf<\/span>\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">_<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_tries<\/span>):\n        <span class=\"pl-s1\">chosen<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">candidates<\/span>&#91;<span class=\"pl-s1\">rng<\/span>.<span class=\"pl-c1\">choice<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">candidates<\/span>), <span class=\"pl-s1\">size<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">replace<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">True<\/span>)&#93;\n        <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">fixed<\/span>, <span class=\"pl-s1\">chosen<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n        <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">True<\/span>\n        <span class=\"pl-k\">while<\/span> <span class=\"pl-s1\">improved<\/span>:\n            <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">False<\/span>\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">run<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span>):\n                <span class=\"pl-s1\">current<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">run<\/span>&#93;.<span class=\"pl-c1\">copy<\/span>()\n                <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">row<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">candidates<\/span>:\n                    <span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">run<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">row<\/span>\n                    <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">fixed<\/span>, <span class=\"pl-s1\">chosen<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n                    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1e-12<\/span>:\n                        <span class=\"pl-s1\">score<\/span>, <span class=\"pl-s1\">current<\/span>, <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">trial<\/span>, <span class=\"pl-s1\">row<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-c1\">True<\/span>\n                <span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">run<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">current<\/span>\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">best_score<\/span>:\n            <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">chosen<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-s1\">score<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">best<\/span>\n\n\n<span class=\"pl-s1\">existing<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">2<\/span>)\n<span class=\"pl-s1\">allowed<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(<span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">product<\/span>(&#91;<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">0.0<\/span>, <span class=\"pl-c1\">1.0<\/span>&#93;, <span class=\"pl-s1\">repeat<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>)))&#91;:, ::<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>&#93;\n<span class=\"pl-s1\">added<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-s1\">allowed<\/span>, <span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">fixed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">existing<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">added<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">round<\/span>(<span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">existing<\/span>, <span class=\"pl-s1\">added<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>), <span class=\"pl-c1\">4<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[ 0.  1.]\n [-1.  0.]]\n0.42\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91; 0.  1.&#93;\n &#91;-1.  0.&#93;&#93;\n0.42\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Fixed Covariates<\/h4><a id=\"user-content-fixed-covariates\" class=\"anchor\" aria-label=\"Permalink: Fixed Covariates\" href=\"#fixed-covariates\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The search of section 8.4; the last column is the evenly drifting covariate.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef covariate_exchange(covariates: np.ndarray, n_factors: int, model: str = 'linear', n_levels: int = 3,\n                       n_tries: int = 5, seed: int = None) -&gt; np.ndarray:\n    &quot;&quot;&quot;D-optimal design whose last columns are the given fixed covariates, one run per covariate row.&quot;&quot;&quot;\n    covariates = np.atleast_2d(covariates)\n    rng = np.random.default_rng(seed)\n    grid = np.linspace(-1.0, 1.0, n_levels)\n    n_runs = len(covariates)\n    best, best_score = None, -np.inf\n    for _ in range(n_tries):\n        controlled = rng.choice(grid, size=(n_runs, n_factors))\n        score = d_efficiency(np.hstack([controlled, covariates]), model=model)\n        improved = True\n        while improved:\n            improved = False\n            for run in range(n_runs):\n                for factor in range(n_factors):\n                    current = controlled[run, factor]\n                    for value in grid:\n                        controlled[run, factor] = value\n                        trial = d_efficiency(np.hstack([controlled, covariates]), model=model)\n                        if trial &gt; score + 1e-12:\n                            score, current, improved = trial, value, True\n                    controlled[run, factor] = current\n        if score &gt; best_score:\n            best, best_score = controlled.copy(), score\n    return np.hstack([best, covariates])\n\n\ndrift = np.linspace(-1.0, 1.0, 8).reshape(-1, 1)\nprint(covariate_exchange(drift, n_factors=2, model='linear', n_levels=3, n_tries=3, seed=4))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">covariate_exchange<\/span>(<span class=\"pl-s1\">covariates<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>,\n                       <span class=\"pl-s1\">n_tries<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"D-optimal design whose last columns are the given fixed covariates, one run per covariate row.\"\"\"<\/span>\n    <span class=\"pl-s1\">covariates<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">atleast_2d<\/span>(<span class=\"pl-s1\">covariates<\/span>)\n    <span class=\"pl-s1\">rng<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">random<\/span>.<span class=\"pl-c1\">default_rng<\/span>(<span class=\"pl-s1\">seed<\/span>)\n    <span class=\"pl-s1\">grid<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-s1\">n_levels<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">covariates<\/span>)\n    <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">inf<\/span>\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">_<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_tries<\/span>):\n        <span class=\"pl-s1\">controlled<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">rng<\/span>.<span class=\"pl-c1\">choice<\/span>(<span class=\"pl-s1\">grid<\/span>, <span class=\"pl-s1\">size<\/span><span class=\"pl-c1\">=<\/span>(<span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_factors<\/span>))\n        <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-s1\">controlled<\/span>, <span class=\"pl-s1\">covariates<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n        <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">True<\/span>\n        <span class=\"pl-k\">while<\/span> <span class=\"pl-s1\">improved<\/span>:\n            <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">False<\/span>\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">run<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span>):\n                <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">factor<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n                    <span class=\"pl-s1\">current<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">controlled<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93;\n                    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">value<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">grid<\/span>:\n                        <span class=\"pl-s1\">controlled<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">value<\/span>\n                        <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-s1\">controlled<\/span>, <span class=\"pl-s1\">covariates<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n                        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1e-12<\/span>:\n                            <span class=\"pl-s1\">score<\/span>, <span class=\"pl-s1\">current<\/span>, <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">trial<\/span>, <span class=\"pl-s1\">value<\/span>, <span class=\"pl-c1\">True<\/span>\n                    <span class=\"pl-s1\">controlled<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">current<\/span>\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">best_score<\/span>:\n            <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">controlled<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-s1\">score<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">covariates<\/span>&#93;)\n\n\n<span class=\"pl-s1\">drift<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">8<\/span>).<span class=\"pl-c1\">reshape<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>, <span class=\"pl-c1\">1<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">covariate_exchange<\/span>(<span class=\"pl-s1\">drift<\/span>, <span class=\"pl-s1\">n_factors<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_levels<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">4<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1.     -1.     -1.    ]\n [ 1.     -1.     -0.7143]\n [ 1.      1.     -0.4286]\n [-1.      1.     -0.1429]\n [-1.      1.      0.1429]\n [ 1.      1.      0.4286]\n [ 1.     -1.      0.7143]\n [-1.     -1.      1.    ]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1.     -1.     -1.    &#93;\n &#91; 1.     -1.     -0.7143&#93;\n &#91; 1.      1.     -0.4286&#93;\n &#91;-1.      1.     -0.1429&#93;\n &#91;-1.      1.      0.1429&#93;\n &#91; 1.      1.      0.4286&#93;\n &#91; 1.     -1.      0.7143&#93;\n &#91;-1.     -1.      1.    &#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Categorical Factors<\/h4><a id=\"user-content-categorical-factors\" class=\"anchor\" aria-label=\"Permalink: Categorical Factors\" href=\"#categorical-factors\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The effect coding and row exchange of section 8.5, with the chosen runs mapped back to their levels and sorted.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef effect_code(levels: np.ndarray, n_levels: int) -&gt; np.ndarray:\n    &quot;&quot;&quot;Effect coding of one categorical factor into n_levels - 1 columns.&quot;&quot;&quot;\n    levels = np.asarray(levels, dtype=int)\n    if levels.min() &lt; 0 or levels.max() &gt;= n_levels:\n        raise ValueError(f&quot;levels must lie in 0..{n_levels - 1}; got range {levels.min()}..{levels.max()}&quot;)\n    coded = np.zeros((len(levels), n_levels - 1))\n    for column in range(n_levels - 1):\n        coded[levels == column, column] = 1.0\n    coded[levels == n_levels - 1, :] = -1.0\n    return coded\n\n\nlevels = np.array(list(itertools.product(range(3), repeat=3)))[:, ::-1]\ncoded = np.hstack([effect_code(levels[:, k], 3) for k in range(3)])\nselected = row_exchange(coded, n_runs=9, model='linear', n_tries=5, seed=7)\nchosen = np.array([levels[int(np.where((coded == r).all(axis=1))[0][0])] for r in selected])\nprint(chosen[np.lexsort((chosen[:, 2], chosen[:, 1], chosen[:, 0]))])\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">effect_code<\/span>(<span class=\"pl-s1\">levels<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Effect coding of one categorical factor into n_levels - 1 columns.\"\"\"<\/span>\n    <span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">asarray<\/span>(<span class=\"pl-s1\">levels<\/span>, <span class=\"pl-s1\">dtype<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">int<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">min<\/span>() <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">0<\/span> <span class=\"pl-c1\">or<\/span> <span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">max<\/span>() <span class=\"pl-c1\">&gt;=<\/span> <span class=\"pl-s1\">n_levels<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"levels must lie in 0..<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span><span class=\"pl-kos\">}<\/span><\/span>; got range <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">min<\/span>()<span class=\"pl-kos\">}<\/span><\/span>..<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">max<\/span>()<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">coded<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">levels<\/span>), <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>))\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">column<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>):\n        <span class=\"pl-s1\">coded<\/span>&#91;<span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s1\">column<\/span>, <span class=\"pl-s1\">column<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">1.0<\/span>\n    <span class=\"pl-s1\">coded<\/span>&#91;<span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>, :&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">coded<\/span>\n\n\n<span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(<span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">product<\/span>(<span class=\"pl-en\">range<\/span>(<span class=\"pl-c1\">3<\/span>), <span class=\"pl-s1\">repeat<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>)))&#91;:, ::<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>&#93;\n<span class=\"pl-s1\">coded<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-en\">effect_code<\/span>(<span class=\"pl-s1\">levels<\/span>&#91;:, <span class=\"pl-s1\">k<\/span>&#93;, <span class=\"pl-c1\">3<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">k<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-c1\">3<\/span>)&#93;)\n<span class=\"pl-s1\">selected<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-s1\">coded<\/span>, <span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">9<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">7<\/span>)\n<span class=\"pl-s1\">chosen<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(&#91;<span class=\"pl-s1\">levels<\/span>&#91;<span class=\"pl-en\">int<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">where<\/span>((<span class=\"pl-s1\">coded<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s1\">r<\/span>).<span class=\"pl-c1\">all<\/span>(<span class=\"pl-s1\">axis<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>))&#91;<span class=\"pl-c1\">0<\/span>&#93;&#91;<span class=\"pl-c1\">0<\/span>&#93;)&#93; <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">r<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">selected<\/span>&#93;)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">lexsort<\/span>((<span class=\"pl-s1\">chosen<\/span>&#91;:, <span class=\"pl-c1\">2<\/span>&#93;, <span class=\"pl-s1\">chosen<\/span>&#91;:, <span class=\"pl-c1\">1<\/span>&#93;, <span class=\"pl-s1\">chosen<\/span>&#91;:, <span class=\"pl-c1\">0<\/span>&#93;))&#93;)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[0 0 1]\n [0 1 0]\n [0 2 2]\n [1 0 0]\n [1 1 2]\n [1 2 1]\n [2 0 2]\n [2 1 1]\n [2 2 0]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;0 0 1&#93;\n &#91;0 1 0&#93;\n &#91;0 2 2&#93;\n &#91;1 0 0&#93;\n &#91;1 1 2&#93;\n &#91;1 2 1&#93;\n &#91;2 0 2&#93;\n &#91;2 1 1&#93;\n &#91;2 2 0&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Candidate Sets<\/h4><a id=\"user-content-candidate-sets\" class=\"anchor\" aria-label=\"Permalink: Candidate Sets\" href=\"#candidate-sets\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Builds the cubic grid of section 8.6 and chooses six runs for a quadratic model in two factors.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef candidate_set(n_factors: int, n_levels: int = 3) -&gt; np.ndarray:\n    &quot;&quot;&quot;Candidate set: the full factorial of n_levels values spanning [-1, 1] in every factor.&quot;&quot;&quot;\n    if n_levels &lt; 2:\n        raise ValueError(f&quot;n_levels must be at least 2; got {n_levels}&quot;)\n    grid = np.linspace(-1.0, 1.0, n_levels)\n    return np.array(list(itertools.product(grid, repeat=n_factors)))[:, ::-1]\n\n\nselected = row_exchange(candidate_set(2, n_levels=3), n_runs=6, model='quadratic', n_tries=5, seed=2)\nprint(selected)\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">candidate_set<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Candidate set: the full factorial of n_levels values spanning &#91;-1, 1&#93; in every factor.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_levels must be at least 2; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_levels<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">grid<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-s1\">n_levels<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(<span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">product<\/span>(<span class=\"pl-s1\">grid<\/span>, <span class=\"pl-s1\">repeat<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">n_factors<\/span>)))&#91;:, ::<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>&#93;\n\n\n<span class=\"pl-s1\">selected<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-en\">candidate_set<\/span>(<span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">n_levels<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>), <span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">6<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">selected<\/span>)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[ 1.  1.]\n [-1.  1.]\n [ 0.  1.]\n [-1. -1.]\n [ 1.  0.]\n [ 1. -1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91; 1.  1.&#93;\n &#91;-1.  1.&#93;\n &#91; 0.  1.&#93;\n &#91;-1. -1.&#93;\n &#91; 1.  0.&#93;\n &#91; 1. -1.&#93;&#93;\n<\/code><\/pre><\/div>\n<\/article><\/div><\/div><\/p>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-kadence-tab kt-tab-inner-content kt-inner-tab-2 kt-inner-tab6913_8626db-b9\"><div class=\"kt-tab-inner-content-inner\"><p><div class=\"github-readme-container markdown-body\"><div id=\"file\" class=\"md\" data-path=\"DOE\/design-of-experiments-ko.md\"><article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><div class=\"markdown-heading\" dir=\"auto\"><h1 class=\"heading-element\" dir=\"auto\">Design of Experiments<\/h1><a id=\"user-content-design-of-experiments\" class=\"anchor\" aria-label=\"Permalink: Design of Experiments\" href=\"#design-of-experiments\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Version 12 | Created: 2026-09-04 | Updated: 2026-11-07 13:46 UTC<\/p>\n<ul dir=\"auto\">\n<li><a href=\"#1-purpose\">1. Purpose<\/a><\/li>\n<li><a href=\"#2-summary\">2. Summary<\/a><\/li>\n<li><a href=\"#3-taxonomy-and-its-hierarchy\">3. Taxonomy and its Hierarchy<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#31-comparison\">3.1 Comparison<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#4-principle\">4. Principle<\/a><\/li>\n<li><a href=\"#5-full-factorial-designs\">5. Full Factorial Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#51-multilevel-designs\">5.1 Multilevel Designs<\/a><\/li>\n<li><a href=\"#52-two-level-designs\">5.2 Two-Level Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#6-fractional-factorial-designs\">6. Fractional Factorial Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#61-confounding-and-resolution\">6.1 Confounding and Resolution<\/a><\/li>\n<li><a href=\"#62-plackett-burman-designs\">6.2 Plackett-Burman Designs<\/a><\/li>\n<li><a href=\"#63-general-fractional-designs\">6.3 General Fractional Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#7-response-surface-designs\">7. Response Surface Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#71-quadratic-model\">7.1 Quadratic Model<\/a><\/li>\n<li><a href=\"#72-central-composite-designs\">7.2 Central Composite Designs<\/a><\/li>\n<li><a href=\"#73-box-behnken-designs\">7.3 Box-Behnken Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#8-d-optimal-designs\">8. D-Optimal Designs<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#81-d-efficiency\">8.1 D-Efficiency<\/a><\/li>\n<li><a href=\"#82-generating-d-optimal-designs\">8.2 Generating D-Optimal Designs<\/a><\/li>\n<li><a href=\"#83-augmenting-d-optimal-designs\">8.3 Augmenting D-Optimal Designs<\/a><\/li>\n<li><a href=\"#84-specifying-fixed-covariate-factors\">8.4 Specifying Fixed Covariate Factors<\/a><\/li>\n<li><a href=\"#85-specifying-categorical-factors\">8.5 Specifying Categorical Factors<\/a><\/li>\n<li><a href=\"#86-specifying-candidate-sets\">8.6 Specifying Candidate Sets<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#references\">References<\/a><\/li>\n<li><a href=\"#appendix-a-terminology\">Appendix A. Terminology<\/a><\/li>\n<li><a href=\"#appendix-b-python-implementation\">Appendix B. Python Implementation<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#b1-common-header\">B.1 Common Header<\/a><\/li>\n<li><a href=\"#b2-full-factorial-designs\">B.2 Full Factorial Designs<\/a><\/li>\n<li><a href=\"#b3-fractional-factorial-designs\">B.3 Fractional Factorial Designs<\/a><\/li>\n<li><a href=\"#b4-response-surface-designs\">B.4 Response Surface Designs<\/a><\/li>\n<li><a href=\"#b5-d-optimal-designs\">B.5 D-Optimal Designs<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">1. Purpose<\/h2><a id=\"user-content-1-purpose\" class=\"anchor\" aria-label=\"Permalink: 1. Purpose\" href=\"#1-purpose\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li><strong>Problem Statement<\/strong>: \uc218\ub3d9\uc801\uc73c\ub85c \ubaa8\uc740 \uc790\ub8cc\uc5d0\uc11c\ub294 \uc5ec\ub7ec factor \uac00 \ubc18\uc751\uc758 \uac19\uc740 \ubcc0\ud654\ub97c \ud568\uaed8 \uc124\uba85\ud558\ubbc0\ub85c, \uadf8 \uc790\ub8cc\uc5d0 \ub9de\ucd98 model \uc774 factor \ub9c8\ub2e4\uc758 \ud6a8\uacfc\ub97c \uac08\ub77c\ub0b4\uc9c0 \ubabb\ud55c\ub2e4.<\/li>\n<li><strong>Goal<\/strong>: DOE User's Guide \ub97c \ub9cc\ub4e0\ub2e4. \ub2e4 \uc77d\uc740 \ub3c5\uc790\uac00 \ubaa9\ud45c model, run \uc608\uc0b0, factor \uacf5\uac04\uc758 \uc81c\uc57d\uc5d0 \ub9de\ub294 design \uc744 \uace0\ub974\uace0 \uadf8 design \uc758 \uac00\uc815\uacfc \ud55c\uacc4\ub97c \ub9d0\ud560 \uc218 \uc788\uc5b4\uc57c \ud55c\ub2e4.<\/li>\n<li><strong>Non-Goal<\/strong>: \uc2e4\ud5d8\uc744 \ub9c8\uce5c \ub4a4\uc758 \ubd84\uc11d (ANOVA, model \uc801\ud569\uacfc \uac80\uc815) \uacfc \ud2b9\uc815 software \uc758 \uc0ac\uc6a9\ubc95\uc740 \ub2e4\ub8e8\uc9c0 \uc54a\ub294\ub2e4.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">2. Summary<\/h2><a id=\"user-content-2-summary\" class=\"anchor\" aria-label=\"Permalink: 2. Summary\" href=\"#2-summary\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\uc2e4\ud5d8\uacc4\ud68d\uc740 run \uc608\uc0b0 \uc548\uc5d0\uc11c \uacc4\uc218 \ucd94\uc815\uac12\uc758 \uacf5\ubd84\uc0b0\uc774 \uc791\uc544\uc9c0\ub3c4\ub85d design matrix \uc758 \ud589\uc744 \uace0\ub974\ub294 \uc77c\uc774\ub2e4.\nDesign \uc740 \ubaa9\ud45c model \ub85c \uace0\ub978\ub2e4. \ubaa8\ub4e0 \ud6a8\uacfc\ub294 full factorial, \ub9ce\uc740 factor \uc758 screening \uc740 fractional factorial,\n\uace1\ub960\uc774 \uc788\ub294 \ucd5c\uc801\ud654\ub294 response surface design, \ubd88\uaddc\uce59\ud55c \uc608\uc0b0\u00b7\uc81c\uc57d\u00b7covariate \ub294 D-optimal design \uc774 \ub9e1\ub294\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">3. Taxonomy and its Hierarchy<\/h2><a id=\"user-content-3-taxonomy-and-its-hierarchy\" class=\"anchor\" aria-label=\"Permalink: 3. Taxonomy and its Hierarchy\" href=\"#3-taxonomy-and-its-hierarchy\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Design \uacc4\uc5f4\uc740 model \uc5d0 \ub450\ub294 \uac00\uc815\uc73c\ub85c \uac08\ub9ac\uba70, \uac00\uc815\uc774 \uac15\ud560\uc218\ub85d run \uc774 \uc801\uac8c \ub4e0\ub2e4. \uc774 \ubb38\uc11c\ub294 MathWorks Statistics and\nMachine Learning Toolbox \uac00 \ub098\ub204\ub294 \ub124 \uacc4\uc5f4\uc744 \ub530\ub978\ub2e4 [<a href=\"#ref-1\">1<\/a>].<\/p>\n<p dir=\"auto\">Design \uc744 \uac00\ub974\ub294 \ub2e4\uc12f \ucd95\uc740 <a href=\"#fig-1\">Fig 1<\/a> \uacfc \uac19\ub2e4.<\/p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Axis               Values\n-----------------  ----------------------------------------------------------------------\nTarget model       all effects | main effects + some interactions | main effects only\n                   | full quadratic | any stated model\nLevels per factor  2 | 3 | any\nRun count          product of levels | power of 2 | multiple of 4 | set by geometry | any\nFactor space       regular cube | constrained region\nFactor type        continuous and set | categorical | recorded covariate\"><pre lang=\"text\" class=\"notranslate\"><code>Axis               Values\n-----------------  ----------------------------------------------------------------------\nTarget model       all effects | main effects + some interactions | main effects only\n                   | full quadratic | any stated model\nLevels per factor  2 | 3 | any\nRun count          product of levels | power of 2 | multiple of 4 | set by geometry | any\nFactor space       regular cube | constrained region\nFactor type        continuous and set | categorical | recorded covariate\n<\/code><\/pre><\/div>\n<p dir=\"auto\"><a id=\"user-content-fig-1\"><\/a>\nFig 1. Axes of the design taxonomy<\/p>\n<p dir=\"auto\">\ub2e4\uc12f \ucd95\uc740 \uc11c\ub85c \ub3c5\ub9bd\uc774\ub2e4. \ubaa9\ud45c model \uc774 \uac19\uc740 \uc644\uc804 \uc774\ucc28 model \uc774\uc5b4\ub3c4 factor \uacf5\uac04\uc774 \uc815\uc721\uba74\uccb4\uc774\uba74 response surface\ndesign \uc744 \uc4f0\uace0, \uc81c\uc57d\uc774 \uc788\ub294 \uc601\uc5ed\uc774\uba74 D-optimal design \uc744 \uc4f4\ub2e4.<\/p>\n<p dir=\"auto\">\uac01 design \uc774 model \uc5d0 \ub450\ub294 \uac00\uc815\uacfc \uadf8 \ub300\uac00\ub294 <a href=\"#fig-2\">Fig 2<\/a> \uc758 \uacc4\uce35\uc744 \ub530\ub978\ub2e4.<\/p>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"Family \/ design          Assumes                              Gives up\n-----------------------  -----------------------------------  ---------------------------------------\nFull factorial           nothing about the model              small run count: N1 x ... x Nk runs\n+- General fractional    high-order interactions are small    separation of confounded effects\n   +- Plackett-Burman    only main effects matter             every interaction (resolution III)\nResponse surface         response is at most quadratic        terms above second order\n+- Central composite     settings at +\/-alpha are reachable   fewest runs: embeds a full 2^k\n+- Box-Behnken           three or more factors                corner runs and an embedded factorial\nD-optimal                the stated model is correct          regular geometry and orthogonality\"><pre lang=\"text\" class=\"notranslate\"><code>Family \/ design          Assumes                              Gives up\n-----------------------  -----------------------------------  ---------------------------------------\nFull factorial           nothing about the model              small run count: N1 x ... x Nk runs\n+- General fractional    high-order interactions are small    separation of confounded effects\n   +- Plackett-Burman    only main effects matter             every interaction (resolution III)\nResponse surface         response is at most quadratic        terms above second order\n+- Central composite     settings at +\/-alpha are reachable   fewest runs: embeds a full 2^k\n+- Box-Behnken           three or more factors                corner runs and an embedded factorial\nD-optimal                the stated model is correct          regular geometry and orthogonality\n<\/code><\/pre><\/div>\n<p dir=\"auto\"><a id=\"user-content-fig-2\"><\/a>\nFig 2. Hierarchy of design families<\/p>\n<p dir=\"auto\">Full factorial \uc5d0\uc11c \ud55c \ub2e8\uacc4 \ub0b4\ub824\uac08 \ub54c\ub9c8\ub2e4 model \uc5d0 \ub450\ub294 \uac00\uc815\uc774 \ub298\uace0 run \uc218\uac00 \uc900\ub2e4. General fractional design \uc740\n\uace0\ucc28 \uad50\ud638\uc791\uc6a9\uc744, Plackett-Burman design \uc740 \ubaa8\ub4e0 \uad50\ud638\uc791\uc6a9\uc744 \uc791\ub2e4\uace0 \ubcf4\ub294 \ub300\uac00\ub85c run \uc744 \uc904\uc778\ub2e4. Response surface\n\uacc4\uc5f4\uc740 model \uc758 \ucc28\uc218\ub97c \uc774\ucc28\ub85c \ubb36\uace0 \uc138 \ubc88\uc9f8 \uc218\uc900\uc744 \ub354\ud574 \uace1\ub960\uc744 \ucd94\uc815\ud55c\ub2e4. D-optimal design \uc740 \uba85\uc2dc\ud55c model \ud558\ub098\uc5d0\n\ub9de\ucdb0 run \uc744 \uace0\ub974\ubbc0\ub85c \uc815\uc721\uba74\uccb4 \ubaa8\uc591\uc758 factor \uacf5\uac04\ub3c4, \uc815\ud574\uc9c4 run \uc218\ub3c4 \uc694\uad6c\ud558\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.1 Comparison<\/h3><a id=\"user-content-31-comparison\" class=\"anchor\" aria-label=\"Permalink: 3.1 Comparison\" href=\"#31-comparison\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Design \uc744 \uace0\ub974\ub294 \uae30\uc900\uc740 Table 1 \uc774\ub2e4.<\/p>\n<p dir=\"auto\">Table 1. Comparison of designs<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Design<\/th>\n<th align=\"center\">Model aimed at<\/th>\n<th align=\"center\">Run count<\/th>\n<th align=\"center\">Use when<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">Full factorial<\/td>\n<td align=\"center\">\ubaa8\ub4e0 \ud6a8\uacfc\uc640 \uad50\ud638\uc791\uc6a9<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$N_1 \\times \\cdots \\times N_k$<\/math-renderer><\/td>\n<td align=\"center\">factor \uac00 \uc801\uace0 \ubaa8\ub4e0 \uc870\ud569\uc744 \uac10\ub2f9\ud560 \uc218 \uc788\ub2e4<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">General fractional<\/td>\n<td align=\"center\">\uc8fc\ud6a8\uacfc\uc640 \uc77c\ubd80 \uad50\ud638\uc791\uc6a9<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^{b}$<\/math-renderer><\/td>\n<td align=\"center\">\ub9ce\uc740 factor \ub97c screening \ud558\uba70 resolution \uc744 \uace0\ub978\ub2e4<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Plackett-Burman<\/td>\n<td align=\"center\">\uc8fc\ud6a8\uacfc<\/td>\n<td align=\"center\">\n<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$k$<\/math-renderer> \ubcf4\ub2e4 \ud070 \uac00\uc7a5 \uc791\uc740 4 \uc758 \ubc30\uc218<\/td>\n<td align=\"center\">\uc8fc\ud6a8\uacfc\ub9cc \ubcf4\ub294 screening \uc5d0 2 \uc758 \uac70\ub4ed\uc81c\uacf1 \uc0ac\uc774 run \uc218\uac00 \ud544\uc694\ud558\ub2e4<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Central composite<\/td>\n<td align=\"center\">\uc644\uc804 \uc774\ucc28 model<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^k + 2k + n_c$<\/math-renderer><\/td>\n<td align=\"center\">\uc54c\ub824\uc9c4 \uc791\uc5c5\uc810 \uadfc\ucc98\uc5d0\uc11c \ucd5c\uc801\ud654\ud55c\ub2e4<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">Box-Behnken<\/td>\n<td align=\"center\">\uc644\uc804 \uc774\ucc28 model<\/td>\n<td align=\"center\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$4\\binom{k}{2} + n_c$<\/math-renderer><\/td>\n<td align=\"center\">\ubaa8\ub4e0 factor \ub97c \ub3d9\uc2dc\uc5d0 \uadf9\ub2e8\uc5d0 \ub458 \uc218 \uc5c6\ub294 \uacf5\uc815\uc744 \ucd5c\uc801\ud654\ud55c\ub2e4<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">D-optimal<\/td>\n<td align=\"center\">\uba85\uc2dc\ud55c \uc784\uc758\uc758 model<\/td>\n<td align=\"center\">\uc608\uc0b0\uc5d0 \ub9de\ucdb0 \uc9c0\uc815<\/td>\n<td align=\"center\">\uc608\uc0b0\uc774 \ubd88\uaddc\uce59\ud558\uac70\ub098 \uc81c\uc57d, covariate, categorical factor \uac00 \uc788\ub2e4<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\"><math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$k$<\/math-renderer> \ub294 factor \uc218, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$b$<\/math-renderer> \ub294 basic factor \uc218, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$n_c$<\/math-renderer> \ub294 centre run \uc218\uc774\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">4. Principle<\/h2><a id=\"user-content-4-principle\" class=\"anchor\" aria-label=\"Permalink: 4. Principle\" href=\"#4-principle\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Design \uc740 \ubc18\uc751\uc744 \uc7ac\uae30 \uc804\uc5d0 \uacc4\uc218 \ucd94\uc815\uc758 \uc815\ubc00\ub3c4\ub97c \uc815\ud55c\ub2e4. \uce21\uc815\ud55c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$n$<\/math-renderer> \uac1c\uc758 \ubc18\uc751 vector \ub97c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\mathbf{y}$<\/math-renderer>, factor\n\uc124\uc815\uc73c\ub85c \ub9cc\ub4e0 model matrix \ub97c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\mathbf{X}$<\/math-renderer>, \uacc4\uc218\ub97c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\boldsymbol{\\beta}$<\/math-renderer> \ub77c \ud558\uba74, \ucd5c\uc18c\uc81c\uacf1\ucd94\uc815\ub7c9\uacfc \uadf8 \uacf5\ubd84\uc0b0\uc740\n\uc2dd (1) \uacfc \uac19\ub2e4.<\/p>\n<math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$$\\hat{\\boldsymbol{\\beta}} = \\left( \\mathbf{X}^{\\top}\\mathbf{X} \\right)^{-1} \\mathbf{X}^{\\top}\\mathbf{y}, \\qquad \\mathrm{Cov}\\left[ \\hat{\\boldsymbol{\\beta}} \\right] = \\sigma^{2} \\left( \\mathbf{X}^{\\top}\\mathbf{X} \\right)^{-1} \\hspace{19em} (1)$$<\/math-renderer>\n<p dir=\"auto\">\uc2dd (1) \uc758 \uacf5\ubd84\uc0b0\uc5d0\ub294 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\mathbf{y}$<\/math-renderer> \uac00 \uc5c6\uc73c\ubbc0\ub85c, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\sigma^2$<\/math-renderer> \uc774 \uc8fc\uc5b4\uc9c0\uba74 design \ub9cc\uc73c\ub85c \uc815\ud574\uc9c4\ub2e4. \uacc4\ud68d\ub41c \uc2e4\ud5d8\uc740 factor\n\uac12\uc744 \uc2e4\ud5d8\uc790\uac00 \uc815\ud558\uc5ec factor \ub4e4\uc774 \uc11c\ub85c \ub3c5\ub9bd\uc73c\ub85c \uc6c0\uc9c1\uc774\uac8c \ud558\uace0, \uadf8 \uacb0\uacfc \ubc18\uc751\uc5d0 \ub300\ud55c \uac01 factor \uc758 \ud6a8\uacfc\ub97c \ub530\ub85c\n\ucd94\uc815\ud55c\ub2e4. Design \uacc4\uc5f4\ub4e4\uc740 \uc5b4\ub5a4 model \uc744 \uaca8\ub0e5\ud558\ub294\uc9c0\uc640 run \uc608\uc0b0\uc744 \uc5b4\ub5bb\uac8c \uc4f0\ub294\uc9c0\uc5d0\uc11c \ub2e4\ub974\ub2e4 (Table 1).<\/p>\n<p dir=\"auto\">\uc774 \ubb38\uc11c\uc5d0\uc11c \ub450 \uc218\uc900 factor \ub294 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$-1$<\/math-renderer> \uacfc <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$+1$<\/math-renderer> \ub85c \ubd80\ud638\ud654\ud558\uace0, \uc5f0\uc18d factor \ub294 \uc791\uc5c5 \ubc94\uc704\uac00 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$[-1, 1]$<\/math-renderer> \uc774 \ub418\ub3c4\ub85d \ucc99\ub3c4\ub97c\n\ub9de\ucd98\ub2e4. \uc815\uc758 \uc5c6\uc774 \uc4f4 \uc6a9\uc5b4\ub294 <a href=\"#appendix-a-terminology\">Appendix A<\/a> \uc5d0, \ubaa8\ub4e0 design \uc758 Python \uad6c\ud604\uacfc \ucd9c\ub825\uc740\n<a href=\"#appendix-b-python-implementation\">Appendix B<\/a> \uc5d0 \uc788\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">5. Full Factorial Designs<\/h2><a id=\"user-content-5-full-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: 5. Full Factorial Designs\" href=\"#5-full-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Full factorial design \uc740 factor \uc218\uc900\uc758 \ubaa8\ub4e0 \uc870\ud569\uc5d0\uc11c \ubc18\uc751\uc744 \uc7ac\uc5b4, factor \ub4e4\uc774 \ub9cc\ub4e4 \uc218 \uc788\ub294 \ubaa8\ub4e0 \ud6a8\uacfc\uc640 \uad50\ud638\uc791\uc6a9\uc744\n\ucd94\uc815\ud55c\ub2e4. \uc218\uc900\uc774 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$N_1, \\ldots, N_k$<\/math-renderer> \uc774\uba74 treatment \ub9c8\ub2e4 \ud558\ub098\uc529 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$N_1 \\times \\cdots \\times N_k$<\/math-renderer> \uac1c\uc758 run \uc774 \ub4e0\ub2e4.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>\uac00\uc815<\/strong>: factor \uc640 \uc218\uc900\uc774 \uc801\uc5b4 \ubaa8\ub4e0 \uc870\ud569\uc758 run \uc744 \uac10\ub2f9\ud560 \uc218 \uc788\ub2e4.<\/li>\n<li>\n<strong>\uc124\uc815\uac12<\/strong>: factor \ub9c8\ub2e4\uc758 \uc218\uc900 \uc218 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$N_i$<\/math-renderer>.<\/li>\n<li>\n<strong>\uae68\uc9c0\ub294 \uc870\uac74<\/strong>: factor \uac00 \ub298\uba74 run \uc218\uac00 \uc218\uc900 \uc218\uc758 \uacf1\uc73c\ub85c \ub298\uace0, \ub450 \uc218\uc900\uc774\uc5b4\ub3c4 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^k$<\/math-renderer> \uc774 \uc608\uc0b0\uc744 \ub118\ub294\ub2e4.<\/li>\n<li>\n<strong>\uc4f0\ub294 \uacf3<\/strong>: factor \uac00 \uc801\uc740 \uc2e4\ud5d8, \uadf8\ub9ac\uace0 fractional \uacc4\uc5f4\uacfc response surface \uacc4\uc5f4\uc758 \ucd9c\ubc1c\uc810.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">5.1 Multilevel Designs<\/h3><a id=\"user-content-51-multilevel-designs\" class=\"anchor\" aria-label=\"Permalink: 5.1 Multilevel Designs\" href=\"#51-multilevel-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Factor \ub9c8\ub2e4 \uc218\uc900 \uc218\uac00 \ub2ec\ub77c\ub3c4 \ub41c\ub2e4. Design \uc740 \uc218\uc900 \uc9d1\ud569\ub4e4\uc758 \uacf1\uc9d1\ud569\uc774\uba70, \uccab \uc5f4\uc774 \uac00\uc7a5 \ube68\ub9ac \ubcc0\ud558\ub3c4\ub85d \ub098\uc5f4\ud55c\ub2e4. \ub450\n\uc218\uc900 factor \ud558\ub098\uc640 \uc138 \uc218\uc900 factor \ud558\ub098\ub294 run 6 \uac1c\ub97c \uc900\ub2e4 (<a href=\"#b2-full-factorial-designs\">Appendix B.2<\/a>).<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">5.2 Two-Level Designs<\/h3><a id=\"user-content-52-two-level-designs\" class=\"anchor\" aria-label=\"Permalink: 5.2 Two-Level Designs\" href=\"#52-two-level-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\ubaa8\ub4e0 factor \uac00 \ub450 \uc218\uc900\uc774\uba74 run \uc740 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^k$<\/math-renderer> \uac1c\uc774\ub2e4. \uc5f4\ub4e4\uc774 \uc9c1\uad50\uc774\uace0 \uade0\ud615\uc744 \uc774\ub8e8\ubbc0\ub85c, \ubaa8\ub4e0 \ud6a8\uacfc\ub97c \uc11c\ub85c \ub3c5\ub9bd\uc73c\ub85c, \uadf8\ub9ac\uace0\n\uadf8 run \uc218\uc5d0\uc11c \uac00\ub2a5\ud55c \uac00\uc7a5 \uc791\uc740 \ubd84\uc0b0\uc73c\ub85c \ucd94\uc815\ud55c\ub2e4. Fractional \uacc4\uc5f4\uacfc response surface \uacc4\uc5f4\uc740 \uc774 design \uc5d0\uc11c\n\ucd9c\ubc1c\ud55c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">6. Fractional Factorial Designs<\/h2><a id=\"user-content-6-fractional-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: 6. Fractional Factorial Designs\" href=\"#6-fractional-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Fractional factorial design \uc740 treatment \uc758 \ubd80\ubd84\uc9d1\ud569\ub9cc \uc7ac\ub418, \uc911\uc694\ud558\ub2e4\uace0 \ubcf4\ub294 \ud6a8\uacfc\ub294 \ucd94\uc815\ud560 \uc218 \uc788\ub3c4\ub85d \ubd80\ubd84\uc9d1\ud569\uc744\n\uace0\ub978\ub2e4. Full factorial \uc758 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^k$<\/math-renderer> \uac1c run \uac00\uc6b4\ub370 \ub300\ubd80\ubd84\uc740 \uc880\ucc98\ub7fc \ud06c\uc9c0 \uc54a\uc740 \uace0\ucc28 \uad50\ud638\uc791\uc6a9\uc744 \ucd94\uc815\ud558\ub294 \ub370 \uc4f0\uc778\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">6.1 Confounding and Resolution<\/h3><a id=\"user-content-61-confounding-and-resolution\" class=\"anchor\" aria-label=\"Permalink: 6.1 Confounding and Resolution\" href=\"#61-confounding-and-resolution\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Run \uc744 \uc904\uc778 \ub300\uac00\ub294 confounding \uc774\ub2e4. \ub0a8\uc740 \uac01 \uc5f4\uc740 \uc5ec\ub7ec \ud6a8\uacfc\uc758 \ud569\uc744 \uc9c0\ub2c8\uba70, \uadf8 design \uc73c\ub85c \ud55c \uc2e4\ud5d8\uc740 \uadf8 \ud6a8\uacfc\ub4e4\uc744\n\uac08\ub77c\ub0b4\uc9c0 \ubabb\ud55c\ub2e4. Resolution \uc740 confounding \uc758 \uc815\ub3c4\ub97c \ub098\ud0c0\ub0b4\uba70, defining relation \uc5d0\uc11c \uac00\uc7a5 \uc9e7\uc740 word \uc758 \uae38\uc774\uc774\ub2e4.<\/p>\n<p dir=\"auto\">Table 2. Design resolution [<a href=\"#ref-2\">2<\/a>]<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Resolution<\/th>\n<th align=\"center\">Main effects confounded with<\/th>\n<th align=\"center\">Two-way interactions confounded with<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">III<\/td>\n<td align=\"center\">2\ucc28 \uad50\ud638\uc791\uc6a9<\/td>\n<td align=\"center\">\uc11c\ub85c<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">IV<\/td>\n<td align=\"center\">3\ucc28 \uad50\ud638\uc791\uc6a9<\/td>\n<td align=\"center\">\uc11c\ub85c<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">V<\/td>\n<td align=\"center\">4\ucc28 \uad50\ud638\uc791\uc6a9<\/td>\n<td align=\"center\">3\ucc28 \uad50\ud638\uc791\uc6a9<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">Resolution III \uc740 2\ucc28 \uad50\ud638\uc791\uc6a9\uc774 \uc791\uc544\uc57c \uc8fc\ud6a8\uacfc\ub97c \ubbff\uc744 \uc218 \uc788\uace0, IV \ub294 \uc8fc\ud6a8\uacfc\ub97c 2\ucc28 \uad50\ud638\uc791\uc6a9\uacfc \uac08\ub77c \ucd94\uc815\ud558\uba70, V \ub294\n\uc8fc\ud6a8\uacfc\uc640 2\ucc28 \uad50\ud638\uc791\uc6a9\uc744 \ubaa8\ub450 \ub2e4\ub978 2\ucc28 \uc774\ud558 \ud6a8\uacfc\uc640 \uac08\ub77c \ucd94\uc815\ud55c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">6.2 Plackett-Burman Designs<\/h3><a id=\"user-content-62-plackett-burman-designs\" class=\"anchor\" aria-label=\"Permalink: 6.2 Plackett-Burman Designs\" href=\"#62-plackett-burman-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Plackett-Burman design \uc740 \uc8fc\ud6a8\uacfc\ub9cc \uc720\uc758\ud558\ub2e4\uace0 \ubcfc \ub54c run \uc218\uac00 2 \uc758 \uac70\ub4ed\uc81c\uacf1\uc774 \uc544\ub2c8\ub77c 4 \uc758 \ubc30\uc218\uc778 resolution III\ndesign \uc744 \uc8fc\uc5b4, \ub450 \uc218\uc900 factorial \uc0ac\uc774\uc758 \ube48\ud2c8\uc744 \uba54\uc6b4\ub2e4 [<a href=\"#ref-3\">3<\/a>]. Factor 11 \uac1c\ub97c run 16 \uac1c\uac00 \uc544\ub2c8\ub77c 12 \uac1c\ub85c\nscreening \ud55c\ub2e4.<\/p>\n<p dir=\"auto\">Design \uc740 Hadamard matrix \ub85c \ub9cc\ub4e0\ub2e4. Run \uc218\uac00 2 \uc758 \uac70\ub4ed\uc81c\uacf1\uc774\uba74 Hadamard matrix \uc758 \uc5f4\uc744 \uadf8\ub300\ub85c \uc4f0\uace0, \uc544\ub2c8\uba74\n\uc54c\ub824\uc9c4 generator \ud589\uc758 \uc21c\ud658\ud589\ub82c \uc544\ub798\uc5d0 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$-1$<\/math-renderer> \ub85c \ucc44\uc6b4 \ud589 \ud558\ub098\ub97c \ubd99\uc778\ub2e4. Run 12 \uac1c design \uc758 \uc5f4 11 \uac1c\ub294 \uc11c\ub85c\n\uc9c1\uad50\ud55c\ub2e4 (<a href=\"#b3-fractional-factorial-designs\">Appendix B.3<\/a>).<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>\uac00\uc815<\/strong>: \uad50\ud638\uc791\uc6a9\uc740 \ubb34\uc2dc\ud560 \ub9cc\ud558\uace0 \uc8fc\ud6a8\uacfc\ub9cc \uc720\uc758\ud558\ub2e4.<\/li>\n<li>\n<strong>\uc124\uc815\uac12<\/strong>: factor \uc218 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$k$<\/math-renderer>. Run \uc218\ub294 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$k$<\/math-renderer> \ubcf4\ub2e4 \ud070 \uac00\uc7a5 \uc791\uc740 4 \uc758 \ubc30\uc218\uc774\uba70, \uadf8 \uc218\uac00 2 \uc758 \uac70\ub4ed\uc81c\uacf1\uc774 \uc544\ub2c8\uba74 generator \ud589\uc774 \uc788\uc5b4\uc57c \ud55c\ub2e4.<\/li>\n<li>\n<strong>\uae68\uc9c0\ub294 \uc870\uac74<\/strong>: 2\ucc28 \uad50\ud638\uc791\uc6a9\uc774 \ud06c\uba74 \uc8fc\ud6a8\uacfc\uc640 confound \ub418\uc5b4, \uc8fc\ud6a8\uacfc \ucd94\uc815\uac12\uc774 \uadf8 \uad50\ud638\uc791\uc6a9\uc744 \ud568\uaed8 \uc9c0\ub2cc\ub2e4.<\/li>\n<li>\n<strong>\uc4f0\ub294 \uacf3<\/strong>: \ub9ce\uc740 factor \uc758 screening.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">6.3 General Fractional Designs<\/h3><a id=\"user-content-63-general-fractional-designs\" class=\"anchor\" aria-label=\"Permalink: 6.3 General Fractional Designs\" href=\"#63-general-fractional-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">General fractional design \uc740 basic factor \ub4e4\ub85c \uc774\ub8e8\uc5b4\uc9c4 full factorial \uc5d0\uc11c \ucd9c\ubc1c\ud574, \ub098\uba38\uc9c0 factor \ub97c basic factor\n\uc758 \uacf1\uc73c\ub85c \uc815\uc758\ud55c\ub2e4.<\/p>\n<blockquote>\n<p dir=\"auto\"><strong>Definition: Generator<\/strong><br>\n\ud55c factor \ub97c basic factor \uc758 \uacf1\uc73c\ub85c \uc815\uc758\ud560 \ub54c, \uadf8 \uacf1\uc744 \uadf8 factor \uc758 generator \ub77c \ud55c\ub2e4.<\/p>\n<\/blockquote>\n<p dir=\"auto\">Generator \uac00 design \uacfc \uadf8 confounding \uc744 \ud568\uaed8 \uc815\ud55c\ub2e4. Generator <code>a b c abc<\/code> \ub294 factor 4 \uac1c\ub97c full factorial \uc774 \uc694\uad6c\ud558\ub294 16 \uac1c\uc758 \uc808\ubc18\uc778 run 8 \uac1c\ub85c\n\ub2e4\ub8ec\ub2e4.<\/p>\n<p dir=\"auto\">Defining relation \uc740 generator \uac00 \ud568\uc758\ud558\ub294 word \ub4e4\uc774 \uc0dd\uc131\ud558\uba70, resolution \uc740 \uadf8 word \ub4e4\uc774 \uc0dd\uc131\ud558\ub294 \ubd80\ubd84\uad70\uc5d0\uc11c\n\uac00\uc7a5 \uc9e7\uc740 word \uc758 \uae38\uc774\uc774\ub2e4. \ub124 generator \uc9d1\ud569\uc758 resolution \uc740 Table 3 \uc774\ub2e4.<\/p>\n<p dir=\"auto\">Table 3. Resolution of four generator sets<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Generators<\/th>\n<th align=\"center\">Runs<\/th>\n<th align=\"center\">Resolution<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">a b ab<\/td>\n<td align=\"center\">4<\/td>\n<td align=\"center\">III<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">a b c ab<\/td>\n<td align=\"center\">8<\/td>\n<td align=\"center\">III<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">a b c abc<\/td>\n<td align=\"center\">8<\/td>\n<td align=\"center\">IV<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">a b c d abcd<\/td>\n<td align=\"center\">16<\/td>\n<td align=\"center\">V<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">Run 8 \uac1c\uc9dc\ub9ac \ub450 design \uc740 \ube44\uc6a9\uc774 \uac19\uace0 generator \ub9cc \ub2e4\ub974\uc9c0\ub9cc, <code>a b c ab<\/code> \ub294 \uc8fc\ud6a8\uacfc\ub97c 2\ucc28 \uad50\ud638\uc791\uc6a9\uacfc confound\n\uc2dc\ud0a4\uace0 <code>a b c abc<\/code> \ub294 \uadf8\ub7ec\uc9c0 \uc54a\ub294\ub2e4. \uac19\uc740 run \uc218\uc5d0\uc11c resolution \uc740 generator \uac00 \uc815\ud55c\ub2e4.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>\uac00\uc815<\/strong>: design \uc758 resolution \uc774 confound \uc2dc\ud0a4\ub294 \uad50\ud638\uc791\uc6a9\uc740 \uc791\ub2e4 (Table 2).<\/li>\n<li>\n<strong>\uc124\uc815\uac12<\/strong>: basic factor \uc218 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$b$<\/math-renderer> (run \uc218 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^{b}$<\/math-renderer>) \uc640 \ub354\ud574\uc9c0\ub294 factor \ub9c8\ub2e4\uc758 generator.<\/li>\n<li>\n<strong>\uae68\uc9c0\ub294 \uc870\uac74<\/strong>: confound \ub41c \uad50\ud638\uc791\uc6a9\uc774 \ud06c\uba74 \uadf8 \uc5f4\uc758 \ucd94\uc815\uac12\uc740 \uc5ec\ub7ec \ud6a8\uacfc\uc758 \ud569\uc774 \ub418\uc5b4, \uc5b4\ub290 \ud6a8\uacfc\uc778\uc9c0 \uac00\ub9b4 \uc218 \uc5c6\ub2e4.<\/li>\n<li>\n<strong>\uc4f0\ub294 \uacf3<\/strong>: \ub9ce\uc740 factor \uc758 screening \uc5d0\uc11c run \uc218\ub97c 2 \uc758 \uac70\ub4ed\uc81c\uacf1\uc73c\ub85c \ub450\uace0 resolution \uc744 \uace8\ub77c\uc57c \ud560 \ub54c.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">7. Response Surface Designs<\/h2><a id=\"user-content-7-response-surface-designs\" class=\"anchor\" aria-label=\"Permalink: 7. Response Surface Designs\" href=\"#7-response-surface-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Response surface design \uc740 \uac01 factor \uc5d0 \uc138 \ubc88\uc9f8 \uc218\uc900\uc744 \ub354\ud574, \uace1\ub960\uc744 \uc9c0\ub2cc \uc644\uc804 \uc774\ucc28 model \uc744 \ub9de\ucd98\ub2e4. \uc911\uc694\ud55c\nfactor \ub97c \uc54c\uace0 \ubaa9\ud45c\uac00 \ucd5c\uc801\ud654\uc774\uba74 model \uc5d0 \uace1\ub960\uc774 \uc788\uc5b4\uc57c \ud55c\ub2e4. \ucd5c\uc801\uc810\uc740 \uc815\ub958\uc810\uc774\uace0, \uc77c\ucc28 model \uc5d0\ub294 \uc815\ub958\uc810\uc774 \uc5c6\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">7.1 Quadratic Model<\/h3><a id=\"user-content-71-quadratic-model\" class=\"anchor\" aria-label=\"Permalink: 7.1 Quadratic Model\" href=\"#71-quadratic-model\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Factor \uac00 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$k$<\/math-renderer> \uac1c\uc778 \uc644\uc804 \uc774\ucc28 model \uc740 \uc2dd (2) \uc774\uba70, \uacc4\uc218\ub294 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$(k+1)(k+2)\/2$<\/math-renderer> \uac1c\uc774\ub2e4.<\/p>\n<math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$$y = \\beta_0 + \\sum_{i=1}^{k} \\beta_i x_i + \\sum_{i \\lt j} \\beta_{ij} x_i x_j + \\sum_{i=1}^{k} \\beta_{ii} x_i^{2} + \\varepsilon \\hspace{19em} (2)$$<\/math-renderer>\n<p dir=\"auto\">\ub450 \uc218\uc900 design \uc73c\ub85c\ub294 \uc2dd (2) \ub97c \ub9de\ucd9c \uc218 \uc5c6\ub2e4. \uc81c\uacf1\ud56d <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$x_i^2$<\/math-renderer> \uc774 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$-1$<\/math-renderer> \uacfc <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$+1$<\/math-renderer> \uc5d0\uc11c \uac19\uc740 \uac12 1 \uc744 \uac16\ub294\ub2e4. \uc544\ub798 \ub450\ndesign \uc740 \uc138 \ubc88\uc9f8 \uc218\uc900\uc744 \uc11c\ub85c \ub2e4\ub978 \ubc29\uc2dd\uc73c\ub85c \ub354\ud55c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">7.2 Central Composite Designs<\/h3><a id=\"user-content-72-central-composite-designs\" class=\"anchor\" aria-label=\"Permalink: 7.2 Central Composite Designs\" href=\"#72-central-composite-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Central composite design \uc740 \uc815\uc721\uba74\uccb4 \uaf2d\uc9d3\uc810\uc758 \ub450 \uc218\uc900 factorial, factor \ucd95 \uc704\uc5d0\uc11c \uc911\uc2ec\uc73c\ub85c\ubd80\ud130 \uac70\ub9ac <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\alpha$<\/math-renderer> \uc778\nstar point, \uadf8\ub9ac\uace0 \ud558\ub098 \uc774\uc0c1\uc758 centre run \uc73c\ub85c \uc774\ub8e8\uc5b4\uc9c4\ub2e4. <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\alpha = (2^k)^{1\/4}$<\/math-renderer> \ub85c \uc7a1\uc73c\uba74 design \uc774 rotatable\n\uc774 \ub418\uc5b4, \uc608\uce21\ubd84\uc0b0\uc774 \ubc29\ud5a5\uacfc \uad00\uacc4\uc5c6\uc774 \uc911\uc2ec\uc73c\ub85c\ubd80\ud130\uc758 \uac70\ub9ac\uc5d0\ub9cc \uc758\uc874\ud55c\ub2e4.<\/p>\n<p dir=\"auto\">\uc138 \ubcc0\ud615\uc740 star point \ub97c \ub450\ub294 \uc704\uce58\uc5d0\uc11c \ub2e4\ub974\ub2e4.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>Circumscribed<\/strong>: star point \ub97c \uc815\uc721\uba74\uccb4 \ubc14\uae65 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\pm\\alpha$<\/math-renderer> \uc5d0 \ub450\ubbc0\ub85c, \ub450 \uc218\uc900 \ubc94\uc704\ub97c \ub118\ub294 factor \uc124\uc815\uc774 \ud544\uc694\ud558\ub2e4.<\/li>\n<li>\n<strong>Faced<\/strong>: <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\alpha = 1$<\/math-renderer> \ub85c \ud558\uc5ec star point \ub97c \uc815\uc721\uba74\uccb4\uc758 \uba74 \uc704\uc5d0 \ub454\ub2e4.<\/li>\n<li>\n<strong>Inscribed<\/strong>: circumscribed \uc758 \ubaa8\uc591\uc744 \uc720\uc9c0\ud558\ub418, \uaf2d\uc9d3\uc810\uc774 \uc544\ub2c8\ub77c star point \uac00 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\pm 1$<\/math-renderer> \uc5d0 \uc624\ub3c4\ub85d \ucc99\ub3c4\ub97c \uc904\uc778\ub2e4.<\/li>\n<\/ul>\n<p dir=\"auto\">Factor 2 \uac1c\uc640 centre run 1 \uac1c\uc758 circumscribed design \uc740 run 9 \uac1c\uc774\uba70, star point \ub294 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\pm 1.4142$<\/math-renderer> \uc5d0 \ub193\uc778\ub2e4\n(<a href=\"#b4-response-surface-designs\">Appendix B.4<\/a>).<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>\uac00\uc815<\/strong>: \uc791\uc5c5\uc810 \uadfc\ucc98\uc5d0\uc11c \ubc18\uc751\uc774 \uc644\uc804 \uc774\ucc28 model \ub85c \uadfc\uc0ac\ub418\uace0, factor \uac00 2 \uac1c \uc774\uc0c1\uc774\ub2e4.<\/li>\n<li>\n<strong>\uc124\uc815\uac12<\/strong>: <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\alpha$<\/math-renderer> (rotatable \uc774\uba74 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$(2^k)^{1\/4}$<\/math-renderer>, faced \uc774\uba74 1), \ubcc0\ud615, centre run \uc218 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$n_c \\ge 1$<\/math-renderer>. Run \uc218\ub294 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^k + 2k + n_c$<\/math-renderer>.<\/li>\n<li>\n<strong>\uae68\uc9c0\ub294 \uc870\uac74<\/strong>: \uacf5\uc815\uc774 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\pm\\alpha$<\/math-renderer> \uc124\uc815\uc744 \ub0bc \uc218 \uc5c6\uc73c\uba74 circumscribed design \uc744 \uc4f8 \uc218 \uc5c6\uc5b4, faced \ub098 inscribed \ub85c \ubc14\uafbc\ub2e4.<\/li>\n<li>\n<strong>\uc4f0\ub294 \uacf3<\/strong>: \uc54c\ub824\uc9c4 \uc791\uc5c5\uc810 \uadfc\ucc98\uc5d0\uc11c\uc758 \ucd5c\uc801\ud654.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">7.3 Box-Behnken Designs<\/h3><a id=\"user-content-73-box-behnken-designs\" class=\"anchor\" aria-label=\"Permalink: 7.3 Box-Behnken Designs\" href=\"#73-box-behnken-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Box-Behnken design \uc740 \uc644\uc804 \uc774\ucc28 model \uc744 \ub9de\ucd94\uba74\uc11c \ub450 factor \ub97c \ub3d9\uc2dc\uc5d0 \uadf9\ub2e8\uc5d0 \ub450\uc9c0 \uc54a\ub294\ub2e4 [<a href=\"#ref-4\">4<\/a>]. Factor\n\uc9dd\ub9c8\ub2e4 \ub450 \uc218\uc900 factorial \uc744 \ub450\uace0 \ub098\uba38\uc9c0 factor \ub294 \uc911\uc2ec\uc5d0 \ub450\ubbc0\ub85c, \uc810\ub4e4\uc774 design \uacf5\uac04\uc758 \ubaa8\uc11c\ub9ac \uc911\uc810\uacfc \uc911\uc2ec\uc5d0\n\ub193\uc778\ub2e4. \uc815\uc721\uba74\uccb4\uc758 \uaf2d\uc9d3\uc810\uc774 \ube60\uc838 \ubaa8\ub4e0 factor \uc758 \uadf9\ub2e8\uc744 \ubb36\uc740 run \uc774 \uc5c6\uace0, \uc548\uc5d0 \ubc15\ud78c factorial design \ub3c4 \uc5c6\ub2e4.<\/p>\n<p dir=\"auto\">Table 4. Run counts of the two response surface designs, three centre runs each<\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th align=\"center\">Factors<\/th>\n<th align=\"center\">Quadratic terms<\/th>\n<th align=\"center\">Box-Behnken<\/th>\n<th align=\"center\">Central composite<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"center\">3<\/td>\n<td align=\"center\">10<\/td>\n<td align=\"center\">15<\/td>\n<td align=\"center\">17<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">4<\/td>\n<td align=\"center\">15<\/td>\n<td align=\"center\">27<\/td>\n<td align=\"center\">27<\/td>\n<\/tr>\n<tr>\n<td align=\"center\">5<\/td>\n<td align=\"center\">21<\/td>\n<td align=\"center\">43<\/td>\n<td align=\"center\">45<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">\uc9dd \ub2e8\uc704 \uad6c\uc131\uc740 factor 3 \uac1c\uc5d0\uc11c 5 \uac1c\uae4c\uc9c0 \ubc1c\ud45c\ub41c Box-Behnken design \uc744 \uadf8\ub300\ub85c \uc7ac\ud604\ud55c\ub2e4. 5 \uac1c\ub97c \ub118\uc73c\uba74 \ubc1c\ud45c\ub41c\ndesign \uc740 balanced incomplete block design \uc744 \uc368\uc11c \ubaa8\ub4e0 \uc9dd\uc744 \ucc28\ub840\ub85c \ub3c4\ub294 \uad6c\uc131\ubcf4\ub2e4 \uc791\ub2e4. \uc9dd \ub2e8\uc704 \uad6c\uc131\uc740 \uadf8\ub54c\ub3c4\n\ud0c0\ub2f9\ud558\uc9c0\ub9cc \ucd5c\uc18c\uac00 \uc544\ub2c8\ub2e4.<\/p>\n<ul dir=\"auto\">\n<li>\n<strong>\uac00\uc815<\/strong>: \ubc18\uc751\uc774 \uc644\uc804 \uc774\ucc28 model \ub85c \uadfc\uc0ac\ub418\uace0, factor \uac00 3 \uac1c \uc774\uc0c1\uc774\ub2e4.<\/li>\n<li>\n<strong>\uc124\uc815\uac12<\/strong>: centre run \uc218 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$n_c$<\/math-renderer> (Appendix B \uad6c\ud604\uc758 \uae30\ubcf8\uac12 3). Run \uc218\ub294 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$4\\binom{k}{2} + n_c$<\/math-renderer>.<\/li>\n<li>\n<strong>\uae68\uc9c0\ub294 \uc870\uac74<\/strong>: factor \uac00 5 \uac1c\ub97c \ub118\uc73c\uba74 \uc9dd \ub2e8\uc704 \uad6c\uc131\uc740 \ucd5c\uc18c run \uc218\ub97c \uc8fc\uc9c0 \ubabb\ud55c\ub2e4.<\/li>\n<li>\n<strong>\uc4f0\ub294 \uacf3<\/strong>: \ubaa8\ub4e0 factor \ub97c \ub3d9\uc2dc\uc5d0 \uadf9\ub2e8\uc5d0 \ub458 \uc218 \uc5c6\ub294 \uacf5\uc815\uc758 \ucd5c\uc801\ud654.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">8. D-Optimal Designs<\/h2><a id=\"user-content-8-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: 8. D-Optimal Designs\" href=\"#8-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">D-optimal design \uc740 model \uacfc run \uc608\uc0b0\uc744 \uc8fc\uc5b4\uc9c4 \uac83\uc73c\ub85c \ubc1b\uace0, \uc815\ubcf4\ud589\ub82c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\mathbf{X}^{\\top}\\mathbf{X}$<\/math-renderer> \uc758 \ud589\ub82c\uc2dd\uc744\n\ucd5c\ub300\ub85c \ud558\uc5ec \uacc4\uc218\uc758 \uacf5\ubd84\uc0b0\uc744 \ucd5c\uc18c\ub85c \ud558\ub294 run \uc9d1\ud569\uc744 \ucc3e\ub294\ub2e4. \uc55e\uc758 \uacc4\uc5f4\ub4e4\uc774 \uc804\uc81c\ud558\ub294 \uc815\uc721\uba74\uccb4 \ubaa8\uc591\uc758 factor \uc124\uc815,\n2 \uc758 \uac70\ub4ed\uc81c\uacf1\uc774\uac70\ub098 4 \uc758 \ubc30\uc218\uc778 run \uc218, \uc790\uc720\ub86d\uac8c \uc6c0\uc9c1\uc774\ub294 factor \ub97c D-optimal design \uc740 \uc694\uad6c\ud558\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n<ul dir=\"auto\">\n<li><strong>\uac00\uc815<\/strong>: \uba85\uc2dc\ud55c model \uc774 \ubc18\uc751\uc744 \ub9de\uac8c \uae30\uc220\ud55c\ub2e4. Design \uc740 \uadf8 model \uc758 \uacc4\uc218\uc5d0 \ub300\ud574\uc11c\ub9cc \ucd5c\uc801\uc774\ub2e4.<\/li>\n<li><strong>\uc124\uc815\uac12<\/strong>: model (linear, interaction, quadratic), run \uc218, \uc5f0\uc18d factor \uc758 grid \uc218\uc900 \uc218, \ubb34\uc791\uc704 \ucd9c\ubc1c\uc810 \uc218, candidate set.<\/li>\n<li><strong>\uae68\uc9c0\ub294 \uc870\uac74<\/strong>: run \uc218\uac00 model \ud56d \uc218\ubcf4\ub2e4 \uc801\uc73c\uba74 model \uc744 \ucd94\uc815\ud560 \uc218 \uc5c6\ub2e4. \ucd9c\ubc1c\uc810\uc774 \uc801\uc73c\uba74 \ud0d0\uc0c9\uc774 \ucd5c\uc801\uc5d0 \ubabb \ubbf8\uce58\ub294 design \uc5d0 \uba38\ubb3c \uc218 \uc788\ub2e4.<\/li>\n<li><strong>\uc4f0\ub294 \uacf3<\/strong>: \ubd88\uaddc\uce59\ud55c run \uc608\uc0b0, \ub2e8\uacc4 \uc2e4\ud5d8\uc758 augmentation, \uae30\ub85d\ub9cc \ud558\ub294 covariate, categorical factor, \uc81c\uc57d\uc774 \uc788\ub294 factor \uacf5\uac04.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.1 D-Efficiency<\/h3><a id=\"user-content-81-d-efficiency\" class=\"anchor\" aria-label=\"Permalink: 8.1 D-Efficiency\" href=\"#81-d-efficiency\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">D-efficiency \ub294 \uc815\ubcf4\ud589\ub82c\uc758 \ud589\ub82c\uc2dd\uc744 \uc815\uaddc\ud654\ud558\uc5ec \ud06c\uae30\uac00 \ub2e4\ub978 design \ub07c\ub9ac \uacac\uc8fc\uac8c \ud55c\ub2e4. \uc2dd (3) \uc5d0\uc11c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$p$<\/math-renderer> \ub294 model \ud56d\n\uc218\uc774\uba70, D-efficiency \ub294 \uc9c1\uad50 design \uc5d0\uc11c 1 \uc774\uace0 \uadf8 \ubc16\uc5d0\uc11c\ub294 1 \ubcf4\ub2e4 \uc791\ub2e4.<\/p>\n<math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$$D = \\frac{\\left| \\mathbf{X}^{\\top}\\mathbf{X} \\right|^{1\/p}}{n} \\hspace{19em} (3)$$<\/math-renderer>\n<p dir=\"auto\">\ub450 \uc218\uc900 full factorial \uc740 linear model \uc5d0\uc11c D-efficiency 1 \uc5d0 \uc774\ub978\ub2e4. \uc9c1\uad50 design \uc774 \uc788\uc73c\uba74 D-optimal \ud0d0\uc0c9\uc740 \uadf8\ubcf4\ub2e4\n\ub098\uc740 design \uc744 \ucc3e\uc9c0 \ubabb\ud55c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.2 Generating D-Optimal Designs<\/h3><a id=\"user-content-82-generating-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: 8.2 Generating D-Optimal Designs\" href=\"#82-generating-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">D-optimal design \uc740 \ubc18\ubcf5 \ud0d0\uc0c9\uc73c\ub85c \uc5bb\ub294\ub2e4. Coordinate-exchange algorithm \uc740 \ubb34\uc791\uc704 design \uc5d0\uc11c \ucd9c\ubc1c\ud574, run \ud558\ub098\uc758\nfactor \ud558\ub098\ub97c \uace8\ub77c grid \uc704\uc758 \ubaa8\ub4e0 \uac12\uc744 \ub123\uc5b4 \ubcf4\uace0 \uac00\uc7a5 \uc88b\uc740 \uac12\uc744 \ub0a8\uae30\ub294 \uc774\ub3d9\uc744 \ub354 \ub098\uc544\uc9c0\uc9c0 \uc54a\uc744 \ub54c\uae4c\uc9c0\n\ub418\ud480\uc774\ud55c\ub2e4 [<a href=\"#ref-5\">5<\/a>]. \uacb0\uacfc\uac00 \ucd9c\ubc1c\uc810\uc5d0 \ub530\ub77c \ub2e4\ub974\ubbc0\ub85c, \ubb34\uc791\uc704 \ucd9c\ubc1c\uc810 \uc5ec\ub7ec \uac1c\uc5d0\uc11c \ud0d0\uc0c9\uc744 \ub418\ud480\uc774\ud558\uace0 \uac00\uc7a5 \uc88b\uc740\ndesign \uc744 \ub0a8\uae34\ub2e4.<\/p>\n<p dir=\"auto\">Factor 3 \uac1c\uc758 quadratic model \uc5d0 run 12 \uac1c\ub97c \uc694\uccad\ud558\uba74 D-efficiency 0.4498 \uc778 design \uc774 \ub098\uc628\ub2e4\n(<a href=\"#b5-d-optimal-designs\">Appendix B.5<\/a>). Table 4 \uc758 \uac00\uc7a5 \uc791\uc740 Box-Behnken design \ubcf4\ub2e4 run \uc774 3 \uac1c \uc801\uace0, model \uc758\n\uacc4\uc218 10 \uac1c\ubcf4\ub2e4 2 \uac1c \ub9ce\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.3 Augmenting D-Optimal Designs<\/h3><a id=\"user-content-83-augmenting-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: 8.3 Augmenting D-Optimal Designs\" href=\"#83-augmenting-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\uc2e4\ud5d8\uc740 \ud754\ud788 \ub2e8\uacc4\ub97c \ub098\ub204\uc5b4 \uc9c4\ud589\ud558\uba70, \uc774\ubbf8 \uc218\ud589\ud55c run \uc740 \ub2e4\uc2dc \uace0\ub97c \uc218 \uc5c6\ub2e4. Augmentation \uc740 \uc218\ud589\ud55c run \uc744 \uace0\uc815\ud55c \ucc44\n\uc0c8 run \ub9cc \ud0d0\uc0c9\ud558\ubbc0\ub85c, \uae30\uc874 design \uc5d0 \uc5c6\ub294 \uc815\ubcf4\ub97c \ucc44\uc6b0\ub294 run \uc744 \uace0\ub978\ub2e4. \uc774 \ud0d0\uc0c9\uc740 \uc88c\ud45c \ud558\ub098\uac00 \uc544\ub2c8\ub77c run \uc804\uccb4\ub97c\ncandidate set \uc758 \ud589\uacfc \ub9de\ubc14\uafb8\ub294 row exchange \ub97c \uc4f0\uba70, run \uc744 \uace0\uc815\ub41c \ubaa9\ub85d\uc5d0\uc11c \ubf51\uc744 \ub54c\ub294 \ud589 \ub2e8\uc704 \uad50\ud658\uc774 \uc54c\ub9de\uc740\n\uc774\ub3d9\uc774\ub2e4.<\/p>\n<p dir=\"auto\">\uaf2d\uc9d3\uc810 run 4 \uac1c\ub9cc\uc73c\ub85c\ub294 \ud56d\uc774 6 \uac1c\uc778 quadratic model \uc744 \ub9de\ucd9c \uc218 \uc5c6\ub2e4. Run 2 \uac1c\ub97c \ub354\ud558\uba74 \ucd94\uc815\ud560 \uc218 \uc788\uac8c \ub418\uba70,\n\ud0d0\uc0c9\uc740 \ub450 run \uc744 \ubaa8\ub450 \uae30\uc874 design \uc5d0 \uc5c6\ub294 \uaf2d\uc9d3\uc810 \ubc16\uc758 \uc810 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$(0, 1)$<\/math-renderer> \uacfc <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$(-1, 0)$<\/math-renderer> \uc5d0 \ub454\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.4 Specifying Fixed Covariate Factors<\/h3><a id=\"user-content-84-specifying-fixed-covariate-factors\" class=\"anchor\" aria-label=\"Permalink: 8.4 Specifying Fixed Covariate Factors\" href=\"#84-specifying-fixed-covariate-factors\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Covariate \ub294 \uc2e4\ud5d8\uc790\uac00 \uc815\ud558\uc9c0 \uc54a\uace0 \uae30\ub85d\ub9cc \ud558\ub294 factor \uc774\uba70, \uc8fc\uc704 \uc628\ub3c4, \uadfc\ubb34 \uc911\uc778 \uc791\uc5c5\uc790, batch \uc758 \uacbd\uacfc \uc2dc\uac04\uc774 \uadf8\n\uc608\uc774\ub2e4. Covariate \uac12\uc740 run \ub9c8\ub2e4 \ubbf8\ub9ac \uc54c\ub824\uc838 \uc788\uc9c0\ub9cc \uace0\ub97c \uc218 \uc5c6\ub2e4. \uc774\ub54c design \ubb38\uc81c\ub294 covariate \uc5f4\uc774 \uc8fc\uc5b4\uc9c4 \uc0c1\ud0dc\uc5d0\uc11c\n\ud1b5\uc81c \uac00\ub2a5\ud55c factor \ub97c \uace8\ub77c, model \uc774 \ud1b5\uc81c \ud6a8\uacfc\uc640 covariate \ud6a8\uacfc\ub97c \uac08\ub77c\ub0b4\uac8c \ud558\ub294 \uc77c\uc774 \ub41c\ub2e4.<\/p>\n<p dir=\"auto\">Run 8 \uac1c\uc5d0 \uac78\uccd0 covariate \uac00 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$-1$<\/math-renderer> \uc5d0\uc11c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$+1$<\/math-renderer> \ub85c \uace0\ub974\uac8c \ubcc0\ud558\uba74, \ud0d0\uc0c9\uc740 \ud1b5\uc81c \uac00\ub2a5\ud55c \ub450 \uc5f4\uc5d0 \uadf8 \ubcc0\ud654\uc640 \uade0\ud615\uc744 \uc774\ub8e8\ub294\n\ubb34\ub2ac\ub97c \ub193\uc544 \uc5b4\ub290 \ud1b5\uc81c \ud6a8\uacfc\ub3c4 covariate \uc640 confound \ub418\uc9c0 \uc54a\uac8c \ud55c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.5 Specifying Categorical Factors<\/h3><a id=\"user-content-85-specifying-categorical-factors\" class=\"anchor\" aria-label=\"Permalink: 8.5 Specifying Categorical Factors\" href=\"#85-specifying-categorical-factors\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Categorical factor \uc5d0\ub294 numeric \ucc99\ub3c4\uac00 \uc5c6\uc5b4 \uc218\uc900\uc744 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\pm 1$<\/math-renderer> \ucabd\uc73c\ub85c \uc62e\uae38 \uc218 \uc5c6\ub2e4. \uc218\uc900\uc774 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$L$<\/math-renderer> \uac1c\uc778 factor \ub294 effect\ncoding \uc73c\ub85c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$L - 1$<\/math-renderer> \uac1c\uc758 \uc5f4\uc774 \ub418\uc5b4 model \uc5d0 \ub4e4\uc5b4\uac00\uace0, \ud0d0\uc0c9\uc740 \uadf8 \uc5f4\ub4e4 \uc704\uc5d0\uc11c \uc774\ub8e8\uc5b4\uc9c4\ub2e4.<\/p>\n<p dir=\"auto\">\uc218\uc900\uc774 3 \uac1c\uc778 categorical factor 3 \uac1c\ub294 \ud6c4\ubcf4 treatment 27 \uac1c\ub97c \uc900\ub2e4. Run 9 \uac1c\ub97c \uc694\uccad\ud558\uba74, \ud0d0\uc0c9\uc740 \ubaa8\ub4e0 factor \uc758\n\ubaa8\ub4e0 \uc218\uc900\uc774 \uc138 \ubc88\uc529 \ub098\ud0c0\ub098\uace0 \ub450 factor \uc758 \uc218\uc900 \uc9dd\uc774 \ubaa8\ub450 \uc815\ud655\ud788 \ud55c \ubc88\uc529 \ub098\ud0c0\ub098\ub294 design \uc744 \ub3cc\ub824\uc900\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">8.6 Specifying Candidate Sets<\/h3><a id=\"user-content-86-specifying-candidate-sets\" class=\"anchor\" aria-label=\"Permalink: 8.6 Specifying Candidate Sets\" href=\"#86-specifying-candidate-sets\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Row exchange \ub294 \uace0\ub97c \uc218 \uc788\ub294 run \uc758 \ubaa9\ub85d\uc778 candidate set \uc744 \ubc1b\ub294\ub2e4. Factor \uacf5\uac04\uc774 \uc815\uc721\uba74\uccb4\uc774\uba74 candidate set \uc740 \uadf8\n\uc704\uc758 grid \uc774\ub2e4.<\/p>\n<p dir=\"auto\">Candidate set \uc744 \uba85\uc2dc\uc801\uc73c\ub85c \uac74\ub124\uba74 \uc815\uc721\uba74\uccb4\uac00 \uc544\ub2cc factor \uacf5\uac04\ub3c4 \ub2e4\ub8f0 \uc218 \uc788\ub2e4. \uc131\ubd84\uc758 \ud569\uc774 1 \uc774\uc5b4\uc57c \ud558\ub294 mixture,\n\ud568\uaed8 \ub192\uc744 \uc218 \uc5c6\ub294 \ub450 \uc124\uc815, \ucc28\uac00\uc6b4 \uc0c1\ud0dc\ub85c \ube60\ub974\uac8c \ub3cc \uc218 \uc5c6\ub294 \uae30\uacc4\ub294 \ubaa8\ub450 grid \uc5d0\uc11c \ud589\uc744 \ub35c\uc5b4\ub0b4\ub294 \uc81c\uc57d\uc774\ub2e4. \ud0d0\uc0c9\uc740\n\ubaa9\ub85d\uc5d0 \uc5c6\ub294 run \uc744 \uc81c\uc548\ud558\uc9c0 \uc54a\uc73c\ubbc0\ub85c, candidate set \uc5d0\uc11c \uadf8 \ud589\ub4e4\uc744 \uc9c0\uc6b0\uba74 \uc81c\uc57d\uc774 design \uc5d0 \ubc18\uc601\ub41c\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">References<\/h2><a id=\"user-content-references\" class=\"anchor\" aria-label=\"Permalink: References\" href=\"#references\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><a id=\"user-content-ref-1\"><\/a>\n[1] MathWorks. <a href=\"https:\/\/kr.mathworks.com\/help\/stats\/design-of-experiments.html\" rel=\"nofollow\">Design of Experiments \u2014 Statistics and Machine Learning Toolbox Documentation<\/a>.<br>\n<a id=\"user-content-ref-2\"><\/a>\n[2] Montgomery, D. C. (2019). <em>Design and Analysis of Experiments<\/em> (10th ed.). Wiley.\nISBN 978-1-119-49249-8.<br>\n<a id=\"user-content-ref-3\"><\/a>\n[3] Plackett, R. L., &amp; Burman, J. P. (1946). <a href=\"https:\/\/doi.org\/10.1093\/biomet\/33.4.305\" rel=\"nofollow\">The Design of Optimum Multifactorial Experiments<\/a>.\n<em>Biometrika<\/em>, 33(4), 305\u2013325.<br>\n<a id=\"user-content-ref-4\"><\/a>\n[4] Box, G. E. P., &amp; Behnken, D. W. (1960). <a href=\"https:\/\/doi.org\/10.1080\/00401706.1960.10489912\" rel=\"nofollow\">Some New Three Level Designs for the Study of\nQuantitative Variables<\/a>. <em>Technometrics<\/em>, 2(4), 455\u2013475.<br>\n<a id=\"user-content-ref-5\"><\/a>\n[5] Meyer, R. K., &amp; Nachtsheim, C. J. (1995). <a href=\"https:\/\/doi.org\/10.1080\/00401706.1995.10485889\" rel=\"nofollow\">The Coordinate-Exchange Algorithm for Constructing\nExact Optimal Experimental Designs<\/a>. <em>Technometrics<\/em>, 37(1), 60\u201369.<\/p>\n<hr>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix A. Terminology<\/h2><a id=\"user-content-appendix-a-terminology\" class=\"anchor\" aria-label=\"Permalink: Appendix A. Terminology\" href=\"#appendix-a-terminology\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li>\n<strong>Basic factor<\/strong>: generator \uac00 \uc544\ub2c8\ub77c fractional design \uc774 \ucd9c\ubc1c\uc810\uc73c\ub85c \uc0bc\ub294 full factorial \uc5d0\uc11c \uc5f4\uc774\n\ub098\uc624\ub294 factor.<\/li>\n<li>\n<strong>Candidate set<\/strong>: D-optimal \ud0d0\uc0c9\uc774 run \uc744 \uace0\ub97c \uc218 \uc788\ub294 factor \uc124\uc815\uc758 \ubaa9\ub85d.<\/li>\n<li>\n<strong>Centre run<\/strong>: \ubaa8\ub4e0 \uc5f0\uc18d factor \uac00 \uc790\uae30 \ubc94\uc704\uc758 \uac00\uc6b4\ub370\uc5d0 \uc788\ub294 run.<\/li>\n<li>\n<strong>Confounding<\/strong>: \ub450 \ud6a8\uacfc\uac00 \uac19\uc740 design \uc5f4\uc5d0 \uc2e4\ub824, \uadf8 \uc2e4\ud5d8\uc758 \uc5b4\ub5a4 \ubd84\uc11d\uc73c\ub85c\ub3c4 \uac08\ub77c\ub0bc \uc218 \uc5c6\ub294 \uc0c1\ud0dc.<\/li>\n<li>\n<strong>Covariate<\/strong>: \uc2e4\ud5d8\uc790\uac00 \uc815\ud558\uc9c0 \uc54a\uace0 run \ub9c8\ub2e4 \uae30\ub85d\ud558\ub294 factor.<\/li>\n<li>\n<strong>Defining relation<\/strong>: fractional factorial design \uc5d0\uc11c 1 \ub85c \ucc44\uc6cc\uc9c4 \uc5f4\uacfc \uac19\uc544\uc9c0\ub294 factor \uc5f4\ub4e4\uc758 \uacf1\uc758\n\ubaa8\uc784\uc774\uba70, \uadf8\uc911 \uac00\uc7a5 \uc9e7\uc740 word \uac00 resolution \uc744 \uc900\ub2e4.<\/li>\n<li>\n<strong>Effect coding<\/strong>: \uc218\uc900\uc774 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$L$<\/math-renderer> \uac1c\uc778 categorical factor \ub97c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$L - 1$<\/math-renderer> \uac1c\uc758 \uc5f4\ub85c \ubc14\uafb8\ub418, \ub9c8\uc9c0\ub9c9 \uc218\uc900\uc744 \ubaa8\ub4e0 \uc5f4\uc5d0\uc11c <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$-1$<\/math-renderer> \ub85c \ub450\ub294 \ubd80\ud638\ud654.<\/li>\n<li>\n<strong>Factor<\/strong>: \uc2e4\ud5d8\uc790\uac00 \uac12\uc744 \uc815\ud558\uac70\ub098 \uae30\ub85d\ud558\ub294 \uc785\ub825.<\/li>\n<li>\n<strong>Generator<\/strong>: fractional factorial design \uc5d0\uc11c \ub354\ud574\uc9c0\ub294 factor \ub97c \uc815\uc758\ud558\ub294 basic factor \ub4e4\uc758 \uacf1.<\/li>\n<li>\n<strong>Hadamard matrix<\/strong>: \uc6d0\uc18c\uac00 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\pm 1$<\/math-renderer> \uc774\uace0 \uc5f4\ub4e4\uc774 \uc11c\ub85c \uc9c1\uad50\ud558\ub294 \uc815\uc0ac\uac01\ud589\ub82c.<\/li>\n<li>\n<strong>Interaction<\/strong>: \ud55c factor \uc758 \ud6a8\uacfc\uac00 \ub2e4\ub978 factor \uc758 \uc218\uc900\uc5d0 \ub530\ub77c \ub2ec\ub77c\uc9c0\ub294 \uc815\ub3c4.<\/li>\n<li>\n<strong>Level<\/strong>: \ud55c design \uc5d0\uc11c factor \uac00 \uac16\ub294 \uac12 \uac00\uc6b4\ub370 \ud558\ub098.<\/li>\n<li>\n<strong>Main effect<\/strong>: \ud55c factor \uc758 \uc218\uc900\uc744 \ubc14\uafc0 \ub54c \ub2e4\ub978 factor \uc5d0 \ub300\ud574 \ud3c9\uade0\ud55c \ubc18\uc751\uc758 \ubcc0\ud654.<\/li>\n<li>\n<strong>Response<\/strong>: run \uc758 \uce21\uc815\ub41c \ucd9c\ub825.<\/li>\n<li>\n<strong>Rotatable<\/strong>: \uc608\uce21\ubd84\uc0b0\uc774 factor \uacf5\uac04 \uc911\uc2ec\uc73c\ub85c\ubd80\ud130\uc758 \uac70\ub9ac\uc5d0\ub9cc \uc758\uc874\ud558\ub294 design.<\/li>\n<li>\n<strong>Run<\/strong>: factor \uc218\uc900\uc758 \ud55c \uc870\ud569\uc5d0\uc11c \uc2e4\ud5d8\uc744 \ud55c \ubc88 \uc218\ud589\ud558\ub294 \uac83\uc774\uba70, design \uc758 \ud55c \ud589.<\/li>\n<li>\n<strong>Screening<\/strong>: \ub9ce\uc740 factor \uac00\uc6b4\ub370 \ubc18\uc751\uc5d0 \uc720\uc758\ud55c factor \ub97c \uac00\ub824\ub0b4\ub294 \uc2e4\ud5d8.<\/li>\n<li>\n<strong>Star point<\/strong>: central composite design \uc5d0\uc11c factor \ud558\ub098\ub97c \uc911\uc2ec \ubc16\uc73c\ub85c \uc62e\uae30\uace0 \ub098\uba38\uc9c0\ub294 \uc911\uc2ec\uc5d0 \ub450\ub294\nrun.<\/li>\n<li>\n<strong>Treatment<\/strong>: factor \uc218\uc900\uc758 \ud55c \uc870\ud569.<\/li>\n<li>\n<strong>Word<\/strong>: defining relation \uc5d0\uc11c \uacf1\uc774 1 \ub85c \ucc44\uc6cc\uc9c4 \uc5f4\uc774 \ub418\ub294 factor \uc774\ub984\ub4e4\uc758 \ubb36\uc74c\uc774\uba70, \uadf8 \uae38\uc774\ub294 \ubb36\uc778 factor \uc218\uc774\ub2e4.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix B. Python Implementation<\/h2><a id=\"user-content-appendix-b-python-implementation\" class=\"anchor\" aria-label=\"Permalink: Appendix B. Python Implementation\" href=\"#appendix-b-python-implementation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\uc774 Appendix \uc758 Python block \uc740 \uc21c\uc11c\ub300\ub85c \uc2e4\ud589\ud558\ub3c4\ub85d \ub418\uc5b4 \uc788\ub2e4. \uac01 block \uc740 B.1 \uc758 header \uc704\uc5d0\uc11c \uc55e\uc120 block \uc774 \uc815\uc758\ud55c\n\uc774\ub984\uc744 \uc4f0\uba70, \ubc14\ub85c \ub4a4\uc758 <code>text<\/code> block \uc740 \uadf8 \ucd9c\ub825\uc774\ub2e4. \uc2e4\ud589\uc5d0\ub294 numpy \uc640 scipy \uac00 \ud544\uc694\ud558\ub2e4.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.1 Common Header<\/h3><a id=\"user-content-b1-common-header\" class=\"anchor\" aria-label=\"Permalink: B.1 Common Header\" href=\"#b1-common-header\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\nimport itertools\nfrom typing import Sequence\n\nimport numpy as np\nfrom scipy.linalg import hadamard\n\nnp.set_printoptions(linewidth=100, suppress=True, precision=4)\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">itertools<\/span>\n<span class=\"pl-k\">from<\/span> <span class=\"pl-s1\">typing<\/span> <span class=\"pl-k\">import<\/span> <span class=\"pl-v\">Sequence<\/span>\n\n<span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">numpy<\/span> <span class=\"pl-k\">as<\/span> <span class=\"pl-s1\">np<\/span>\n<span class=\"pl-k\">from<\/span> <span class=\"pl-s1\">scipy<\/span>.<span class=\"pl-s1\">linalg<\/span> <span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">hadamard<\/span>\n\n<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">set_printoptions<\/span>(<span class=\"pl-s1\">linewidth<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">100<\/span>, <span class=\"pl-s1\">suppress<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">True<\/span>, <span class=\"pl-s1\">precision<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">4<\/span>)<\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.2 Full Factorial Designs<\/h3><a id=\"user-content-b2-full-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: B.2 Full Factorial Designs\" href=\"#b2-full-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Multilevel Designs<\/h4><a id=\"user-content-multilevel-designs\" class=\"anchor\" aria-label=\"Permalink: Multilevel Designs\" href=\"#multilevel-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 5.1 \uc758 \uacf1\uc9d1\ud569 \uad6c\uc131\uc774\uba70, \ub450 \uc218\uc900 factor \uc640 \uc138 \uc218\uc900 factor \ub85c run 6 \uac1c\ub97c \ub9cc\ub4e0\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef full_factorial(levels: Sequence[int]) -&gt; np.ndarray:\n    &quot;&quot;&quot;Full factorial design. Column i takes levels 0..levels[i]-1; the first column varies fastest.&quot;&quot;&quot;\n    levels = list(levels)\n    if any(v &lt; 2 for v in levels):\n        raise ValueError(f&quot;every factor needs at least 2 levels; got {levels}&quot;)\n    grids = np.meshgrid(*[np.arange(v) for v in levels], indexing='ij')\n    return np.column_stack([g.ravel(order='F') for g in grids])\n\n\nprint(full_factorial([2, 3]))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">full_factorial<\/span>(<span class=\"pl-s1\">levels<\/span>: <span class=\"pl-v\">Sequence<\/span>&#91;<span class=\"pl-smi\">int<\/span>&#93;) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Full factorial design. Column i takes levels 0..levels&#91;i&#93;-1; the first column varies fastest.\"\"\"<\/span>\n    <span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">levels<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">any<\/span>(<span class=\"pl-s1\">v<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">v<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">levels<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"every factor needs at least 2 levels; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">levels<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">grids<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">meshgrid<\/span>(<span class=\"pl-c1\">*<\/span>&#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">arange<\/span>(<span class=\"pl-s1\">v<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">v<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">levels<\/span>&#93;, <span class=\"pl-s1\">indexing<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'ij'<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">column_stack<\/span>(&#91;<span class=\"pl-s1\">g<\/span>.<span class=\"pl-c1\">ravel<\/span>(<span class=\"pl-s1\">order<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'F'<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">g<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">grids<\/span>&#93;)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">full_factorial<\/span>(&#91;<span class=\"pl-c1\">2<\/span>, <span class=\"pl-c1\">3<\/span>&#93;))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[0 0]\n [1 0]\n [0 1]\n [1 1]\n [0 2]\n [1 2]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;0 0&#93;\n &#91;1 0&#93;\n &#91;0 1&#93;\n &#91;1 1&#93;\n &#91;0 2&#93;\n &#91;1 2&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Two-Level Designs<\/h4><a id=\"user-content-two-level-designs\" class=\"anchor\" aria-label=\"Permalink: Two-Level Designs\" href=\"#two-level-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 5.2 \uc758 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$2^k$<\/math-renderer> design \uc744 <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"e066069dc03865b7037e64adaf1c8cb8\">$\\pm 1$<\/math-renderer> \ub85c \ubd80\ud638\ud654\ud55c\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef two_level_factorial(n_factors: int) -&gt; np.ndarray:\n    &quot;&quot;&quot;Two-level full factorial design coded as -1 and +1.&quot;&quot;&quot;\n    if n_factors &lt; 1:\n        raise ValueError(f&quot;n_factors must be at least 1; got {n_factors}&quot;)\n    return 2.0 * full_factorial([2] * n_factors) - 1.0\n\n\nprint(two_level_factorial(3))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Two-level full factorial design coded as -1 and +1.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_factors must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">2.0<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-en\">full_factorial<\/span>(&#91;<span class=\"pl-c1\">2<\/span>&#93; <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">n_factors<\/span>) <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1.0<\/span>\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">3<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1. -1. -1.]\n [ 1. -1. -1.]\n [-1.  1. -1.]\n [ 1.  1. -1.]\n [-1. -1.  1.]\n [ 1. -1.  1.]\n [-1.  1.  1.]\n [ 1.  1.  1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1. -1. -1.&#93;\n &#91; 1. -1. -1.&#93;\n &#91;-1.  1. -1.&#93;\n &#91; 1.  1. -1.&#93;\n &#91;-1. -1.  1.&#93;\n &#91; 1. -1.  1.&#93;\n &#91;-1.  1.  1.&#93;\n &#91; 1.  1.  1.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.3 Fractional Factorial Designs<\/h3><a id=\"user-content-b3-fractional-factorial-designs\" class=\"anchor\" aria-label=\"Permalink: B.3 Fractional Factorial Designs\" href=\"#b3-fractional-factorial-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Plackett-Burman Designs<\/h4><a id=\"user-content-plackett-burman-designs\" class=\"anchor\" aria-label=\"Permalink: Plackett-Burman Designs\" href=\"#plackett-burman-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 6.2 \uc758 \uad6c\uc131\uc774\ub2e4. \ub9c8\uc9c0\ub9c9 \uc904\uc740 run 12 \uac1c design \uc758 \uc5f4 11 \uac1c\uac00 \uc11c\ub85c \uc9c1\uad50\ud568\uc744 \ud655\uc778\ud55c\ub2e4. Run \uc218\uac00 2 \uc758\n\uac70\ub4ed\uc81c\uacf1\ub3c4 \uc544\ub2c8\uace0 generator \ub3c4 \uc5c6\uc73c\uba74, \ub2e4\ub978 design \uc73c\ub85c \ubc14\uafb8\uc9c0 \uc54a\uace0 \uc624\ub958\ub97c \ub0b8\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\nPB_GENERATORS = {\n    12: '++-+++---+-',\n    20: '++--++++-+-+----++-',\n    24: '+++++-+-++--++--+-+----',\n}\n\n\ndef plackett_burman(n_factors: int) -&gt; np.ndarray:\n    &quot;&quot;&quot;Plackett-Burman design with the smallest run count that is a multiple of 4 and exceeds n_factors.&quot;&quot;&quot;\n    if n_factors &lt; 1:\n        raise ValueError(f&quot;n_factors must be at least 1; got {n_factors}&quot;)\n    n_runs = 4 * int(np.ceil((n_factors + 1) \/ 4))\n    if n_runs &amp; (n_runs - 1) == 0:\n        design = hadamard(n_runs)[:, 1:] * 1.0\n    elif n_runs in PB_GENERATORS:\n        row = np.array([1.0 if c == '+' else -1.0 for c in PB_GENERATORS[n_runs]])\n        design = np.vstack([np.roll(row, k) for k in range(n_runs - 1)] + [-np.ones(n_runs - 1)])\n    else:\n        raise ValueError(f&quot;no Plackett-Burman construction available for {n_runs} runs&quot;)\n    return design[:, :n_factors]\n\n\ndesign = plackett_burman(11)\nprint(design.shape, np.allclose(design.T @ design, 12 * np.eye(11)))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-c1\">PB_GENERATORS<\/span> <span class=\"pl-c1\">=<\/span> {\n    <span class=\"pl-c1\">12<\/span>: <span class=\"pl-s\">'++-+++---+-'<\/span>,\n    <span class=\"pl-c1\">20<\/span>: <span class=\"pl-s\">'++--++++-+-+----++-'<\/span>,\n    <span class=\"pl-c1\">24<\/span>: <span class=\"pl-s\">'+++++-+-++--++--+-+----'<\/span>,\n}\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">plackett_burman<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Plackett-Burman design with the smallest run count that is a multiple of 4 and exceeds n_factors.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_factors must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">4<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-en\">int<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ceil<\/span>((<span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-c1\">4<\/span>))\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">&amp;<\/span> (<span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">0<\/span>:\n        <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">hadamard<\/span>(<span class=\"pl-s1\">n_runs<\/span>)&#91;:, <span class=\"pl-c1\">1<\/span>:&#93; <span class=\"pl-c1\">*<\/span> <span class=\"pl-c1\">1.0<\/span>\n    <span class=\"pl-k\">elif<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-c1\">PB_GENERATORS<\/span>:\n        <span class=\"pl-s1\">row<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(&#91;<span class=\"pl-c1\">1.0<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'+'<\/span> <span class=\"pl-k\">else<\/span> <span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-c1\">PB_GENERATORS<\/span>&#91;<span class=\"pl-s1\">n_runs<\/span>&#93;&#93;)\n        <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">roll<\/span>(<span class=\"pl-s1\">row<\/span>, <span class=\"pl-s1\">k<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">k<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>)&#93; <span class=\"pl-c1\">+<\/span> &#91;<span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ones<\/span>(<span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>)&#93;)\n    <span class=\"pl-k\">else<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"no Plackett-Burman construction available for <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_runs<\/span><span class=\"pl-kos\">}<\/span><\/span> runs\"<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">design<\/span>&#91;:, :<span class=\"pl-s1\">n_factors<\/span>&#93;\n\n\n<span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">plackett_burman<\/span>(<span class=\"pl-c1\">11<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">shape<\/span>, <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">allclose<\/span>(<span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">T<\/span> @ <span class=\"pl-s1\">design<\/span>, <span class=\"pl-c1\">12<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">eye<\/span>(<span class=\"pl-c1\">11<\/span>)))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"(12, 11) True\"><pre lang=\"text\" class=\"notranslate\"><code>(12, 11) True\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">General Fractional Designs<\/h4><a id=\"user-content-general-fractional-designs\" class=\"anchor\" aria-label=\"Permalink: General Fractional Designs\" href=\"#general-fractional-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 6.3 \uc758 generator \uad6c\uc131\uc774\uba70, generator <code>a b c abc<\/code> \ub85c factor 4 \uac1c\uc758 run 8 \uac1c design \uc744 \ub9cc\ub4e0\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef fractional_factorial(generators: str) -&gt; np.ndarray:\n    &quot;&quot;&quot;Fractional factorial design from generators such as 'a b c abc'. Single letters are the basic factors.&quot;&quot;&quot;\n    terms = generators.split()\n    basic = ''.join(t for t in terms if len(t) == 1)\n    if not basic:\n        raise ValueError(f&quot;generators must contain at least one single-letter basic factor; got {generators!r}&quot;)\n    if len(set(basic)) != len(basic):\n        raise ValueError(f&quot;basic factors must be distinct; got {basic!r}&quot;)\n    base = two_level_factorial(len(basic))\n    columns = []\n    for term in terms:\n        unknown = set(term) - set(basic)\n        if unknown:\n            raise ValueError(f&quot;term {term!r} uses factors {sorted(unknown)} that are not basic factors&quot;)\n        columns.append(np.prod(base[:, [basic.index(c) for c in term]], axis=1))\n    return np.column_stack(columns)\n\n\nprint(fractional_factorial('a b c abc'))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">fractional_factorial<\/span>(<span class=\"pl-s1\">generators<\/span>: <span class=\"pl-smi\">str<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Fractional factorial design from generators such as 'a b c abc'. Single letters are the basic factors.\"\"\"<\/span>\n    <span class=\"pl-s1\">terms<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">generators<\/span>.<span class=\"pl-c1\">split<\/span>()\n    <span class=\"pl-s1\">basic<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">''<\/span>.<span class=\"pl-c1\">join<\/span>(<span class=\"pl-s1\">t<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">t<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">terms<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">t<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">1<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-c1\">not<\/span> <span class=\"pl-s1\">basic<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"generators must contain at least one single-letter basic factor; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">generators<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-en\">set<\/span>(<span class=\"pl-s1\">basic<\/span>)) <span class=\"pl-c1\">!=<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">basic<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"basic factors must be distinct; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">basic<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">base<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">basic<\/span>))\n    <span class=\"pl-s1\">columns<\/span> <span class=\"pl-c1\">=<\/span> &#91;&#93;\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">term<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">terms<\/span>:\n        <span class=\"pl-s1\">unknown<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">set<\/span>(<span class=\"pl-s1\">term<\/span>) <span class=\"pl-c1\">-<\/span> <span class=\"pl-en\">set<\/span>(<span class=\"pl-s1\">basic<\/span>)\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">unknown<\/span>:\n            <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"term <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">term<\/span>!r<span class=\"pl-kos\">}<\/span><\/span> uses factors <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">sorted<\/span>(<span class=\"pl-s1\">unknown<\/span>)<span class=\"pl-kos\">}<\/span><\/span> that are not basic factors\"<\/span>)\n        <span class=\"pl-s1\">columns<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">prod<\/span>(<span class=\"pl-s1\">base<\/span>&#91;:, &#91;<span class=\"pl-s1\">basic<\/span>.<span class=\"pl-c1\">index<\/span>(<span class=\"pl-s1\">c<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">term<\/span>&#93;&#93;, <span class=\"pl-s1\">axis<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>))\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">column_stack<\/span>(<span class=\"pl-s1\">columns<\/span>)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">fractional_factorial<\/span>(<span class=\"pl-s\">'a b c abc'<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1. -1. -1. -1.]\n [ 1. -1. -1.  1.]\n [-1.  1. -1.  1.]\n [ 1.  1. -1. -1.]\n [-1. -1.  1.  1.]\n [ 1. -1.  1. -1.]\n [-1.  1.  1. -1.]\n [ 1.  1.  1.  1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1. -1. -1. -1.&#93;\n &#91; 1. -1. -1.  1.&#93;\n &#91;-1.  1. -1.  1.&#93;\n &#91; 1.  1. -1. -1.&#93;\n &#91;-1. -1.  1.  1.&#93;\n &#91; 1. -1.  1. -1.&#93;\n &#91;-1.  1.  1. -1.&#93;\n &#91; 1.  1.  1.  1.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Design Resolution<\/h4><a id=\"user-content-design-resolution\" class=\"anchor\" aria-label=\"Permalink: Design Resolution\" href=\"#design-resolution\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Generator \uac00 \ud568\uc758\ud558\ub294 word \ub4e4\uc774 \uc0dd\uc131\ud558\ub294 \ubd80\ubd84\uad70\uc5d0\uc11c \uac00\uc7a5 \uc9e7\uc740 word \ub97c \ucc3e\uc544 Table 3 \uc758 resolution \uc744 \uacc4\uc0b0\ud55c\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef design_resolution(generators: str) -&gt; int:\n    &quot;&quot;&quot;Resolution of a fractional factorial design: the length of the shortest word in the defining relation.&quot;&quot;&quot;\n    terms = generators.split()\n    basic = ''.join(t for t in terms if len(t) == 1)\n    names = [chr(ord('A') + i) for i in range(len(terms))]\n    words = []\n    for name, term in zip(names, terms):\n        if len(term) == 1:\n            continue\n        words.append(frozenset([names[basic.index(c)] for c in term] + [name]))\n    if not words:\n        return len(terms) + 1  # a full factorial has no defining relation, so no effect is confounded\n    subgroup = set()\n    for size in range(1, len(words) + 1):\n        for combination in itertools.combinations(words, size):\n            word = frozenset()\n            for w in combination:\n                word = word.symmetric_difference(w)\n            if word:\n                subgroup.add(word)\n    return min(len(w) for w in subgroup)\n\n\nfor spec in ['a b ab', 'a b c ab', 'a b c abc', 'a b c d abcd']:\n    print(f'{spec:16s} runs={len(fractional_factorial(spec)):2d} resolution={design_resolution(spec)}')\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">design_resolution<\/span>(<span class=\"pl-s1\">generators<\/span>: <span class=\"pl-smi\">str<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">int<\/span>:\n    <span class=\"pl-s\">\"\"\"Resolution of a fractional factorial design: the length of the shortest word in the defining relation.\"\"\"<\/span>\n    <span class=\"pl-s1\">terms<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">generators<\/span>.<span class=\"pl-c1\">split<\/span>()\n    <span class=\"pl-s1\">basic<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">''<\/span>.<span class=\"pl-c1\">join<\/span>(<span class=\"pl-s1\">t<\/span> <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">t<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">terms<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">t<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">1<\/span>)\n    <span class=\"pl-s1\">names<\/span> <span class=\"pl-c1\">=<\/span> &#91;<span class=\"pl-en\">chr<\/span>(<span class=\"pl-en\">ord<\/span>(<span class=\"pl-s\">'A'<\/span>) <span class=\"pl-c1\">+<\/span> <span class=\"pl-s1\">i<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">terms<\/span>))&#93;\n    <span class=\"pl-s1\">words<\/span> <span class=\"pl-c1\">=<\/span> &#91;&#93;\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">name<\/span>, <span class=\"pl-s1\">term<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">zip<\/span>(<span class=\"pl-s1\">names<\/span>, <span class=\"pl-s1\">terms<\/span>):\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">term<\/span>) <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">1<\/span>:\n            <span class=\"pl-k\">continue<\/span>\n        <span class=\"pl-s1\">words<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-en\">frozenset<\/span>(&#91;<span class=\"pl-s1\">names<\/span>&#91;<span class=\"pl-s1\">basic<\/span>.<span class=\"pl-c1\">index<\/span>(<span class=\"pl-s1\">c<\/span>)&#93; <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">c<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">term<\/span>&#93; <span class=\"pl-c1\">+<\/span> &#91;<span class=\"pl-s1\">name<\/span>&#93;))\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-c1\">not<\/span> <span class=\"pl-s1\">words<\/span>:\n        <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">terms<\/span>) <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>  <span class=\"pl-c\"># a full factorial has no defining relation, so no effect is confounded<\/span>\n    <span class=\"pl-s1\">subgroup<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">set<\/span>()\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">size<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-c1\">1<\/span>, <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">words<\/span>) <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>):\n        <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">combination<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">combinations<\/span>(<span class=\"pl-s1\">words<\/span>, <span class=\"pl-s1\">size<\/span>):\n            <span class=\"pl-s1\">word<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">frozenset<\/span>()\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">w<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">combination<\/span>:\n                <span class=\"pl-s1\">word<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">word<\/span>.<span class=\"pl-c1\">symmetric_difference<\/span>(<span class=\"pl-s1\">w<\/span>)\n            <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">word<\/span>:\n                <span class=\"pl-s1\">subgroup<\/span>.<span class=\"pl-c1\">add<\/span>(<span class=\"pl-s1\">word<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">min<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">w<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">w<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">subgroup<\/span>)\n\n\n<span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">spec<\/span> <span class=\"pl-c1\">in<\/span> &#91;<span class=\"pl-s\">'a b ab'<\/span>, <span class=\"pl-s\">'a b c ab'<\/span>, <span class=\"pl-s\">'a b c abc'<\/span>, <span class=\"pl-s\">'a b c d abcd'<\/span>&#93;:\n    <span class=\"pl-en\">print<\/span>(<span class=\"pl-s\">f'<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">spec<\/span>:16s<span class=\"pl-kos\">}<\/span><\/span> runs=<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">len<\/span>(<span class=\"pl-en\">fractional_factorial<\/span>(<span class=\"pl-s1\">spec<\/span>)):2d<span class=\"pl-kos\">}<\/span><\/span> resolution=<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">design_resolution<\/span>(<span class=\"pl-s1\">spec<\/span>)<span class=\"pl-kos\">}<\/span><\/span>'<\/span>)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"a b ab           runs= 4 resolution=3\na b c ab         runs= 8 resolution=3\na b c abc        runs= 8 resolution=4\na b c d abcd     runs=16 resolution=5\"><pre lang=\"text\" class=\"notranslate\"><code>a b ab           runs= 4 resolution=3\na b c ab         runs= 8 resolution=3\na b c abc        runs= 8 resolution=4\na b c d abcd     runs=16 resolution=5\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.4 Response Surface Designs<\/h3><a id=\"user-content-b4-response-surface-designs\" class=\"anchor\" aria-label=\"Permalink: B.4 Response Surface Designs\" href=\"#b4-response-surface-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Central Composite Designs<\/h4><a id=\"user-content-central-composite-designs\" class=\"anchor\" aria-label=\"Permalink: Central Composite Designs\" href=\"#central-composite-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 7.2 \uc758 \uc138 \ubcc0\ud615\uc744 <code>kind<\/code> \ub85c \uace0\ub978\ub2e4. \uc798\ubabb\ub41c <code>kind<\/code> \ub294 \uae30\ubcf8\uac12\uc73c\ub85c \ubc14\uafb8\uc9c0 \uc54a\uace0 \uc624\ub958\ub97c \ub0b4\ubbc0\ub85c, \ucca0\uc790\ub97c \ud2c0\ub9b0\n\ubcc0\ud615\uc774 \ud638\ucd9c\uc790\uac00 \uc694\uccad\ud558\uc9c0 \uc54a\uc740 design \uc744 \ub9cc\ub4e4\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef central_composite(n_factors: int, n_center: int = 1, kind: str = 'circumscribed') -&gt; np.ndarray:\n    &quot;&quot;&quot;Central composite design. kind is 'circumscribed', 'inscribed' or 'faced'.&quot;&quot;&quot;\n    if n_factors &lt; 2:\n        raise ValueError(f&quot;a central composite design needs at least 2 factors; got {n_factors}&quot;)\n    if n_center &lt; 1:\n        raise ValueError(f&quot;n_center must be at least 1; got {n_center}&quot;)\n    if kind not in ('circumscribed', 'inscribed', 'faced'):\n        raise ValueError(f&quot;kind must be 'circumscribed', 'inscribed' or 'faced'; got {kind!r}&quot;)\n    cube = two_level_factorial(n_factors)\n    alpha = 1.0 if kind == 'faced' else (2.0 ** n_factors) ** 0.25\n    star = np.zeros((2 * n_factors, n_factors))\n    for i in range(n_factors):\n        star[2 * i, i] = alpha\n        star[2 * i + 1, i] = -alpha\n    if kind == 'inscribed':\n        cube, star = cube \/ alpha, star \/ alpha\n    return np.vstack([cube, star, np.zeros((n_center, n_factors))])\n\n\nprint(central_composite(2, n_center=1))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">central_composite<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_center<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">1<\/span>, <span class=\"pl-s1\">kind<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'circumscribed'<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Central composite design. kind is 'circumscribed', 'inscribed' or 'faced'.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"a central composite design needs at least 2 factors; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_center<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_center must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_center<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">kind<\/span> <span class=\"pl-c1\"><span class=\"pl-c1\">not<\/span> <span class=\"pl-c1\">in<\/span><\/span> (<span class=\"pl-s\">'circumscribed'<\/span>, <span class=\"pl-s\">'inscribed'<\/span>, <span class=\"pl-s\">'faced'<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"kind must be 'circumscribed', 'inscribed' or 'faced'; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">kind<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">cube<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-s1\">n_factors<\/span>)\n    <span class=\"pl-s1\">alpha<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">1.0<\/span> <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">kind<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'faced'<\/span> <span class=\"pl-k\">else<\/span> (<span class=\"pl-c1\">2.0<\/span> <span class=\"pl-c1\">**<\/span> <span class=\"pl-s1\">n_factors<\/span>) <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">0.25<\/span>\n    <span class=\"pl-s1\">star<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-c1\">2<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">n_factors<\/span>, <span class=\"pl-s1\">n_factors<\/span>))\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n        <span class=\"pl-s1\">star<\/span>&#91;<span class=\"pl-c1\">2<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">alpha<\/span>\n        <span class=\"pl-s1\">star<\/span>&#91;<span class=\"pl-c1\">2<\/span> <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1<\/span>, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">alpha<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">kind<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'inscribed'<\/span>:\n        <span class=\"pl-s1\">cube<\/span>, <span class=\"pl-s1\">star<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">cube<\/span> <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">alpha<\/span>, <span class=\"pl-s1\">star<\/span> <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">alpha<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">cube<\/span>, <span class=\"pl-s1\">star<\/span>, <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-s1\">n_center<\/span>, <span class=\"pl-s1\">n_factors<\/span>))&#93;)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">central_composite<\/span>(<span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">n_center<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1.     -1.    ]\n [ 1.     -1.    ]\n [-1.      1.    ]\n [ 1.      1.    ]\n [ 1.4142  0.    ]\n [-1.4142  0.    ]\n [ 0.      1.4142]\n [ 0.     -1.4142]\n [ 0.      0.    ]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1.     -1.    &#93;\n &#91; 1.     -1.    &#93;\n &#91;-1.      1.    &#93;\n &#91; 1.      1.    &#93;\n &#91; 1.4142  0.    &#93;\n &#91;-1.4142  0.    &#93;\n &#91; 0.      1.4142&#93;\n &#91; 0.     -1.4142&#93;\n &#91; 0.      0.    &#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Box-Behnken Designs<\/h4><a id=\"user-content-box-behnken-designs\" class=\"anchor\" aria-label=\"Permalink: Box-Behnken Designs\" href=\"#box-behnken-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 7.3 \uc758 \uc9dd \ub2e8\uc704 \uad6c\uc131\uc774\uba70, factor 3 \uac1c\uc640 centre run 3 \uac1c\ub85c Table 4 \uc758 run 15 \uac1c\ub97c \ub9cc\ub4e0\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef box_behnken(n_factors: int, n_center: int = 3) -&gt; np.ndarray:\n    &quot;&quot;&quot;Box-Behnken design: a two-level factorial in each pair of factors with the rest held at the centre.&quot;&quot;&quot;\n    if n_factors &lt; 3:\n        raise ValueError(f&quot;a Box-Behnken design needs at least 3 factors; got {n_factors}&quot;)\n    if n_center &lt; 1:\n        raise ValueError(f&quot;n_center must be at least 1; got {n_center}&quot;)\n    block = two_level_factorial(2)\n    rows = []\n    for i, j in itertools.combinations(range(n_factors), 2):\n        edge = np.zeros((len(block), n_factors))\n        edge[:, [i, j]] = block\n        rows.append(edge)\n    return np.vstack(rows + [np.zeros((n_center, n_factors))])\n\n\nprint(box_behnken(3, n_center=3))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">box_behnken<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_center<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Box-Behnken design: a two-level factorial in each pair of factors with the rest held at the centre.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">3<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"a Box-Behnken design needs at least 3 factors; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_factors<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_center<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_center must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_center<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">block<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">2<\/span>)\n    <span class=\"pl-s1\">rows<\/span> <span class=\"pl-c1\">=<\/span> &#91;&#93;\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">j<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">combinations<\/span>(<span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>), <span class=\"pl-c1\">2<\/span>):\n        <span class=\"pl-s1\">edge<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">block<\/span>), <span class=\"pl-s1\">n_factors<\/span>))\n        <span class=\"pl-s1\">edge<\/span>&#91;:, &#91;<span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">j<\/span>&#93;&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">block<\/span>\n        <span class=\"pl-s1\">rows<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">edge<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(<span class=\"pl-s1\">rows<\/span> <span class=\"pl-c1\">+<\/span> &#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-s1\">n_center<\/span>, <span class=\"pl-s1\">n_factors<\/span>))&#93;)\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">box_behnken<\/span>(<span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">n_center<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1. -1.  0.]\n [ 1. -1.  0.]\n [-1.  1.  0.]\n [ 1.  1.  0.]\n [-1.  0. -1.]\n [ 1.  0. -1.]\n [-1.  0.  1.]\n [ 1.  0.  1.]\n [ 0. -1. -1.]\n [ 0.  1. -1.]\n [ 0. -1.  1.]\n [ 0.  1.  1.]\n [ 0.  0.  0.]\n [ 0.  0.  0.]\n [ 0.  0.  0.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1. -1.  0.&#93;\n &#91; 1. -1.  0.&#93;\n &#91;-1.  1.  0.&#93;\n &#91; 1.  1.  0.&#93;\n &#91;-1.  0. -1.&#93;\n &#91; 1.  0. -1.&#93;\n &#91;-1.  0.  1.&#93;\n &#91; 1.  0.  1.&#93;\n &#91; 0. -1. -1.&#93;\n &#91; 0.  1. -1.&#93;\n &#91; 0. -1.  1.&#93;\n &#91; 0.  1.  1.&#93;\n &#91; 0.  0.  0.&#93;\n &#91; 0.  0.  0.&#93;\n &#91; 0.  0.  0.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">B.5 D-Optimal Designs<\/h3><a id=\"user-content-b5-d-optimal-designs\" class=\"anchor\" aria-label=\"Permalink: B.5 D-Optimal Designs\" href=\"#b5-d-optimal-designs\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">D-Efficiency<\/h4><a id=\"user-content-d-efficiency\" class=\"anchor\" aria-label=\"Permalink: D-Efficiency\" href=\"#d-efficiency\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">\uc2dd (3) \uc744 \uacc4\uc0b0\ud558\uba70, \ub450 \uc218\uc900 full factorial \uc758 linear model D-efficiency 1 \ub85c \ucc99\ub3c4\ub97c \ud655\uc778\ud55c\ub2e4. Run \uc218\uac00 model \ud56d\n\uc218\ubcf4\ub2e4 \uc801\uc73c\uba74 \uc624\ub958\ub97c \ub0b8\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef model_matrix(design: np.ndarray, model: str = 'linear') -&gt; np.ndarray:\n    &quot;&quot;&quot;Model matrix with an intercept. model is 'linear', 'interaction' or 'quadratic'.&quot;&quot;&quot;\n    if model not in ('linear', 'interaction', 'quadratic'):\n        raise ValueError(f&quot;model must be 'linear', 'interaction' or 'quadratic'; got {model!r}&quot;)\n    design = np.atleast_2d(design)\n    n_runs, n_factors = design.shape\n    columns = [np.ones(n_runs), *design.T]\n    if model in ('interaction', 'quadratic'):\n        for i, j in itertools.combinations(range(n_factors), 2):\n            columns.append(design[:, i] * design[:, j])\n    if model == 'quadratic':\n        for i in range(n_factors):\n            columns.append(design[:, i] ** 2)\n    return np.column_stack(columns)\n\n\ndef d_efficiency(design: np.ndarray, model: str = 'linear') -&gt; float:\n    &quot;&quot;&quot;D-efficiency, the normalised determinant of the information matrix. Larger is better; 1 is the maximum.&quot;&quot;&quot;\n    x = model_matrix(design, model=model)\n    n_runs, n_terms = x.shape\n    if n_runs &lt; n_terms:\n        raise ValueError(f&quot;{n_runs} runs cannot fit {n_terms} model terms&quot;)\n    determinant = np.linalg.det(x.T @ x)\n    if determinant &lt;= 0:\n        return 0.0\n    return determinant ** (1.0 \/ n_terms) \/ n_runs\n\n\nprint(round(d_efficiency(two_level_factorial(2), model='linear'), 4))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">model_matrix<\/span>(<span class=\"pl-s1\">design<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Model matrix with an intercept. model is 'linear', 'interaction' or 'quadratic'.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">model<\/span> <span class=\"pl-c1\"><span class=\"pl-c1\">not<\/span> <span class=\"pl-c1\">in<\/span><\/span> (<span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s\">'interaction'<\/span>, <span class=\"pl-s\">'quadratic'<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"model must be 'linear', 'interaction' or 'quadratic'; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">model<\/span>!r<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">atleast_2d<\/span>(<span class=\"pl-s1\">design<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_factors<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">shape<\/span>\n    <span class=\"pl-s1\">columns<\/span> <span class=\"pl-c1\">=<\/span> &#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ones<\/span>(<span class=\"pl-s1\">n_runs<\/span>), <span class=\"pl-c1\">*<\/span><span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">T<\/span>&#93;\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">model<\/span> <span class=\"pl-c1\">in<\/span> (<span class=\"pl-s\">'interaction'<\/span>, <span class=\"pl-s\">'quadratic'<\/span>):\n        <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span>, <span class=\"pl-s1\">j<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">combinations<\/span>(<span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>), <span class=\"pl-c1\">2<\/span>):\n            <span class=\"pl-s1\">columns<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">design<\/span>&#91;:, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">*<\/span> <span class=\"pl-s1\">design<\/span>&#91;:, <span class=\"pl-s1\">j<\/span>&#93;)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">model<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s\">'quadratic'<\/span>:\n        <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">i<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n            <span class=\"pl-s1\">columns<\/span>.<span class=\"pl-c1\">append<\/span>(<span class=\"pl-s1\">design<\/span>&#91;:, <span class=\"pl-s1\">i<\/span>&#93; <span class=\"pl-c1\">**<\/span> <span class=\"pl-c1\">2<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">column_stack<\/span>(<span class=\"pl-s1\">columns<\/span>)\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"D-efficiency, the normalised determinant of the information matrix. Larger is better; 1 is the maximum.\"\"\"<\/span>\n    <span class=\"pl-s1\">x<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">model_matrix<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_terms<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">x<\/span>.<span class=\"pl-c1\">shape<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-s1\">n_terms<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_runs<\/span><span class=\"pl-kos\">}<\/span><\/span> runs cannot fit <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_terms<\/span><span class=\"pl-kos\">}<\/span><\/span> model terms\"<\/span>)\n    <span class=\"pl-s1\">determinant<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linalg<\/span>.<span class=\"pl-c1\">det<\/span>(<span class=\"pl-s1\">x<\/span>.<span class=\"pl-c1\">T<\/span> @ <span class=\"pl-s1\">x<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">determinant<\/span> <span class=\"pl-c1\">&lt;=<\/span> <span class=\"pl-c1\">0<\/span>:\n        <span class=\"pl-k\">return<\/span> <span class=\"pl-c1\">0.0<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">determinant<\/span> <span class=\"pl-c1\">**<\/span> (<span class=\"pl-c1\">1.0<\/span> <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">n_terms<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">n_runs<\/span>\n\n\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">round<\/span>(<span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">2<\/span>), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'linear'<\/span>), <span class=\"pl-c1\">4<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"1.0\"><pre lang=\"text\" class=\"notranslate\"><code>1.0\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Coordinate Exchange<\/h4><a id=\"user-content-coordinate-exchange\" class=\"anchor\" aria-label=\"Permalink: Coordinate Exchange\" href=\"#coordinate-exchange\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 8.2 \uc758 \ud0d0\uc0c9\uc774\uba70, factor 3 \uac1c\uc758 quadratic model \uc5d0 run 12 \uac1c\ub97c \uace0\ub978\ub2e4. \ucd9c\ub825\uc758 \uccab \uc904\uc774 D-efficiency \uc774\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef coordinate_exchange(n_runs: int, n_factors: int, model: str = 'linear', n_levels: int = 3,\n                        n_tries: int = 5, seed: int = None) -&gt; np.ndarray:\n    &quot;&quot;&quot;D-optimal design by coordinate exchange over a grid of n_levels values spanning [-1, 1].&quot;&quot;&quot;\n    if n_levels &lt; 2:\n        raise ValueError(f&quot;n_levels must be at least 2; got {n_levels}&quot;)\n    rng = np.random.default_rng(seed)\n    grid = np.linspace(-1.0, 1.0, n_levels)\n    best, best_score = None, -np.inf\n    for _ in range(n_tries):\n        design = rng.choice(grid, size=(n_runs, n_factors))\n        score = d_efficiency(design, model=model)\n        improved = True\n        while improved:\n            improved = False\n            for run in range(n_runs):\n                for factor in range(n_factors):\n                    current = design[run, factor]\n                    for value in grid:\n                        design[run, factor] = value\n                        trial = d_efficiency(design, model=model)\n                        if trial &gt; score + 1e-12:\n                            score, current, improved = trial, value, True\n                    design[run, factor] = current\n        if score &gt; best_score:\n            best, best_score = design.copy(), score\n    return best\n\n\ndesign = coordinate_exchange(n_runs=12, n_factors=3, model='quadratic', n_levels=3, n_tries=5, seed=1)\nprint(round(d_efficiency(design, model='quadratic'), 4))\nprint(design)\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">coordinate_exchange<\/span>(<span class=\"pl-s1\">n_runs<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>,\n                        <span class=\"pl-s1\">n_tries<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"D-optimal design by coordinate exchange over a grid of n_levels values spanning &#91;-1, 1&#93;.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_levels must be at least 2; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_levels<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">rng<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">random<\/span>.<span class=\"pl-c1\">default_rng<\/span>(<span class=\"pl-s1\">seed<\/span>)\n    <span class=\"pl-s1\">grid<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-s1\">n_levels<\/span>)\n    <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">inf<\/span>\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">_<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_tries<\/span>):\n        <span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">rng<\/span>.<span class=\"pl-c1\">choice<\/span>(<span class=\"pl-s1\">grid<\/span>, <span class=\"pl-s1\">size<\/span><span class=\"pl-c1\">=<\/span>(<span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_factors<\/span>))\n        <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n        <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">True<\/span>\n        <span class=\"pl-k\">while<\/span> <span class=\"pl-s1\">improved<\/span>:\n            <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">False<\/span>\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">run<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span>):\n                <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">factor<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n                    <span class=\"pl-s1\">current<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">design<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93;\n                    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">value<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">grid<\/span>:\n                        <span class=\"pl-s1\">design<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">value<\/span>\n                        <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n                        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1e-12<\/span>:\n                            <span class=\"pl-s1\">score<\/span>, <span class=\"pl-s1\">current<\/span>, <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">trial<\/span>, <span class=\"pl-s1\">value<\/span>, <span class=\"pl-c1\">True<\/span>\n                    <span class=\"pl-s1\">design<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">current<\/span>\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">best_score<\/span>:\n            <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">design<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-s1\">score<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">best<\/span>\n\n\n<span class=\"pl-s1\">design<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">coordinate_exchange<\/span>(<span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">12<\/span>, <span class=\"pl-s1\">n_factors<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>, <span class=\"pl-s1\">n_levels<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">round<\/span>(<span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">design<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>), <span class=\"pl-c1\">4<\/span>))\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">design<\/span>)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"0.4498\n[[ 1.  1.  1.]\n [-1. -1. -1.]\n [ 1.  1. -1.]\n [-1.  1.  1.]\n [-1.  1. -1.]\n [-1.  0.  0.]\n [ 0.  0. -1.]\n [ 0.  1.  0.]\n [ 1. -1.  1.]\n [ 1. -1. -1.]\n [ 1.  0.  1.]\n [-1. -1.  1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>0.4498\n&#91;&#91; 1.  1.  1.&#93;\n &#91;-1. -1. -1.&#93;\n &#91; 1.  1. -1.&#93;\n &#91;-1.  1.  1.&#93;\n &#91;-1.  1. -1.&#93;\n &#91;-1.  0.  0.&#93;\n &#91; 0.  0. -1.&#93;\n &#91; 0.  1.  0.&#93;\n &#91; 1. -1.  1.&#93;\n &#91; 1. -1. -1.&#93;\n &#91; 1.  0.  1.&#93;\n &#91;-1. -1.  1.&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Row Exchange and Augmentation<\/h4><a id=\"user-content-row-exchange-and-augmentation\" class=\"anchor\" aria-label=\"Permalink: Row Exchange and Augmentation\" href=\"#row-exchange-and-augmentation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 8.3 \uc758 \ud0d0\uc0c9\uc774\uba70, <code>fixed<\/code> \uc5d0 \ub123\uc740 \ud589\uc740 \ubc14\uafb8\uc9c0 \uc54a\ub294\ub2e4. \uaf2d\uc9d3\uc810 run 4 \uac1c\uc5d0 run 2 \uac1c\ub97c \ub354\ud55c\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef row_exchange(candidates: np.ndarray, n_runs: int, model: str = 'linear', n_tries: int = 5,\n                 seed: int = None, fixed: np.ndarray = None) -&gt; np.ndarray:\n    &quot;&quot;&quot;D-optimal design chosen from a candidate set by row exchange. Rows in fixed are kept and not exchanged.&quot;&quot;&quot;\n    if n_runs &lt; 1:\n        raise ValueError(f&quot;n_runs must be at least 1; got {n_runs}&quot;)\n    rng = np.random.default_rng(seed)\n    fixed = np.empty((0, candidates.shape[1])) if fixed is None else np.atleast_2d(fixed)\n    best, best_score = None, -np.inf\n    for _ in range(n_tries):\n        chosen = candidates[rng.choice(len(candidates), size=n_runs, replace=True)]\n        score = d_efficiency(np.vstack([fixed, chosen]), model=model)\n        improved = True\n        while improved:\n            improved = False\n            for run in range(n_runs):\n                current = chosen[run].copy()\n                for row in candidates:\n                    chosen[run] = row\n                    trial = d_efficiency(np.vstack([fixed, chosen]), model=model)\n                    if trial &gt; score + 1e-12:\n                        score, current, improved = trial, row.copy(), True\n                chosen[run] = current\n        if score &gt; best_score:\n            best, best_score = chosen.copy(), score\n    return best\n\n\nexisting = two_level_factorial(2)\nallowed = np.array(list(itertools.product([-1.0, 0.0, 1.0], repeat=2)))[:, ::-1]\nadded = row_exchange(allowed, n_runs=2, model='quadratic', n_tries=5, seed=3, fixed=existing)\nprint(added)\nprint(round(d_efficiency(np.vstack([existing, added]), model='quadratic'), 4))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-s1\">candidates<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">n_runs<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_tries<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">5<\/span>,\n                 <span class=\"pl-s1\">seed<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">fixed<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"D-optimal design chosen from a candidate set by row exchange. Rows in fixed are kept and not exchanged.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_runs must be at least 1; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_runs<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">rng<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">random<\/span>.<span class=\"pl-c1\">default_rng<\/span>(<span class=\"pl-s1\">seed<\/span>)\n    <span class=\"pl-s1\">fixed<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">empty<\/span>((<span class=\"pl-c1\">0<\/span>, <span class=\"pl-s1\">candidates<\/span>.<span class=\"pl-c1\">shape<\/span>&#91;<span class=\"pl-c1\">1<\/span>&#93;)) <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">fixed<\/span> <span class=\"pl-c1\">is<\/span> <span class=\"pl-c1\">None<\/span> <span class=\"pl-k\">else<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">atleast_2d<\/span>(<span class=\"pl-s1\">fixed<\/span>)\n    <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">inf<\/span>\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">_<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_tries<\/span>):\n        <span class=\"pl-s1\">chosen<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">candidates<\/span>&#91;<span class=\"pl-s1\">rng<\/span>.<span class=\"pl-c1\">choice<\/span>(<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">candidates<\/span>), <span class=\"pl-s1\">size<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">replace<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">True<\/span>)&#93;\n        <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">fixed<\/span>, <span class=\"pl-s1\">chosen<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n        <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">True<\/span>\n        <span class=\"pl-k\">while<\/span> <span class=\"pl-s1\">improved<\/span>:\n            <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">False<\/span>\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">run<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span>):\n                <span class=\"pl-s1\">current<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">run<\/span>&#93;.<span class=\"pl-c1\">copy<\/span>()\n                <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">row<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">candidates<\/span>:\n                    <span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">run<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">row<\/span>\n                    <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">fixed<\/span>, <span class=\"pl-s1\">chosen<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n                    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1e-12<\/span>:\n                        <span class=\"pl-s1\">score<\/span>, <span class=\"pl-s1\">current<\/span>, <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">trial<\/span>, <span class=\"pl-s1\">row<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-c1\">True<\/span>\n                <span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">run<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">current<\/span>\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">best_score<\/span>:\n            <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">chosen<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-s1\">score<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">best<\/span>\n\n\n<span class=\"pl-s1\">existing<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">two_level_factorial<\/span>(<span class=\"pl-c1\">2<\/span>)\n<span class=\"pl-s1\">allowed<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(<span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">product<\/span>(&#91;<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">0.0<\/span>, <span class=\"pl-c1\">1.0<\/span>&#93;, <span class=\"pl-s1\">repeat<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>)))&#91;:, ::<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>&#93;\n<span class=\"pl-s1\">added<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-s1\">allowed<\/span>, <span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">fixed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">existing<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">added<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">round<\/span>(<span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">vstack<\/span>(&#91;<span class=\"pl-s1\">existing<\/span>, <span class=\"pl-s1\">added<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>), <span class=\"pl-c1\">4<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[ 0.  1.]\n [-1.  0.]]\n0.42\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91; 0.  1.&#93;\n &#91;-1.  0.&#93;&#93;\n0.42\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Fixed Covariates<\/h4><a id=\"user-content-fixed-covariates\" class=\"anchor\" aria-label=\"Permalink: Fixed Covariates\" href=\"#fixed-covariates\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 8.4 \uc758 \ud0d0\uc0c9\uc774\uba70, \ub9c8\uc9c0\ub9c9 \uc5f4\uc774 \uace0\ub974\uac8c \ubcc0\ud558\ub294 covariate \uc774\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef covariate_exchange(covariates: np.ndarray, n_factors: int, model: str = 'linear', n_levels: int = 3,\n                       n_tries: int = 5, seed: int = None) -&gt; np.ndarray:\n    &quot;&quot;&quot;D-optimal design whose last columns are the given fixed covariates, one run per covariate row.&quot;&quot;&quot;\n    covariates = np.atleast_2d(covariates)\n    rng = np.random.default_rng(seed)\n    grid = np.linspace(-1.0, 1.0, n_levels)\n    n_runs = len(covariates)\n    best, best_score = None, -np.inf\n    for _ in range(n_tries):\n        controlled = rng.choice(grid, size=(n_runs, n_factors))\n        score = d_efficiency(np.hstack([controlled, covariates]), model=model)\n        improved = True\n        while improved:\n            improved = False\n            for run in range(n_runs):\n                for factor in range(n_factors):\n                    current = controlled[run, factor]\n                    for value in grid:\n                        controlled[run, factor] = value\n                        trial = d_efficiency(np.hstack([controlled, covariates]), model=model)\n                        if trial &gt; score + 1e-12:\n                            score, current, improved = trial, value, True\n                    controlled[run, factor] = current\n        if score &gt; best_score:\n            best, best_score = controlled.copy(), score\n    return np.hstack([best, covariates])\n\n\ndrift = np.linspace(-1.0, 1.0, 8).reshape(-1, 1)\nprint(covariate_exchange(drift, n_factors=2, model='linear', n_levels=3, n_tries=3, seed=4))\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">covariate_exchange<\/span>(<span class=\"pl-s1\">covariates<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">model<\/span>: <span class=\"pl-smi\">str<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>,\n                       <span class=\"pl-s1\">n_tries<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"D-optimal design whose last columns are the given fixed covariates, one run per covariate row.\"\"\"<\/span>\n    <span class=\"pl-s1\">covariates<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">atleast_2d<\/span>(<span class=\"pl-s1\">covariates<\/span>)\n    <span class=\"pl-s1\">rng<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">random<\/span>.<span class=\"pl-c1\">default_rng<\/span>(<span class=\"pl-s1\">seed<\/span>)\n    <span class=\"pl-s1\">grid<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-s1\">n_levels<\/span>)\n    <span class=\"pl-s1\">n_runs<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">covariates<\/span>)\n    <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-c1\">-<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">inf<\/span>\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">_<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_tries<\/span>):\n        <span class=\"pl-s1\">controlled<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">rng<\/span>.<span class=\"pl-c1\">choice<\/span>(<span class=\"pl-s1\">grid<\/span>, <span class=\"pl-s1\">size<\/span><span class=\"pl-c1\">=<\/span>(<span class=\"pl-s1\">n_runs<\/span>, <span class=\"pl-s1\">n_factors<\/span>))\n        <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-s1\">controlled<\/span>, <span class=\"pl-s1\">covariates<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n        <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">True<\/span>\n        <span class=\"pl-k\">while<\/span> <span class=\"pl-s1\">improved<\/span>:\n            <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">False<\/span>\n            <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">run<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_runs<\/span>):\n                <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">factor<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_factors<\/span>):\n                    <span class=\"pl-s1\">current<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">controlled<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93;\n                    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">value<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">grid<\/span>:\n                        <span class=\"pl-s1\">controlled<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">value<\/span>\n                        <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">d_efficiency<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-s1\">controlled<\/span>, <span class=\"pl-s1\">covariates<\/span>&#93;), <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">model<\/span>)\n                        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">trial<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">+<\/span> <span class=\"pl-c1\">1e-12<\/span>:\n                            <span class=\"pl-s1\">score<\/span>, <span class=\"pl-s1\">current<\/span>, <span class=\"pl-s1\">improved<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">trial<\/span>, <span class=\"pl-s1\">value<\/span>, <span class=\"pl-c1\">True<\/span>\n                    <span class=\"pl-s1\">controlled<\/span>&#91;<span class=\"pl-s1\">run<\/span>, <span class=\"pl-s1\">factor<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">current<\/span>\n        <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">score<\/span> <span class=\"pl-c1\">&gt;<\/span> <span class=\"pl-s1\">best_score<\/span>:\n            <span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">best_score<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">controlled<\/span>.<span class=\"pl-c1\">copy<\/span>(), <span class=\"pl-s1\">score<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-s1\">best<\/span>, <span class=\"pl-s1\">covariates<\/span>&#93;)\n\n\n<span class=\"pl-s1\">drift<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">8<\/span>).<span class=\"pl-c1\">reshape<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>, <span class=\"pl-c1\">1<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-en\">covariate_exchange<\/span>(<span class=\"pl-s1\">drift<\/span>, <span class=\"pl-s1\">n_factors<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_levels<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">4<\/span>))<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[-1.     -1.     -1.    ]\n [ 1.     -1.     -0.7143]\n [ 1.      1.     -0.4286]\n [-1.      1.     -0.1429]\n [-1.      1.      0.1429]\n [ 1.      1.      0.4286]\n [ 1.     -1.      0.7143]\n [-1.     -1.      1.    ]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;-1.     -1.     -1.    &#93;\n &#91; 1.     -1.     -0.7143&#93;\n &#91; 1.      1.     -0.4286&#93;\n &#91;-1.      1.     -0.1429&#93;\n &#91;-1.      1.      0.1429&#93;\n &#91; 1.      1.      0.4286&#93;\n &#91; 1.     -1.      0.7143&#93;\n &#91;-1.     -1.      1.    &#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Categorical Factors<\/h4><a id=\"user-content-categorical-factors\" class=\"anchor\" aria-label=\"Permalink: Categorical Factors\" href=\"#categorical-factors\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 8.5 \uc758 effect coding \uacfc row exchange \uc774\uba70, \uace0\ub978 run \uc744 \uc6d0\ub798 \uc218\uc900\uc73c\ub85c \ub418\ub3cc\ub824 \uc815\ub82c\ud574 \ubcf4\uc778\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef effect_code(levels: np.ndarray, n_levels: int) -&gt; np.ndarray:\n    &quot;&quot;&quot;Effect coding of one categorical factor into n_levels - 1 columns.&quot;&quot;&quot;\n    levels = np.asarray(levels, dtype=int)\n    if levels.min() &lt; 0 or levels.max() &gt;= n_levels:\n        raise ValueError(f&quot;levels must lie in 0..{n_levels - 1}; got range {levels.min()}..{levels.max()}&quot;)\n    coded = np.zeros((len(levels), n_levels - 1))\n    for column in range(n_levels - 1):\n        coded[levels == column, column] = 1.0\n    coded[levels == n_levels - 1, :] = -1.0\n    return coded\n\n\nlevels = np.array(list(itertools.product(range(3), repeat=3)))[:, ::-1]\ncoded = np.hstack([effect_code(levels[:, k], 3) for k in range(3)])\nselected = row_exchange(coded, n_runs=9, model='linear', n_tries=5, seed=7)\nchosen = np.array([levels[int(np.where((coded == r).all(axis=1))[0][0])] for r in selected])\nprint(chosen[np.lexsort((chosen[:, 2], chosen[:, 1], chosen[:, 0]))])\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">effect_code<\/span>(<span class=\"pl-s1\">levels<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Effect coding of one categorical factor into n_levels - 1 columns.\"\"\"<\/span>\n    <span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">asarray<\/span>(<span class=\"pl-s1\">levels<\/span>, <span class=\"pl-s1\">dtype<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">int<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">min<\/span>() <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">0<\/span> <span class=\"pl-c1\">or<\/span> <span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">max<\/span>() <span class=\"pl-c1\">&gt;=<\/span> <span class=\"pl-s1\">n_levels<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"levels must lie in 0..<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span><span class=\"pl-kos\">}<\/span><\/span>; got range <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">min<\/span>()<span class=\"pl-kos\">}<\/span><\/span>..<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">levels<\/span>.<span class=\"pl-c1\">max<\/span>()<span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">coded<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">zeros<\/span>((<span class=\"pl-en\">len<\/span>(<span class=\"pl-s1\">levels<\/span>), <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>))\n    <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">column<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>):\n        <span class=\"pl-s1\">coded<\/span>&#91;<span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s1\">column<\/span>, <span class=\"pl-s1\">column<\/span>&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">1.0<\/span>\n    <span class=\"pl-s1\">coded<\/span>&#91;<span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>, :&#93; <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">coded<\/span>\n\n\n<span class=\"pl-s1\">levels<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(<span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">product<\/span>(<span class=\"pl-en\">range<\/span>(<span class=\"pl-c1\">3<\/span>), <span class=\"pl-s1\">repeat<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>)))&#91;:, ::<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>&#93;\n<span class=\"pl-s1\">coded<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">hstack<\/span>(&#91;<span class=\"pl-en\">effect_code<\/span>(<span class=\"pl-s1\">levels<\/span>&#91;:, <span class=\"pl-s1\">k<\/span>&#93;, <span class=\"pl-c1\">3<\/span>) <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">k<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-en\">range<\/span>(<span class=\"pl-c1\">3<\/span>)&#93;)\n<span class=\"pl-s1\">selected<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-s1\">coded<\/span>, <span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">9<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'linear'<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">7<\/span>)\n<span class=\"pl-s1\">chosen<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(&#91;<span class=\"pl-s1\">levels<\/span>&#91;<span class=\"pl-en\">int<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">where<\/span>((<span class=\"pl-s1\">coded<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-s1\">r<\/span>).<span class=\"pl-c1\">all<\/span>(<span class=\"pl-s1\">axis<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">1<\/span>))&#91;<span class=\"pl-c1\">0<\/span>&#93;&#91;<span class=\"pl-c1\">0<\/span>&#93;)&#93; <span class=\"pl-k\">for<\/span> <span class=\"pl-s1\">r<\/span> <span class=\"pl-c1\">in<\/span> <span class=\"pl-s1\">selected<\/span>&#93;)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">chosen<\/span>&#91;<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">lexsort<\/span>((<span class=\"pl-s1\">chosen<\/span>&#91;:, <span class=\"pl-c1\">2<\/span>&#93;, <span class=\"pl-s1\">chosen<\/span>&#91;:, <span class=\"pl-c1\">1<\/span>&#93;, <span class=\"pl-s1\">chosen<\/span>&#91;:, <span class=\"pl-c1\">0<\/span>&#93;))&#93;)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[0 0 1]\n [0 1 0]\n [0 2 2]\n [1 0 0]\n [1 1 2]\n [1 2 1]\n [2 0 2]\n [2 1 1]\n [2 2 0]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91;0 0 1&#93;\n &#91;0 1 0&#93;\n &#91;0 2 2&#93;\n &#91;1 0 0&#93;\n &#91;1 1 2&#93;\n &#91;1 2 1&#93;\n &#91;2 0 2&#93;\n &#91;2 1 1&#93;\n &#91;2 2 0&#93;&#93;\n<\/code><\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h4 class=\"heading-element\" dir=\"auto\">Candidate Sets<\/h4><a id=\"user-content-candidate-sets\" class=\"anchor\" aria-label=\"Permalink: Candidate Sets\" href=\"#candidate-sets\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Section 8.6 \uc758 \uc815\uc721\uba74\uccb4 grid \ub97c \ub9cc\ub4e4\uace0, factor 2 \uac1c\uc758 quadratic model \uc5d0 run 6 \uac1c\ub97c \uace0\ub978\ub2e4.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Python\ndef candidate_set(n_factors: int, n_levels: int = 3) -&gt; np.ndarray:\n    &quot;&quot;&quot;Candidate set: the full factorial of n_levels values spanning [-1, 1] in every factor.&quot;&quot;&quot;\n    if n_levels &lt; 2:\n        raise ValueError(f&quot;n_levels must be at least 2; got {n_levels}&quot;)\n    grid = np.linspace(-1.0, 1.0, n_levels)\n    return np.array(list(itertools.product(grid, repeat=n_factors)))[:, ::-1]\n\n\nselected = row_exchange(candidate_set(2, n_levels=3), n_runs=6, model='quadratic', n_tries=5, seed=2)\nprint(selected)\"><pre><span class=\"pl-c\"># Python<\/span>\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">candidate_set<\/span>(<span class=\"pl-s1\">n_factors<\/span>: <span class=\"pl-smi\">int<\/span>, <span class=\"pl-s1\">n_levels<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">3<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Candidate set: the full factorial of n_levels values spanning &#91;-1, 1&#93; in every factor.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">n_levels<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"n_levels must be at least 2; got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">n_levels<\/span><span class=\"pl-kos\">}<\/span><\/span>\"<\/span>)\n    <span class=\"pl-s1\">grid<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">linspace<\/span>(<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-c1\">1.0<\/span>, <span class=\"pl-s1\">n_levels<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">array<\/span>(<span class=\"pl-en\">list<\/span>(<span class=\"pl-s1\">itertools<\/span>.<span class=\"pl-c1\">product<\/span>(<span class=\"pl-s1\">grid<\/span>, <span class=\"pl-s1\">repeat<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">n_factors<\/span>)))&#91;:, ::<span class=\"pl-c1\">-<\/span><span class=\"pl-c1\">1<\/span>&#93;\n\n\n<span class=\"pl-s1\">selected<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">row_exchange<\/span>(<span class=\"pl-en\">candidate_set<\/span>(<span class=\"pl-c1\">2<\/span>, <span class=\"pl-s1\">n_levels<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">3<\/span>), <span class=\"pl-s1\">n_runs<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">6<\/span>, <span class=\"pl-s1\">model<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s\">'quadratic'<\/span>, <span class=\"pl-s1\">n_tries<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">5<\/span>, <span class=\"pl-s1\">seed<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-c1\">2<\/span>)\n<span class=\"pl-en\">print<\/span>(<span class=\"pl-s1\">selected<\/span>)<\/pre><\/div>\n<div class=\"snippet-clipboard-content notranslate position-relative overflow-auto\" data-snippet-clipboard-copy-content=\"[[ 1.  1.]\n [-1.  1.]\n [ 0.  1.]\n [-1. -1.]\n [ 1.  0.]\n [ 1. -1.]]\"><pre lang=\"text\" class=\"notranslate\"><code>&#91;&#91; 1.  1.&#93;\n &#91;-1.  1.&#93;\n &#91; 0.  1.&#93;\n &#91;-1. -1.&#93;\n &#91; 1.  0.&#93;\n &#91; 1. -1.&#93;&#93;\n<\/code><\/pre><\/div>\n<\/article><\/div><\/div><\/p>\n<\/div><\/div>\n<\/div><\/div><\/div>\n<div style='text-align:center' class='yasr-auto-insert-overall'><\/div><div style='text-align:center' class='yasr-auto-insert-visitor'><\/div>","protected":false},"excerpt":{"rendered":"<p>\ud83c\uddfa\ud83c\uddf8\ud83c\uddf0\ud83c\uddf7 Passive data cannot separate factors that move together, so the settings are chosen deliberately instead. Because the covariance of the estimates follows from the design alone, designing an experiment is choosing the rows of the model matrix against a run budget. Full factorial, fractional factorial, response surface and D-optimal, in Python.<\/p>\n","protected":false},"author":4,"featured_media":6912,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","fifu_image_url":"","fifu_image_alt":"","iawp_total_views":27,"footnotes":""},"categories":[56,432,321],"tags":[386],"class_list":["post-6913","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-science-slug","category-doe-slug","category-math-slug","tag-github-hosted"],"yasr_visitor_votes":{"stars_attributes":{"read_only":false,"span_bottom":false},"number_of_votes":1,"sum_votes":4},"jetpack_featured_media_url":"https:\/\/ykim.synology.me\/wordpress\/wp-content\/uploads\/2026\/08\/plywood-shipping-crate-hinged.jpg","_links":{"self":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/comments?post=6913"}],"version-history":[{"count":8,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6913\/revisions"}],"predecessor-version":[{"id":7447,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6913\/revisions\/7447"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media\/6912"}],"wp:attachment":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media?parent=6913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/categories?post=6913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/tags?post=6913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}