Binomial Distribution and Sampling
2013-12-13 01:05
This applet demonstrates the relationship between binomial distribution and sampling. Assuming an infinite population with a success proportion of p, a sample of size n is drawn. By setting the number of sampling trials, the graph displays the actual distribution of the number of successes and compares it visually with the theoretical binomial distribution, helping to understand probability distri
Loading the GeoGebra board and drawing, please wait…
<?xml version="1.0" encoding="utf-8"?>
<geogebra format="4.4" version="4.4.0.0" id="d895bbbf-1aa2-4338-b3e5-6d07ea7a127a" xsi:noNamespaceSchemaLocation="http://www.geogebra.org/ggb.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<gui>
<window width="821" height="642" />
<perspectives>
<perspective id="tmp">
<panes>
<pane location="" divider="0.6588785046728972" orientation="0" />
</panes>
<views>
<view id="4097" visible="false" inframe="true" stylebar="true" location="1,1,1" size="400" window="740,150,700,750" />
<view id="4" toolbar="0 59 || 2020 , 2021 , 2022 , 66 || 2001 , 2003 , 2002 , 2004 , 2005 || 2040 , 2041 , 2042 , 2044 , 2043" visible="false" inframe="false" stylebar="true" location="1,1" size="300" window="100,100,600,400" />
<view id="8" toolbar="1001 | 1002 | 1003 || 1005 | 1004 || 1006 | 1007 | 1010 | 1011 || 1008 1009 || 6" visible="false" inframe="false" stylebar="false" location="1,3" size="300" window="100,100,600,400" />
<view id="1" visible="true" inframe="false" stylebar="true" location="0" size="423" window="100,100,600,400" />
<view id="2" visible="false" inframe="true" stylebar="true" location="3" size="200" window="893,24,250,802" />
<view id="16" visible="true" inframe="false" stylebar="false" location="2" size="100" window="50,50,500,500" />
<view id="32" visible="false" inframe="false" stylebar="true" location="1" size="150" window="50,50,500,500" />
<view id="64" visible="false" inframe="true" stylebar="true" location="1" size="150" window="50,50,500,500" />
<view id="70" toolbar="0 || 2020 || 2021 || 2022" visible="false" inframe="true" stylebar="true" location="1" size="150" window="50,50,500,500" />
</views>
<toolbar show="true" items="0 39 59 | 1 501 67 , 5 19 , 72 | 2 15 45 , 18 65 , 7 37 | 4 3 8 9 , 13 44 , 58 , 47 | 16 51 64 , 70 | 10 34 53 11 , 24 20 22 , 21 23 | 55 56 57 , 12 | 36 46 , 38 49 50 , 71 | 30 29 54 32 31 33 | 17 26 62 73 , 14 66 68 | 25 52 60 61 | 40 41 42 , 27 28 35 , 6" position="1" help="false" />
<input show="true" cmd="true" top="false" />
<dockBar show="true" east="true" />
</perspective>
</perspectives>
<labelingStyle val="3"/>
<font size="12"/>
<graphicsSettings javaLatexFonts="false"/>
</gui>
<euclidianView>
<size width="810" height="377"/>
<coordSystem xZero="213.5171645133878" yZero="218.02789214460557" scale="17.021866078181993" yscale="17.021866078182004"/>
<evSettings axes="false" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="26" gridType="0"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="1" grid="10"/>
<axis id="0" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
<axis id="1" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true"/>
</euclidianView>
<euclidianView>
<viewNumber viewNo="2"/>
<size width="810" height="81"/>
<coordSystem xZero="215.00000000000009" yZero="315.00000000000006" scale="50.00000000000002" yscale="50.00000000000002"/>
<evSettings axes="false" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="26" gridType="0"/>
<bgColor r="255" g="255" b="255"/>
<axesColor r="0" g="0" b="0"/>
<gridColor r="192" g="192" b="192"/>
<lineStyle axes="1" grid="10"/>
<axis id="0" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true" tickDistance="0.5"/>
<axis id="1" show="false" label="" unitLabel="" tickStyle="1" showNumbers="true" tickDistance="0.5"/>
</euclidianView>
<kernel>
<continuous val="false"/>
<usePathAndRegionParameters val="true"/>
<decimals val="2"/>
<angleUnit val="degree"/>
<algebraStyle val="0"/>
<coordStyle val="0"/>
<angleFromInvTrig val="false"/>
</kernel>
<scripting blocked="false" disabled="false"/>
<construction title="" author="" date="">
<element type="numeric" label="pad">
<value val="0.05"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<element type="numeric" label="maxNum">
<value val="1.0"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<slider min="1" max="20" absoluteScreenLocation="true" width="200.0" x="0.0" y="0.0" fixed="false" horizontal="true"/>
<lineStyle thickness="10" type="0" typeHidden="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
<javascript onUpdate="resample();"/>
</element>
<command name="Corner">
<input a0="5"/>
<output a0="Pixels"/>
</command>
<element type="point" label="Pixels">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="810.0" y="377.0" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<command name="Sequence">
<input a0="k" a1="k" a2="0" a3="maxNum"/>
<output a0="numbers"/>
</command>
<element type="list" label="numbers">
<objColor r="0" g="100" b="0" alpha="0.1"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="LaTeX">
<input a0="numbers" a1="true" a2="false"/>
<output a0="txtMaxNum"/>
</command>
<element type="text" label="txtMaxNum">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1.4" size="5" style="0"/>
<absoluteScreenLocation x="161" y="9"/>
</element>
<element type="numeric" label="numVar">
<value val="50.0"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<slider min="2" max="100" absoluteScreenLocation="true" width="200.0" x="0.0" y="0.0" fixed="false" horizontal="true"/>
<lineStyle thickness="10" type="0" typeHidden="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
<javascript onUpdate="resample();"/>
</element>
<element type="numeric" label="times">
<value val="500.0"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<slider min="10" max="2000" absoluteScreenLocation="true" width="200.0" x="0.0" y="0.0" fixed="false" horizontal="true"/>
<lineStyle thickness="10" type="0" typeHidden="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
<javascript onUpdate="resample();"/>
</element>
<expression label="winW" exp="x(Corner[2] - Corner[1])" />
<element type="numeric" label="winW">
<value val="47.7033479332088"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="winH" exp="y(Corner[4] - Corner[1])" />
<element type="numeric" label="winH">
<value val="22.265478899859758"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="pixelsPerUnitX" exp="x(Pixels) / winW" />
<element type="numeric" label="pixelsPerUnitX">
<value val="16.979940299664303"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="pixelsPerUnitY" exp="y(Pixels) / winH" />
<element type="numeric" label="pixelsPerUnitY">
<value val="16.932040927373656"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="unitsPerPixelX" exp="1 / pixelsPerUnitX" />
<element type="numeric" label="unitsPerPixelX">
<value val="0.058893022139763954"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="unitsPerPixelY" exp="1 / pixelsPerUnitY" />
<element type="numeric" label="unitsPerPixelY">
<value val="0.05905962572907098"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="padPixels" exp="(pad * x(Pixels))" />
<element type="numeric" label="padPixels">
<value val="40.5"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="A" exp="Corner[1] + (padPixels * (unitsPerPixelX, unitsPerPixelY))" type="point" />
<element type="point" label="A">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-10.217279569383315" y="-7.006121020823216" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<expression label="B" exp="Corner[1] + (((x(Pixels) - padPixels) * unitsPerPixelX), (padPixels * unitsPerPixelY))" type="point" />
<element type="point" label="B">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="32.715733570504604" y="-7.006121020823216" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<expression label="C" exp="Corner[1] + (((x(Pixels) - padPixels) * unitsPerPixelX), ((y(Pixels) - padPixels) * unitsPerPixelY))" type="point" />
<element type="point" label="C">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="32.715733570504604" y="10.475528194981795" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<expression label="D" exp="Corner[1] + ((padPixels * unitsPerPixelX), ((y(Pixels) - padPixels) * unitsPerPixelY))" type="point" />
<element type="point" label="D">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-10.217279569383315" y="10.475528194981795" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<expression label="figW" exp="x(B - A)" />
<element type="numeric" label="figW">
<value val="42.93301313988792"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="figH" exp="y(D - A)" />
<element type="numeric" label="figH">
<value val="17.48164921580501"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="E" exp="A + (0, (padPixels * unitsPerPixelY))" type="point" />
<element type="point" label="E">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-10.217279569383315" y="-4.6142061787958415" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<expression label="F" exp="B + (0, (padPixels * unitsPerPixelY))" type="point" />
<element type="point" label="F">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="32.715733570504604" y="-4.6142061787958415" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<expression label="maxX" exp="(maxNum * numVar)" />
<element type="numeric" label="maxX">
<value val="50.0"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="dW" exp="figW / (maxX + 1)" />
<element type="numeric" label="dW">
<value val="0.8418237870566259"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="Sequence">
<input a0="E + (dW / 2 + (k * dW), 0)" a1="k" a2="0" a3="maxX"/>
<output a0="ticksX"/>
</command>
<element type="list" label="ticksX">
<show object="false" label="false"/>
<objColor r="0" g="100" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<element type="button" label="run">
<show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="1.0"/>
<bgColor r="255" g="102" b="153" alpha="255"/>
<layer val="0"/>
<labelOffset x="590" y="15"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<javascript val="resample();"/>
<font serif="true" sizeM="1.0" size="0" style="0"/>
<file name="/geogebra/main/nav_play.png"/>
</element>
<expression label ="sample" exp="{0, 0, 0, 0, 0, 3, 0, 1, 7, 15, 27, 21, 52, 62, 59, 52, 38, 47, 44, 34, 18, 9, 4, 4, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}"/>
<element type="list" label="sample">
<objColor r="0" g="100" b="0" alpha="0.1"/>
<animation step="1" speed="1" type="0" playing="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<element type="numeric" label="maxFreq">
<value val="62.0"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<expression label="maxH" exp="((y(Pixels) - (4 * padPixels)) * unitsPerPixelY)" />
<element type="numeric" label="maxH">
<value val="12.69781953175026"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="Sequence">
<input a0="Element[ticksX, k] + (0, (Element[sample, k] * maxH / maxFreq))" a1="k" a2="1" a3="maxX + 1"/>
<output a0="ticksY"/>
</command>
<element type="list" label="ticksY">
<show object="false" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="4"/>
<pointStyle val="0"/>
</element>
<command name="Sequence">
<input a0="Segment[Element[ticksX, k], Element[ticksY, k]]" a1="k" a2="1" a3="maxX + 1"/>
<output a0="poles"/>
</command>
<element type="list" label="poles">
<show object="true" label="false"/>
<objColor r="125" g="125" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Textfield">
<input a0="times"/>
<output a0="inSampleSize"/>
</command>
<element type="textfield" label="inSampleSize">
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="440" y="15"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<ggbscript val=""/>
<linkedGeo exp="times"/>
<length val="3"/>
<caption val="抽樣次數:"/>
</element>
<command name="Textfield">
<input a0="numVar"/>
<output a0="inNumVar"/>
</command>
<element type="textfield" label="inNumVar">
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="290" y="15"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<ggbscript val=""/>
<linkedGeo exp="numVar"/>
<length val="3"/>
<caption val="樣本大小:"/>
</element>
<command name="Segment">
<input a0="E" a1="F"/>
<output a0="segX"/>
</command>
<element type="segment" label="segX">
<show object="true" label="false"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<coords x="0.0" y="42.93301313988792" z="198.1017745043939"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Sequence">
<input a0=""X_" + (k)" a1="k" a2="1" a3="numVar"/>
<output a0="strVars"/>
</command>
<element type="list" label="strVars">
<show object="false" label="false"/>
<objColor r="0" g="100" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<expression label="strRV" exp=""X=X_1" + (Sum[Sequence["+" + (Element[strVars, k]), k, 2, numVar]])" />
<element type="text" label="strRV">
<show object="false" label="false"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<startPoint x="12.637925620018397" y="-4.014139039917159" z="1.0"/>
</element>
<element type="point" label="OffPixels">
<show object="false" label="true"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<animation step="0.1" speed="1" type="1" playing="false"/>
<coords x="-5.0" y="-20.0" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<element type="numeric" label="p">
<value val="0.3"/>
<show object="false" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="1"/>
<labelMode val="1"/>
<slider min="0" max="1" absoluteScreenLocation="true" width="100.0" x="0.0" y="0.0" fixed="false" horizontal="true"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<animation step="0.01" speed="1" type="0" playing="false"/>
<javascript onUpdate="resample();"/>
</element>
<command name="Textfield">
<input a0="p"/>
<output a0="inP"/>
</command>
<element type="textfield" label="inP">
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="140" y="15"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<linkedGeo exp="p"/>
<length val="3"/>
<caption val="母體比例:"/>
</element>
<command name="Max">
<input a0="1" a1="ceil(maxX / 30)"/>
<output a0="padX"/>
</command>
<element type="numeric" label="padX">
<value val="2.0"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="Sequence">
<input a0="Text[k - 1, Element[ticksX, k] + ((x(OffPixels) * unitsPerPixelX), (y(OffPixels) * unitsPerPixelY))]" a1="k" a2="1" a3="maxX + 1" a4="padX"/>
<output a0="txtX"/>
</command>
<element type="list" label="txtX">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<expression label="q" exp="1 - p" />
<element type="numeric" label="q">
<value val="0.7"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="Sequence">
<input a0="Element[ticksX, k + 1] + (0, ((((times * Binomial[numVar, k]) * p^(k)) * q^(numVar - k)) * maxH / maxFreq))" a1="k" a2="0" a3="maxX"/>
<output a0="BinoProb"/>
</command>
<element type="list" label="BinoProb">
<show object="true" label="false"/>
<condition showObject="a"/>
<objColor r="255" g="204" b="51" alpha="0.0"/>
<layer val="2"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<element type="boolean" label="a">
<value val="true"/>
<show object="true" label="true" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="2"/>
<labelOffset x="10" y="10"/>
<labelMode val="0"/>
<caption val="顯示理論值"/>
</element>
<expression label=""" + (FormulaText[strRV]) + """ exp=""" + (LaTeX[strRV]) + """ />
<element type="text" label=""" + (FormulaText[strRV]) + """>
<show object="true" label="false" ev="3"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="2"/>
<labelMode val="0"/>
<isLaTeX val="true"/>
<font serif="false" sizeM="1.0" size="0" style="0"/>
</element>
</construction>
</geogebra>