有人知道如何使用 pstricks 或 tikz 绘制非中心 t 分布吗pst-fun
?对于中心 t,pst-fun
有函数psTDist
,但我可以找到一种方法向其添加 $\delta$ ncp。
对于中央 t 来说,它相当直:
\documentclass[border=5mm]{standalone}
\usepackage{pst-plot,pst-func}
\begin{document}
\psset{xunit=1cm,yunit=7.5cm}
\begin{pspicture}(-5.25,-0.05)(5.25,0.5)
% Valor de corte z
\newcommand\z{1.3}
%Dist
\psTDist[nue=9,yunit=1]{\z}{4}
\end{pspicture}
\end{document}
我想知道我是否只需要生成非中心 t 分布并绘制重叠点。
谢谢!
答案1
使用新版本的pst-func
。这可能正确吗?这些方程式并不简单……
(例如 nue -> n)
\psset{xunit=1.25cm,yunit=7.5cm}
\begin{pspicture}(-6,-0.1)(6,0.7)
\psaxes[Dy=0.1]{->}(0,0)(-4.5,0)(5.5,0.5)
\psset{linewidth=1.5pt,plotpoints=100}
\psNonCentralTDist[linecolor=red,nue=4]{-4}{5}
\psNonCentralTDist[linecolor=blue,nue=4,lambda=2]{-4}{5}
\end{pspicture}
答案2
所以,这就是我所做的......不确定这是否是更简约的方式但是......
\documentclass[border=5mm]{standalone}
\usepackage{pst-plot,pst-func}
\begin{document}
\definecolor{fillColor}{RGB}{125, 185, 250}
\psset{xunit=1cm,yunit=7.5cm}
\begin{pspicture}[algebraic](-4,-0.05)(8,0.5)
% Valor de corte z
\newcommand\z{1.833}
\def\pdfT#1{\fpeval{1/(sqrt(2*pi))*exp(-0.5*(#1)^2)}}
%Dist
\pscustom[fillstyle=solid,fillcolor=fillColor!30,linestyle=none]{%
%\psline(-2,0)
\psTDist[nue=9,yunit=1]{\z}{4}
\psline(\z,0)}
%\psTDist[linewidth=1pt,linecolor=fillColor!120,nue=9,yunit=1]{-4}{4}
%NonCentral
\savedata{\mydata}[
-4,4.95603884931306e-07
-3.75,8.27266484115796e-07
-3.5,1.41017659064221e-06
-3.25,2.45724910327064e-06
-3,4.38081829512438e-06
-2.75,7.99628465696469e-06
-2.5,1.49489511813261e-05
-2.25,2.86209005229132e-05
-2,5.60761577907409e-05
-1.75,0.000112246283638675
-1.5,0.000228885682700408
-1.25,0.000473385461861131
-1,0.000986904571583903
-0.75,0.00205706746253531
-0.5,0.00424346475653148
-0.25,0.00856135144220627
0,0.0166768245538877
0.25,0.0309605598258274
0.5,0.0541363810101856
0.75,0.0883066522197213
1,0.133507678070106
1.25,0.186520662362244
1.5,0.240892502696099
1.75,0.288544668758476
1.833,0.3015716
2,0.32229011250974
2.25,0.337962254785326
2.5,0.335200493792012
2.75,0.316828855923198
3,0.287451252549856
3.25,0.252010187554509
3.5,0.214775358753859
3.75,0.178873351874724
4,0.146242775800368
4.25,0.117829676682817
4.5,0.0938663221305527
4.75,0.0741367598730511
5,0.058186348552428
5.25,0.0454670983318004
5.5,0.035427681827488
5.75,0.0275623914314711
6,0.0214327192008265
6.25,0.0166723370299849
6.5,0.0129830403846555
6.75,0.0101265191618662
7,0.00791484135400984
7.25,0.0062012107493628
7.5,0.00487173441525535
7.75,0.00383845547186056
8,0.00303364899963482
]
\pscustom[fillstyle=solid, fillcolor=gray!15,linestyle=none,opacity=0.1]{
\listplot[plotstyle=curve,showpoints=false,linecolor=darkgray,xEnd=1.833]{\mydata}
\psline(\z,0)
}
\listplot[plotstyle=curve,showpoints=false,linecolor=darkgray!85]{\mydata}
\psTDist[linewidth=1pt,linecolor=fillColor!120,nue=9,yunit=1]{-4}{4}
\psline[linewidth=0.75pt,linecolor=gray!75](\z,-0.015)(\z,\pdfT{0.0})
\pcline[linewidth=0.75pt,linecolor=gray!75]{*->}(\z,\pdfT{0.0})(6,\pdfT{0.0})\ncput{\colorbox{white}{\ttfamily Região de Rejeição}}
%Alfa e Beta
\psline[linearc=.90]{*->}(2.1,0.025)(2.25,0.05)(2.5,0.07)\uput[0](2.4,0.07){$\alpha$}
\psline[linearc=.90]{*->}(1.1,0.05)(0.85,0.085)(0.2,0.1)\uput[0](-0.25,0.1){$\beta$}
\uput[0](2,0.175){$1-\beta$}
\psline[linearc=.90]{->}(-1.6,0.3)(-1.3,0.3)(-1.,0.25)
\rput[0](-2.5,0.3){\ttfamily \small \shortstack[c]{Distribuição\\Amostral\\sob $H_0$}}
\psline[linearc=.90]{->}(4.7,0.2)(4.35,0.19)(4,0.16)
\rput[0](5.6,0.2){\ttfamily \small \shortstack[c]{Distribuição\\Amostral\\sob $H_1$}}
%Axes
\psaxes[Dx=1, yAxis=false,xLabels={-4,,-2,,0,,,,4,,6}]{->}(0,0)(-4,0)(8,0.5)
%\psaxes[Dy=0.1,labels=none, ticks=none, xAxis=false,linewidth=0.5pt]{->}(0,0)(-4,0)(4,0.5)
%Labels
\uput[-90](7.75,-.01){$T$}
%\uput[-150](-0.1,0.5){$f(t)$}
\uput[-90](\z,-0.01){$\, t_{0.95; (9)}$}
\uput[-10](-4.6,0.5){\ttfamily \textbf{Teste Unilateral à Direita}}
\end{pspicture}
\end{document}
这是最终结果:
灰线是非中心 t 分布(与中心 t 分布的蓝线不完全对称)。