你好,
我正在繪製一系列不同的設備及其信號響應響應作為時間的函數。 一旦繪圖超過一個值,例如 3100,我希望從每個更平滑的繪圖中提取時間值。 散射數據太粗略,無法獲得發生這種情況的時間,但是如果每個設備的平滑擬合背後都有一個函數,那麼這個信息應該是可用的。
有誰知道這是否可行,如果可以,如何完成?
JMP 確實提供了功能樣條係數()和樣條評估() .您可以使用樣條係數()獲取樣條參數,然後在任何所需點評估該樣條。您可以輕鬆地將其與牛頓法一起使用來確定每個樣條何時穿過某個值(例如 3100)。
請注意,您需要在此之前標準化 x 數據(零均值,std-dev = 1),以便樣條 lambda 可以匹配您通常期望的值。
這是我剛剛匯總的一個示例,我相信它可以滿足您的要求:
Names Default to Here( 1 );
determine crossover = Function( {table, value, spline lambda, x col, y col, group, precision = 0.1},
{Default Local},
spline number = 64;
max runs = 10;
rows = table << Get Rows Where( Excluded( Row State() ) == 0 );
groups = Associative Array( Column( table, group )[rows] ) << Get Keys;
curves = [=>];
For( i = 1, i <= N Items( groups ), i++,
item = groups[i];
Eval( Parse( Eval Insert( JSL Quote(
rows = table << Get Rows Where( Excluded( Row State() ) == 0 & :Name("^group^") == "^item^" )
) ) ) );
curves[item] = [=>];
curves[item]["rows"] = rows;
curves[item]["abcissa"] = Column( table, x col )[rows];
curves[item]["ordinate"] = Column( table, y col )[rows];
curves[item]["abcissa mean"] = Mean( curves[item]["abcissa"] );
curves[item]["abcissa stddev"] = Std Dev( curves[item]["abcissa"] );
If( curves[item]["abcissa stddev"] == 0, curves[item]["abcissa"] = 1 );
curves[item]["abcissa"] = (curves[item]["abcissa"] - curves[item]["abcissa mean"]) / curves[item]["abcissa stddev"];
first = Min( curves[item]["abcissa"] );
last = Max( curves[item]["abcissa"] );
curves[item]["crossover abcissa"] = .;
curves[item]["crossover ordinate"] = -1932870987120;
run = 1;
While( Abs( value - curves[item]["crossover ordinate"] ) > precision * value & run <= max runs,
run++;
points = first :: last :: (last - first) / spline number;
coef = Spline Coef( curves[item]["abcissa"], curves[item]["ordinate"], spline lambda );
spline = Spline Eval(
points,
coef
);
For( j = 1, j <= spline number, j++,
If( spline[j] > value,
first = If( j == 1, first, points[j - 1] );
last = points[j];
Break();
,
If( Abs( value - spline[j] ) < Abs( value - curves[item]["crossover ordinate"] ),
curves[item]["crossover abcissa"] = points[j] * curves[item]["abcissa stddev"] + curves[item]["abcissa mean"];
curves[item]["crossover ordinate"] = spline[j];
)
)
);
If( first == last, Break() );
);
first = Min( curves[item]["abcissa"] );
last = Max( curves[item]["abcissa"] );
points = first :: last :: (last - first) / spline number;
curves[item]["spline ordniate"] = Spline Eval(
points,
coef
);
curves[item]["spline abcissa"] = points * curves[item]["abcissa stddev"] + curves[item]["abcissa mean"];
curves[item]["abcissa"] = curves[item]["abcissa"] * curves[item]["abcissa stddev"] + curves[item]["abcissa mean"];
);
curves
);
dt = Open("$SAMPLE_DATA/Nonlinear Examples/Algae Mitscherlich.jmp");
lambda = 1;
Current Data Table( dt );
gb = Graph Builder(
Size( 516, 450 ),
Show Control Panel( 0 ),
Variables( X( :Days ), Y( :Algae density ), Overlay( :Treatment ) ),
Elements( Points( X, Y, Legend( 18 ) ), Smoother( X, Y, Legend( 19 ), Lambda( lambda ) ) ),
SendToReport(
Dispatch(
{},
"Algae density",
ScaleBox,
{Add Ref Line( 3, "Solid", "Black", "", 1 )}
)
)
);
curves = determine crossover( dt, 3, lambda, "Days", "Algae density", "Treatment", 0.001 );
gbr = Report( gb );
dt << Color or Mark by Column( :Treatment );
{y min, y max} = Eval List( {gbr[Axis Box( 2 )] << Get Min, gbr[Axis Box( 2 )] << Get Max} );
key = curves << First;
While( !Is Empty( key ),
Print( Eval List( {key, curves[key]["crossover abcissa"], curves[key]["crossover ordinate"]} ) );
color = Color Of( Row State( curves[key]["rows"][1] ) );
Eval( Eval Expr(
gbr[Frame Box( 1 )] << Add Graphics Script(
Pen Color( Expr( color ) );
Pen Size( 2 );
Line( {Expr( curves[key]["crossover abcissa"] ), Expr( y min )}, {Expr( curves[key]["crossover abcissa"] ), Expr( y max )} )
)
) );
key = curves << Next( key )
)
JMP Pro 中的函數數據資源管理器提供了許多用於處理函數、輪廓和曲線的工具。