PageSourceSearch

https://www.stats4stem.org/_next/static/chunks/93312.c02558070e9b3608.js

js stats4stem.org collected 2026-10-07 18:04:49 UTC 10,210 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[93312],{93312:(e,t,s)=>{s.r(t),s.d(t,{default:()=>o});var r=s(95155),l=s(12115);function a(e){return e.reduce((e,t)=>e+t,0)/e.length}function n(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;return e.toFixed(t)}let d=[{label:"Blood pressure medication",before:[148,142,136,134,138,140,132,144,150,146],after:[130,135,126,128,132,130,120,138,140,134],context:"Systolic BP before/after 8 weeks of medication"},{label:"SAT prep course",before:[1050,1120,980,1200,1100,1080,1150,1e3,1070,1140,990,1060],after:[1090,1140,1020,1210,1150,1100,1190,1050,1110,1160,1030,1100],context:"SAT scores before and after a prep course"}],i={left:50,right:50};function o(){let[e,t]=(0,l.useState)(d[0].before.join(", ")),[s,o]=(0,l.useState)(d[0].after.join(", ")),[c,x]=(0,l.useState)(.95),m=(0,l.useMemo)(()=>e.split(",").map(e=>parseFloat(e.trim())).filter(e=>!isNaN(e)),[e]),h=(0,l.useMemo)(()=>s.split(",").map(e=>parseFloat(e.trim())).filter(e=>!isNaN(e)),[s]),b=Math.min(m.length,h.length),u=(0,l.useMemo)(()=>{let e=[];for(let t=0;t<b;t++)e.push(h[t]-m[t]);return e},[m,h,b]),f=b>=2,p=f?a(u):0,j=f?function(e){let t=a(e);return Math.sqrt(e.reduce((e,s)=>e+(s-t)**2,0)/(e.length-1))}(u):0,g=f?j/Math.sqrt(b):0,N=b-1,v=f?function(e,t){let s=function(e){let t;if(e<=0)return-1/0;if(e>=1)return 1/0;if(.5===e)return 0;if(e<.02425)return(((((-.007784894002430293*(t=Math.sqrt(-2*Math.log(e)))+-.3223964580411365)*t+-2.400758277161838)*t+-2.549732539343734)*t+4.374664141464968)*t+2.938163982698783)/((((.007784695709041462*t+.3224671290700398)*t+2.445134137142996)*t+3.754408661907416)*t+1);if(!(e<=.97575))return-(((((-.007784894002430293*(t=Math.sqrt(-2*Math.log(1-e)))+-.3223964580411365)*t+-2.400758277161838)*t+-2.549732539343734)*t+4.374664141464968)*t+2.938163982698783)/((((.007784695709041462*t+.3224671290700398)*t+2.445134137142996)*t+3.754408661907416)*t+1);{let s=(t=e-.5)*t;return(((((-39.69683028665376*s+220.9460984245205)*s+-275.9285104469687)*s+138.357751867269)*s+-30.66479806614716)*s+2.506628277459239)*t/(((((-54.47609879822406*s+161.5858368580409)*s+-155.6989798598866)*s+66.80131188771972)*s+-13.28068155288572)*s+1)}}(1-(1-t)/2),r=(5*s*s*s*s*s+16*s*s*s+3*s)/96,l=(3*s*s*s*s*s*s*s+19*s*s*s*s*s+17*s*s*s-15*s)/384;return s+(s*s*s+s)/4/e+r/(e*e)+l/(e*e*e)}(N,c):0,y=v*g,k=p-y,w=p+y,S=b>=30,C=b<30?"With n < 30, check that the differences have no strong skew or outliers.":"",M=e=>{t(e.before.join(", ")),o(e.after.join(", "))},_=Math.max(3*y,2*j,1),A=p-_,F=p+_,W=e=>i.left+(e-A)/(F-A)*(600-i.left-i.right);return(0,r.jsxs)("div",{className:"mx-auto max-w-5xl rounded-xl border border-slate-200 bg-white p-6 shadow-sm",children:[(0,r.jsx)("h2",{className:"mb-4 text-xl font-bold text-slate-800",children:"Paired t-Interval for μ_d"}),(0,r.jsx)("div",{className:"mb-4 flex flex-wrap gap-2",children:d.map(e=>(0,r.jsx)("button",{onClick:()=>M(e),className:"rounded border border-slate-300 bg-slate-50 px-3 py-1 text-xs font-medium text-slate-600 hover:bg-slate-100",children:e.label},e.label))}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[340px_1fr]",children:[(0,r.jsxs)("div",{className:"space-y-4 rounded-lg border border-slate-200 bg-slate-50 p-4",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold uppercase tracking-wide text-slate-500",children:"Input Paired Data"}),(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-slate-700",children:"Before (comma-separated)"}),(0,r.jsx)("textarea",{value:e,onChange:e=>t(e.target.value),rows:2,className:"mt-1 block w-full rounded border border-slate-300 px-3 py-2 text-sm font-mono focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-slate-700",children:"After (comma-separated)"}),(0,r.jsx)("textarea",{value:s,onChange:e=>o(e.target.value),rows:2,className:"mt-1 block w-full rounded border border-slate-300 px-3 py-2 text-sm font-mono focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),(0,r.jsxs)("label",{className:"block",children:[(0,r.jsxs)("span",{className:"text-sm font-medium text-slate-700",children:["Confidence level: ",(100*c).toFixed(0),"%"]}),(0,r.jsxs)("select",{value:c,onChange:e=>x(Number(e.target.value)),className:"mt-1 block w-full rounded border border-slate-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[(0,r.jsx)("option",{value:.9,children:"90%"}),(0,r.jsx)("option",{value:.95,children:"95%"}),(0,r.jsx)("option",{value:.99,children:"99%"})]})]}),b!==m.length||b!==h.length?(0,r.jsxs)("p",{className:"text-xs text-amber-600",children:["Pairing uses the first ",b," values from each list."]}):null,(0,r.jsxs)("div",{className:"rounded bg-blue-50 border border-blue-200 p-3 text-xs text-blue-800",children:[(0,r.jsx)("strong",{children:"Key Idea:"})," We analyze the ",(0,r.jsx)("em",{children:"DIFFERENCES"}),", not the raw data. Each before/after pair produces one difference d = after − before."]})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[f&&(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:"w-full border-collapse text-sm",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"border border-slate-300 bg-slate-100 px-3 py-1",children:"Pair"}),(0,r.jsx)("th",{className:"border border-slate-300 bg-slate-100 px-3 py-1",children:"Before"}),(0,r.jsx)("th",{className:"border border-slate-300 bg-slate-100 px-3 py-1",children:"After"}),(0,r.jsx)("th",{className:"border border-slate-300 bg-blue-100 px-3 py-1 font-bold",children:"d = After − Before"})]})}),(0,r.jsx)("tbody",{children:u.map((e,t)=>(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{className:"border border-slate-300 px-3 py-1 text-center text-slate-500",children:t+1}),(0,r.jsx)("td",{className:"border border-slate-300 px-3 py-1 text-center",children:m[t]}),(0,r.jsx)("td",{className:"border border-slate-300 px-3 py-1 text-center",children:h[t]}),(0,r.jsxs)("td",{className:"border border-slate-300 px-3 py-1 text-center font-medium ".concat(e>0?"text-green-700":e<0?"text-red-700":"text-slate-600"),children:[e>0?"+":"",n(e,2)]})]},t))})]})}),f&&(0,r.jsxs)("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-4 space-y-2 text-sm text-slate-600",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold uppercase tracking-wide text-slate-500",children:"Statistics on Differences"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-x-6 gap-y-1",children:[(0,r.jsxs)("p",{children:["n = ",b]}),(0,r.jsxs)("p",{children:["df = ",N]}),(0,r.jsxs)("p",{children:["d̄ = ",(0,r.jsx)("strong",{children:n(p)})]}),(0,r.jsxs)("p",{children:["s_d = ",(0,r.jsx)("strong",{children:n(j)})]}),(0,r.jsxs)("p",{children:["SE = s_d/√n = ",(0,r.jsx)("strong",{children:n(g)})]}),(0,r.jsxs)("p",{children:["t* = ",(0,r.jsx)("strong",{children:n(v,3)})]})]}),(0,r.jsxs)("div",{className:"border-t border-slate-200 pt-2 mt-2",children:[(0,r.jsx)("p",{className:"font-medium",children:"Conditions:"}),(0,r.jsxs)("ul",{className:"ml-4 space-y-1 text-xs",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-amber-500",children:"⚠"})," Random: paired data from random sample or experiment (assumed)"]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:S?"text-green-600":"text-amber-500",children:S?"✓":"⚠"})," ","Normal: ",S?"n = ".concat(b," ≥ 30 (CLT applies)"):"n = ".concat(b," < 30. ").concat(C)]})]})]})]}),f&&(0,r.jsxs)("div",{className:"rounded-lg border border-blue-200 bg-blue-50 p-4",children:[(0,r.jsxs)("h3",{className:"text-sm font-semibold uppercase tracking-wide text-blue-700 mb-2",children:[(100*c).toFixed(0),"% Confidence Interval for μ_d"]}),(0,r.jsxs)("p",{className:"text-sm font-mono text-blue-900 mb-1",children:["d̄ \xb1 t* \xb7 (s_d / √n) = ",n(p)," \xb1 ",n(y)]}),(0,r.jsxs)("p",{className:"text-lg font-bold text-blue-900",children:["(",n(k),", ",n(w),")"]}),(0,r.jsxs)("p",{className:"mt-2 text-sm text-blue-800",children:["We are ",(100*c).toFixed(0),"% confident that the true mean difference μ_d is between ",n(k)," and ",n(w),"."]}),k>0&&(0,r.jsx)("p",{className:"mt-1 text-sm font-medium text-green-700",children:"The interval is entirely positive, suggesting a real increase."}),w<0&&(0,r.jsx)("p",{className:"mt-1 text-sm font-medium text-red-700",children:"The interval is entirely negative, suggesting a real decrease."}),k<=0&&w>=0&&(0,r.jsx)("p",{className:"mt-1 text-sm font-medium text-amber-700",children:"The interval contains 0 — no significant difference at this confidence level."})]}),f&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"mb-1 text-sm font-semibold uppercase tracking-wide text-slate-500",children:"Confidence Interval on Number Line"}),(0,r.jsxs)("svg",{viewBox:"0 0 ".concat(600," ").concat(120),className:"w-full h-auto","aria-label":"Number line showing confidence interval",children:[(0,r.jsx)("line",{x1:i.left,y1:60,x2:600-i.right,y2:60,stroke:"#94a3b8",strokeWidth:1}),A<0&&F>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("line",{x1:W(0),y1:40,x2:W(0),y2:80,stroke:"#94a3b8",strokeWidth:1,strokeDasharray:"3,3"}),(0,r.jsx)("text",{x:W(0),y:92,textAnchor:"middle",fill:"#64748b",fontSize:10,
1children:"0"})]}),(0,r.jsx)("line",{x1:W(k),y1:60,x2:W(w),y2:60,stroke:"#2563eb",strokeWidth:4}),(0,r.jsx)("line",{x1:W(k),y1:50,x2:W(k),y2:70,stroke:"#2563eb",strokeWidth:2}),(0,r.jsx)("line",{x1:W(w),y1:50,x2:W(w),y2:70,stroke:"#2563eb",strokeWidth:2}),(0,r.jsx)("text",{x:W(k),y:46,textAnchor:"middle",fill:"#2563eb",fontSize:10,children:n(k)}),(0,r.jsx)("text",{x:W(w),y:46,textAnchor:"middle",fill:"#2563eb",fontSize:10,children:n(w)}),(0,r.jsx)("circle",{cx:W(p),cy:60,r:5,fill:"#1d4ed8"}),(0,r.jsxs)("text",{x:W(p),y:92,textAnchor:"middle",fill:"#1d4ed8",fontSize:10,fontWeight:"bold",children:["d̄ = ",n(p)]})]})]}),!f&&(0,r.jsx)("div",{className:"flex items-center justify-center h-40 text-slate-400 text-sm",children:"Enter at least 2 paired values above"})]})]})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.