我曾幾次需要創建一個填充的正態分佈曲線,以用於演示,培訓和出版。 與正態分佈一樣普遍和重要,您可能會認為可以輕鬆地將其作為標準形狀或使用Internet搜索來找到,但是我找不到我需要的東西很運氣。
JMP有一些不錯的方法,可以使用圖形腳本在繪圖上繪製線條和幾何形狀。 如果我想要一個看起來像這樣的形狀

一種方法是使用正態分佈函數創建具有定義多邊形的坐標點的向量,然後在圖形腳本中將其用作Polygon()函數的參數。
下面顯示的函數就是這樣做的,並返回可以在圖形腳本中使用的評估表達式。
func_VNormalShape = Function( // create a polygon that looks like a vertically oriented normal distribution
{_xloc, _yloc, _xscale = 1, _yscale = 1, _range=3, _scaleres=10},
{_VNormShapeX, _VNormShapeY},
// _xloc, _yloc is the "origin" for the normal curve (centered on Yloc, base of curve at xloc)
// _xscale is the scale magnification in the x-axis direction
// _yscale is the scale magnification in the y-axis direction
// range is the +/- range (in standard deviation) to draws the curve over
// scalres is the number of points per _yscale to use for determining the polygon. 10 generally works well, but if range is set to be large
// then scale_res should probably be increased.
// create a vector of y values to use for plotting the shape
_VNormShapeY = ((_yloc - _range * _yscale) :: (_yloc + _range * _yscale) :: (_yscale / _scaleres))`;
// create the filled polygon boundary points
_VNormShapeX = V Concat(
J( _range*2*_scaleres + 1, 1, _xloc ),
_xloc + Sqrt( 2 * Pi() ) * _yscale * _xscale * Normal Density( Sort Descending( _VNormShapeY ), _yloc, _yscale )
);
_VNormShapeY = V Concat(
_VNormShapeY,
Sort Descending( _VNormShapeY )
);
// substitute into the Polygon(function) the two vectorw with the boundary point X and Y values
// and evaluate the function
Eval( Substitute( Expr( Polygon( Expr( shape_x ), Expr( shape_y ) ) ), Expr( shape_x ), _VNormShapeX, Expr( shape_y ), _VNormShapeY ) );
); 然後可以在Graph Box()函數內部使用該函數,如下所示(它將創建上面所示的填充法線)。
_nw = New Window( "Vertical Normal Distribution",
_ob = Outline Box("Gray Vertical Filled Normal Distribution",
_hlb = H List Box(
_gb = Graph Box(
X Scale( 0, 1.1 ),
Y Scale( 1, 8 ),
Xname( "" ),
Yname( "" ),
Fill Color( "gray" );
func_VNormalShape( 0, 4.5, 1, 1, 3.4, 8 );
)
)
)
);
相同的方法可以應用於其他概率分佈。