二项分布可视化与参数探索
2013-09-23 04:08
本 GeoGebra 范例演示二项分布的概率质量函数。用户可通过输入框调整试验次数 n 和成功概率 p,实时观察概率柱状图的变化。界面标注了均值 μ 和标准差 σ 的位置,并显示最大概率值。通过 Sequence 和 PolyLine 命令绘制概率条形图,帮助学习者直观理解二项分布的形状、集中趋势与离散程度,是概率统计教学的实用交互工具。
<?xml version="1.0" encoding="utf-8"?>
<geogebra format="5.0" version="5.0.200.0" id="0dd31ea6-75f4-4b32-a8c0-05ed1d6de682" xsi:noNamespaceSchemaLocation="http://www.geogebra.org/ggb.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<gui>
<window width="800" height="600" />
<perspectives>
<perspective id="tmp">
<panes>
<pane location="" divider="0.25" orientation="1" />
</panes>
<views>
<view id="4097" visible="false" inframe="true" stylebar="true" location="1,1,1" size="400" window="4,350,1418,550" />
<view id="512" toolbar="0 | 1 501 5 19 , 67 | 2 15 45 18 , 7 37 | 514 3 9 , 13 44 , 47 | 16 | 551 550 11 , 20 22 21 23 , 55 56 57 , 12 | 69 | 510 511 , 512 513 | 533 531 , 534 532 , 522 523 , 537 536 , 535 | 521 520 | 36 , 38 49 560 | 571 30 29 570 31 33 | 17 | 540 40 41 42 , 27 28 35 , 6 , 502" visible="false" inframe="false" stylebar="false" location="1,1,1" size="500" window="100,100,600,400" />
<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="false" 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="1" size="789" window="100,100,600,400" />
<view id="2" visible="false" inframe="true" stylebar="true" location="3" size="200" window="1029,93,250,400" />
<view id="16" visible="false" inframe="false" stylebar="false" location="1" size="150" 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" toolbar="0" 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"/>
</gui>
<euclidianView>
<viewNumber viewNo="1"/>
<size width="789" height="467"/>
<coordSystem xZero="248.65459090909098" yZero="280.52350000000007" scale="60.63750000000001" yscale="60.6375000000001"/>
<evSettings axes="false" grid="false" gridIsBold="false" pointCapturing="3" rightAngleStyle="1" checkboxSize="13" 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>
<algebraView>
<auxiliary show="true"/>
</algebraView>
<kernel>
<continuous val="false"/>
<usePathAndRegionParameters val="true"/>
<decimals val="2"/>
<angleUnit val="degree"/>
<algebraStyle val="0" spreadsheet="0"/>
<coordStyle val="0"/>
<angleFromInvTrig val="false"/>
</kernel>
<scripting blocked="false" disabled="false"/>
<construction title="" author="" date="">
<expression label="borderW" exp="x(Corner[3] - Corner[4])" />
<element type="numeric" label="borderW">
<value val="13.044733044733043"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="borderH" exp="y(Corner[3] - Corner[2])" />
<element type="numeric" label="borderH">
<value val="7.734487734487722"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<element type="numeric" label="paddingPercent">
<value val="10.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>
<command name="Min">
<input a0="(borderH * paddingPercent / 100)" a1="(borderW * paddingPercent / 100)"/>
<output a0="padding"/>
</command>
<element type="numeric" label="padding">
<value val="0.7734487734487723"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="O" exp="Corner[1] + (padding * (1, 1))" type="point" />
<element type="point" label="O">
<show object="false" label="true" ev="4"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<coords x="-3.3437161972226925" y="-2.3183096268810504" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="3"/>
</element>
<expression label="frameW" exp="borderW - (2 * padding)" />
<element type="numeric" label="frameW">
<value val="11.4978354978355"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="frameH" exp="borderH - (2 * padding)" />
<element type="numeric" label="frameH">
<value val="6.187590187590177"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="PolyLine">
<input a0="O" a1="O + (frameW, 0)" a2="O + (frameW, frameH)" a3="O + (0, frameH)" a4="O"/>
<output a0="frame"/>
</command>
<element type="polyline" label="frame">
<lineStyle thickness="3" type="0" typeHidden="1"/>
<show object="true" label="false"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
</element>
<element type="numeric" label="n">
<value val="21.0"/>
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<slider min="1" max="50" absoluteScreenLocation="true" width="200.0" x="198.0" y="33.0" fixed="false" horizontal="true" showAlgebra="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<animation step="1" speed="1" type="0" playing="false"/>
</element>
<element type="numeric" label="p">
<value val="0.6"/>
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
<layer val="0"/>
<labelMode val="1"/>
<slider min="0" max="1" absoluteScreenLocation="true" width="150.0" x="589.0" y="33.0" fixed="false" horizontal="true" showAlgebra="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<animation step="0.01" speed="1" type="0" playing="false"/>
</element>
<expression label="q" exp="1 - p" />
<element type="numeric" label="q">
<value val="0.4"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="μ" exp="(n * p)" />
<element type="numeric" label="μ">
<value val="12.6"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="σ" exp="sqrt(((n * p) * q))" />
<element type="numeric" label="σ">
<value val="2.244994432064365"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="Segment">
<input a0="O + (0, padding)" a1="O + (frameW, padding)"/>
<output a0="lineX"/>
</command>
<element type="segment" label="lineX">
<show object="true" label="false"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<coords x="0.0" y="11.4978354978355" z="17.762555959810093"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<expression label="dx" exp="frameW / (n + 2)" />
<element type="numeric" label="dx">
<value val="0.4999058912102391"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="Sequence">
<input a0="O + (((k + 1) * dx), padding)" a1="k" a2="0" a3="n"/>
<output a0="pointsX"/>
</command>
<element type="list" label="pointsX">
<show object="false" label="false" ev="4"/>
<objColor r="0" g="100" b="0" alpha="0.0"/>
<bgColor r="255" g="255" b="255" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<element type="point" label="XLabelOffset">
<show object="false" label="true"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<layer val="0"/>
<labelMode val="0"/>
<animation step="0.05" speed="1" type="1" playing="false"/>
<coords x="-0.05" y="-0.2" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<command name="Sequence">
<input a0="Text[k - 1, Element[pointsX, k] + XLabelOffset]" a1="k" a2="1" a3="n + 1"/>
<output a0="labelsX"/>
</command>
<element type="list" label="labelsX">
<show object="true" label="false"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<bgColor r="255" g="255" b="255" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
<font serif="false" sizeM="1.0" size="0" style="1"/>
</element>
<command name="Sequence">
<input a0="((Binomial[n, k] * p^(k)) * q^(n - k))" a1="k" a2="0" a3="n"/>
<output a0="prob"/>
</command>
<element type="list" label="prob">
<objColor r="0" g="100" b="0" alpha="0.1"/>
<bgColor r="255" g="255" b="255" alpha="255"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Max">
<input a0="prob"/>
<output a0="probMax"/>
</command>
<element type="numeric" label="probMax">
<value val="0.1741763789006989"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="probH" exp="frameH - (2 * padding)" />
<element type="numeric" label="probH">
<value val="4.640692640692633"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<command name="Sequence">
<input a0="(probH * Element[prob, k + 1] / probMax)" a1="k" a2="0" a3="n"/>
<output a0="probY"/>
</command>
<element type="list" label="probY">
<objColor r="0" g="100" b="0" alpha="0.1"/>
<bgColor r="255" g="255" b="255" alpha="255"/>
<selectionAllowed val="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Sequence">
<input a0="Segment[Element[pointsX, k + 1], Element[pointsX, k + 1] + (0, Element[probY, k + 1])]" a1="k" a2="0" a3="n"/>
<output a0="probBars"/>
</command>
<element type="list" label="probBars">
<show object="true" label="false"/>
<condition showObject="¬toggleBars"/>
<objColor r="0" g="0" b="255" alpha="0.0"/>
<bgColor r="255" g="255" b="255" alpha="255"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="5" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<command name="Textfield">
<input a0="n"/>
<output a0="inputN"/>
</command>
<element type="textfield" label="inputN">
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="45" y="15"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<linkedGeo exp="n"/>
<length val="5"/>
<caption val="n ="/>
</element>
<command name="Textfield">
<input a0="p"/>
<output a0="inputP"/>
</command>
<element type="textfield" label="inputP">
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="0"/>
<labelOffset x="492" y="15"/>
<labelMode val="0"/>
<animation step="1" speed="1" type="0" playing="false"/>
<auxiliary val="true"/>
<linkedGeo exp="p"/>
<length val="5"/>
<caption val="p ="/>
</element>
<element type="numeric" label="barWidthRatio">
<value val="0.5"/>
<show object="true" label="false"/>
<condition showObject="toggleBars"/>
<objColor r="0" g="0" b="255" alpha="0.1"/>
<layer val="0"/>
<labelMode val="3"/>
<slider min="0.05" max="0.5" absoluteScreenLocation="true" width="100.0" x="627.0" y="448.0" fixed="false" horizontal="true" showAlgebra="false"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<animation step="0.05" speed="1" type="0" playing="false"/>
<caption val="長條寬度"/>
</element>
<command name="Sequence">
<input a0="Polygon[Element[pointsX, k + 1] - (barWidthRatio * (dx, 0)), Element[pointsX, k + 1] + (barWidthRatio * (dx, 0)), Element[pointsX, k + 1] + ((barWidthRatio * dx), Element[probY, k + 1]), Element[pointsX, k + 1] + (((-barWidthRatio) * dx), Element[probY, k + 1])]" a1="k" a2="0" a3="n"/>
<output a0="bars"/>
</command>
<element type="list" label="bars">
<show object="true" label="false" ev="4"/>
<condition showObject="toggleBars"/>
<objColor r="0" g="0" b="255" alpha="0.25"/>
<bgColor r="255" g="255" b="255" alpha="255"/>
<layer val="0"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<lineStyle thickness="1" type="0" typeHidden="1"/>
<pointSize val="3"/>
<pointStyle val="-1"/>
</element>
<element type="boolean" label="toggleBars">
<value val="true"/>
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelOffset x="533" y="437"/>
<labelMode val="0"/>
<checkbox fixed="true"/>
<caption val="顯示長條"/>
</element>
<expression label="txtMaxProb" exp=""" + (LaTeX[probMax]) + """ />
<element type="text" label="txtMaxProb">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1.0" size="0" style="1"/>
<decimals val="4"/>
<startPoint exp="Element[pointsX, xMaxP + 1] + (0, Element[probY, xMaxP + 1])"/>
<labelOffset x="-20" y="-41"/>
</element>
<expression label="xMaxP" exp="floor(((n + 1) * p))" />
<element type="numeric" label="xMaxP">
<value val="13.0"/>
<objColor r="0" g="0" b="0" alpha="0.1"/>
</element>
<expression label="P_μ" exp="O + (((μ + 1) * dx), padding / 2)" type="point" />
<element type="point" label="P_μ">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<coords x="3.4550039232365592" y="-1.9315852401566642" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="6"/>
</element>
<expression label="txtMu" exp=""μ=" + (LaTeX[μ]) + """ />
<element type="text" label="txtMu">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1.0" size="0" style="0"/>
<startPoint exp="P_μ"/>
<labelOffset x="-19" y="2"/>
</element>
<expression label="P_{-σ}" exp="O + (((μ - σ + 1) * dx), padding / 2)" type="point" />
<element type="point" label="P_{-σ}">
<show object="true" label="false"/>
<condition showObject="showSD"/>
<objColor r="255" g="127" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<coords x="2.3327179809133978" y="-1.9315852401566642" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="6"/>
</element>
<expression label="P_{σ}" exp="O + (((μ + σ + 1) * dx), padding / 2)" type="point" />
<element type="point" label="P_{σ}">
<show object="true" label="false"/>
<condition showObject="showSD"/>
<objColor r="255" g="127" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<coords x="4.57728986555972" y="-1.9315852401566642" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="6"/>
</element>
<command name="Segment">
<input a0="P_{-σ} + (0, padding / 2)" a1="P_{-σ} + (0, padding / 2 + probH)"/>
<output a0="seg_{-σ}"/>
</command>
<element type="segment" label="seg_{-σ}">
<show object="true" label="false"/>
<condition showObject="showSD"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<coords x="-4.640692640692633" y="0.0" z="10.825427166836182"/>
<lineStyle thickness="2" type="20" typeHidden="1"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<command name="Segment">
<input a0="P_{σ} + (0, padding / 2)" a1="P_{σ} + (0, padding / 2 + probH)"/>
<output a0="seg_{σ}"/>
</command>
<element type="segment" label="seg_{σ}">
<show object="true" label="false"/>
<condition showObject="showSD"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<coords x="-4.640692640692633" y="0.0" z="21.241795393419963"/>
<lineStyle thickness="2" type="20" typeHidden="1"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
<expression label="PinText_{σ}" exp="Midpoint[P_{-σ}, P_μ] + (0, probH + padding / 2)" type="point" />
<element type="point" label="PinText_{σ}">
<show object="false" label="true"/>
<objColor r="68" g="68" b="68" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<coords x="2.8938609520749785" y="3.0958317872603542" z="1.0"/>
<pointSize val="3"/>
<pointStyle val="0"/>
</element>
<command name="Vector">
<input a0="PinText_{σ}" a1="PinText_{σ} + (dx * (σ / 2, 0))"/>
<output a0="u"/>
</command>
<element type="vector" label="u">
<show object="true" label="false"/>
<condition showObject="showSD"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<coords x="0.5611429711615803" y="0.0" z="0.0"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<coordStyle style="cartesian"/>
<startPoint exp="PinText_{σ}"/>
</element>
<command name="Vector">
<input a0="PinText_{σ}" a1="PinText_{σ} + (dx * (((-σ)) / 2, 0))"/>
<output a0="v"/>
</command>
<element type="vector" label="v">
<show object="true" label="false"/>
<condition showObject="showSD"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<coords x="-0.5611429711615803" y="0.0" z="0.0"/>
<lineStyle thickness="2" type="0" typeHidden="1"/>
<coordStyle style="cartesian"/>
<startPoint exp="PinText_{σ}"/>
</element>
<expression label="txtSigma" exp=""σ=" + (LaTeX[σ]) + """ />
<element type="text" label="txtSigma">
<show object="true" label="false"/>
<condition showObject="showSD"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<isLaTeX val="true"/>
<font serif="true" sizeM="1.0" size="0" style="0"/>
<decimals val="2"/>
<startPoint exp="PinText_{σ}"/>
<labelOffset x="-24" y="-23"/>
</element>
<element type="boolean" label="showSD">
<value val="false"/>
<show object="true" label="true"/>
<objColor r="0" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelOffset x="39" y="437"/>
<labelMode val="0"/>
<checkbox fixed="true"/>
<caption val="標準差"/>
</element>
<command name="Segment">
<input a0="P_μ + (0, padding / 2)" a1="P_μ + (0, padding / 2 + probH)"/>
<output a0="seg_{μ}"/>
</command>
<element type="segment" label="seg_{μ}">
<show object="true" label="false"/>
<objColor r="255" g="0" b="0" alpha="0.0"/>
<layer val="1"/>
<labelMode val="0"/>
<selectionAllowed val="false"/>
<coords x="-4.640692640692633" y="0.0" z="16.033611280128074"/>
<lineStyle thickness="2" type="20" typeHidden="1"/>
<outlyingIntersections val="false"/>
<keepTypeOnTransform val="true"/>
</element>
</construction>
</geogebra>