Problemy w praktyce praktycznych zasad
var globalThing= {}; // Globally scoped object
function check() { if(globalThing.q_selected=="between") { if(globalThing.sd_multiplier==1) { var solution = 68; } if(globalThing.sd_multiplier==2) { var solution = 95; } if(globalThing.sd_multiplier==3) { var solution = 99.7; } } //end between if(globalThing.q_selected=="less than") { if(globalThing.sd_multiplier==1) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 84; } else { var solution = 16; } } if(globalThing.sd_multiplier==2) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 97.5; } else { var solution = 2.5; } } if(globalThing.sd_multiplier==3) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 99.85; } else { var solution = 0.15; } } } //end less than if(globalThing.q_selected=="greater than") { if(globalThing.sd_multiplier==1) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 16; } else { var solution = 84; } } if(globalThing.sd_multiplier==2) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 2.5; } else { var solution = 97.5; } } if(globalThing.sd_multiplier==3) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 0.15; } else { var solution = 99.85; } } } //end greater than
//check if user-entered solution matches correct solution var user_answer = document.getElementById('answer').value; if (user_answer == solution) { document.getElementById('output').innerHTML = "Correct!" } else { document.getElementById('output').innerHTML = "Not quite yet..." }
//toggle answer showing var result_display = document.getElementById("words_output"); result_display.style.display = "block"; } //end massive check() function
function solution() { if(globalThing.q_selected=="between") { if(globalThing.sd_multiplier==1) { var solution = 68; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 68% of data values fall within one standard deviation of the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located one standard deviation below the mean and " + globalThing.sd_above.toFixed(1) + " is located one standard deviation above the mean.
Thus, 68% of plants are between " + globalThing.sd_below.toFixed(1) + " and " + globalThing.sd_above.toFixed(1) + " inches tall."; } if(globalThing.sd_multiplier==2) { var solution = 95; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 95% of data values fall within two standard deviations of the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located two standard deviations below the mean and " + globalThing.sd_above.toFixed(1) + " is located two standard deviations above the mean.
Thus, 95% of plants are between " + globalThing.sd_below.toFixed(1) + " and " + globalThing.sd_above.toFixed(1) + " inches tall."; } if(globalThing.sd_multiplier==3) { var solution = 99.7; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 99.7% of data values fall within three standard deviations of the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located three standard deviations below the mean and " + globalThing.sd_above.toFixed(1) + " is located three standard deviations above the mean.
Thus, 99.7% of plants are between " + globalThing.sd_below.toFixed(1) + " and " + globalThing.sd_above.toFixed(1) + " inches tall."; } } //end between if(globalThing.q_selected=="less than") { if(globalThing.sd_multiplier==1) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 84; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 68% of data values fall within one standard deviation of the mean. This means that 34% of values fall between the mean and one standard deviation above the mean.
In this example, " + globalThing.sd_above.toFixed(1) + " is located one standard deviation above the mean. Since we know that 50% of data values fall below the mean in a normal distribution, a total of 50% + 34% = 84% of values fall below " + globalThing.sd_above.toFixed(1) + ".
Thus, 84% of plants are less than " + globalThing.sd_above.toFixed(1) + " inches tall."; } else { var solution = 16; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 68% of data values fall within one standard deviation of the mean. This means that 34% of values fall between the mean and one standard deviation below the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located one standard deviation below the mean. Since we know that 50% of data values fall above the mean in a normal distribution, a total of 50% + 34% = 84% of values fall above " + globalThing.sd_below.toFixed(1) + ". This means that 100% - 84% = 16% of values fall below " + globalThing.sd_below.toFixed(1) + ".
Thus, 16% of plants are less than " + globalThing.sd_below.toFixed(1) + " inches tall."; } } if(globalThing.sd_multiplier==2) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 97.5; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 95% of data values fall within two standard deviations of the mean. This means that 47.5% of values fall between the mean and two standard deviations above the mean.
In this example, " + globalThing.sd_above.toFixed(1) + " is located two standard deviations above the mean. Since we know that 50% of data values fall below the mean in a normal distribution, a total of 50% + 47.5% = 97.5% of values fall below " + globalThing.sd_above.toFixed(1) + ".
Thus, 97.5% of plants are less than " + globalThing.sd_above.toFixed(1) + " inches tall."; } else { var solution = 2.5; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 95% of data values fall within two standard deviations of the mean. This means that 47.5% of values fall between the mean and two standard deviations below the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located two standard deviations below the mean. Since we know that 50% of data values fall above the mean in a normal distribution, a total of 50% + 47.5% = 97.5% of values fall above " + globalThing.sd_below.toFixed(1) + ". This means that 100% - 97.5% = 2.5% of values fall below " + globalThing.sd_below.toFixed(1) + ".
Thus, 2.5% of plants are less than " + globalThing.sd_below.toFixed(1) + " inches tall."; } } if(globalThing.sd_multiplier==3) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 99.85; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 99.7% of data values fall within three standard deviations of the mean. This means that 49.85% of values fall between the mean and three standard deviations above the mean.
In this example, " + globalThing.sd_above.toFixed(1) + " is located three standard deviations above the mean. Since we know that 50% of data values fall below the mean in a normal distribution, a total of 50% + 49.85% = 99.85% of values fall below " + globalThing.sd_above.toFixed(1) + ".
Thus, 99.85% of plants are less than " + globalThing.sd_above.toFixed(1) + " inches tall."; } else { var solution = 0.15; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 99.7% of data values fall within three standard deviations of the mean. This means that 49.85% of values fall between the mean and three standard deviations below the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located three standard deviations below the mean. Since we know that 50% of data values fall above the mean in a normal distribution, a total of 50% + 49.85% = 99.85% of values fall above " + globalThing.sd_below.toFixed(1) + ". This means that 100% - 99.85% = 0.15% of values fall below " + globalThing.sd_below.toFixed(1) + ".
Thus, 0.15% of plants are less than " + globalThing.sd_below.toFixed(1) + " inches tall."; } } } //end less than if(globalThing.q_selected=="greater than") { if(globalThing.sd_multiplier==1) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 16; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 68% of data values fall within one standard deviation of the mean. This means that 34% of values fall between the mean and one standard deviation above the mean.
In this example, " + globalThing.sd_above.toFixed(1) + " is located one standard deviation above the mean. Since we know that 50% of data values fall below the mean in a normal distribution, a total of 50% + 34% = 84% of values fall below " + globalThing.sd_above.toFixed(1) + ". This means that 100% - 84% = 16% of values fall above " + globalThing.sd_above.toFixed(1) + ".
Thus, 16% of plants are greater than " + globalThing.sd_above.toFixed(1) + " inches tall."; } else { var solution = 84; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 68% of data values fall within one standard deviation of the mean. This means that 34% of values fall between the mean and one standard deviation below the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located one standard deviation below the mean. Since we know that 50% of data values fall above the mean in a normal distribution, a total of 50% + 34% = 84% of values fall above " + globalThing.sd_below.toFixed(1) + ".
Thus, 84% of plants are greater than " + globalThing.sd_below.toFixed(1) + " inches tall."; } } if(globalThing.sd_multiplier==2) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 2.5; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 95% of data values fall within two standard deviations of the mean. This means that 47.5% of values fall between the mean and two standard deviations above the mean.
In this example, " + globalThing.sd_above.toFixed(1) + " is located two standard deviations above the mean. Since we know that 50% of data values fall below the mean in a normal distribution, a total of 50% + 47.5% = 97.5% of values fall below " + globalThing.sd_above.toFixed(1) + ". This means that 100% - 97.5% = 2.5% of values fall above " + globalThing.sd_above.toFixed(1) + ".
Thus, 2.5% of plants are greater than " + globalThing.sd_above.toFixed(1) + " inches tall."; } else { var solution = 97.5; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 95% of data values fall within two standard deviations of the mean. This means that 47.5% of values fall between the mean and two standard deviations below the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located two standard deviations below the mean. Since we know that 50% of data values fall above the mean in a normal distribution, a total of 50% + 47.5% = 97.5% of values fall above " + globalThing.sd_below.toFixed(1) + ".
Thus, 97.5% of plants are greater than " + globalThing.sd_below.toFixed(1) + " inches tall."; } } if(globalThing.sd_multiplier==3) { if(globalThing.sd_selected==globalThing.sd_above) { var solution = 0.15; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 99.7% of data values fall within three standard deviations of the mean. This means that 49.85% of values fall between the mean and three standard deviations above the mean.
In this example, " + globalThing.sd_above.toFixed(1) + " is located three standard deviations above the mean. Since we know that 50% of data values fall below the mean in a normal distribution, a total of 50% + 49.85% = 99.85% of values fall below " + globalThing.sd_above.toFixed(1) + ". This means that 100% - 99.85% = 0.15% of values fall above " + globalThing.sd_above.toFixed(1) + ".
Thus, 0.15% of plants are greater than " + globalThing.sd_above.toFixed(1) + " inches tall."; } else { var solution = 99.85; document.getElementById('solution_words').innerHTML = "The Empirical Rule states that for a given dataset with a normal distribution, 99.7% of data values fall within three standard deviations of the mean. This means that 49.85% of values fall between the mean and three standard deviation below the mean.
In this example, " + globalThing.sd_below.toFixed(1) + " is located three standard deviations below the mean. Since we know that 50% of data values fall above the mean in a normal distribution, a total of 50% + 49.85% = 99.85% of values fall above " + globalThing.sd_below.toFixed(1) + ".
Thus, 99.85% of plants are greater than " + globalThing.sd_below.toFixed(1) + " inches tall."; } } } //end greater than
//toggle hide/show solution var solution_div = document.getElementById("solution_div"); solution_div.style.display = "block"; } //end massive solution() function
function gen() { var mean = Math.round(jStat.uniform.sample(20, 50)*10)/10; var sd = Math.round(jStat.uniform.sample(2, 6)*10)/10;
var sd_options = [1, 2, 3]; globalThing.sd_multiplier = sd_options[Math.floor(Math.random()*sd_options .length)];
globalThing.sd_above = mean - (-globalThing.sd_multiplier*sd); globalThing.sd_below = mean - (globalThing.sd_multiplier*sd);
sd_above_below = [globalThing.sd_above, globalThing.sd_below]; globalThing.sd_selected = sd_above_below[Math.floor(Math.random()*sd_above_below.length)];
var q_options = ["between", "less than", "greater than"]; globalThing.q_selected = q_options[Math.floor(Math.random()*q_options .length)];
if (globalThing.q_selected == "less than") { document.getElementById('scenario').innerHTML = "less than " + globalThing.sd_selected.toFixed(1); } else if (globalThing.q_selected == "greater than") { document.getElementById('scenario').innerHTML = "greater than " + globalThing.sd_selected.toFixed(1); } else { document.getElementById('scenario').innerHTML = "between " + globalThing.sd_below.toFixed(1) + " and " + globalThing.sd_above.toFixed(1); }
//fill in mean and sd in initial question document.getElementById('mean').innerHTML = mean; document.getElementById('sd').innerHTML = sd;
//toggle answer & solution to hide and clear input field var result_display = document.getElementById("words_output"); result_display.style.display = "none"; var solution_div = document.getElementById("solution_div"); solution_div.style.display = "none"; document.getElementById('answer').value = ""; } //end massive gen() function
//generate initial question gen();