Combine Integrate con Interpolate o SplineEval para obtener el área bajo la curva.
@sseligman escribió Uso de JMP para encontrar el área bajo una curva ; aquí hay un poco más de información sobre algunas funciones integradas.
La función Interpolar utiliza una lista ordenada de coordenadas X y una lista correspondiente de coordenadas Y y responde a la pregunta "si X fuera 42, ¿cuál sería Y?" usando interpolación lineal entre las dos coordenadas X más cercanas en la lista ordenada. La interpolación lineal produce segmentos de línea recta con puntos de datos en las esquinas de la curva.
La función SplineEval hace lo mismo (con la ayuda de la función Spline Coef) usando una interpolación spline. Una spline es un cable de metal elástico y flexible que pasa cerca de los puntos de datos, según su rigidez. Por lo general, los puntos de datos no caen en la curva spline.
Ambas funciones producen todos los puntos de datos en una curva desde la primera X hasta la última X.
La función Integrar responde a una pregunta diferente: "¿cuánta área hay bajo esta curva en este rango?" Interpolar tiene cuatro argumentos; los dos primeros describen una función af(x) que genera una curva y los dos últimos describen un rango de valores de x. El resultado de Integrar (f(x), x, bajo, alto) es el área bajo la curva cuando x va de menor a mayor. Las dos primeras variables parecen repetir x porque f(x) podría ser una expresión como a+2*b y la segunda variable indica si aob es la variable entre bajo y alto.
El JSL para esta publicación trata sobre el uso de Interpolate o SplineEval como el valor f(x) de Interpolate.Construye un gráfico interactivo para ayudar a comprender cómo encontrar el área bajo una curva definida por algunos puntos de datos ruidosos podría funcionar con interpolación lineal o spline. También muestra la respuesta exacta (rojo) antes de que se agregara el ruido (puntos de datos negros) a los datos. La curva azul es el ajuste spline a los puntos de datos negros. El gráfico de barras en el medio muestra los tres cálculos de área uno al lado del otro; solo la barra azul central se mueve cuando cambia la tensión de la spline. Con los datos aleatorios correctos, cualquier barra puede ser más alta o más corta que las demás.
JSL makes a graph like this; the lambda slider changes the blue spline's tension.JSL hace un gráfico como este; el control deslizante lambda cambia la tensión de la spline azul.
Se requiere JMP 16... para cada...
New Window( "Integrate Area Under Curve",
// make a function, in the window: namespace, that returns a sine wave
window:f = Function( {t},
50 + Sin( t / 10 ) * 40
);
// create the x dimension of the graph
window:xmin = 20; // integrate over this range
window:xmax = 80;
window:xcoarse = window:xmin :: window:xmax :: 4; // the coarse data is used to make random data from sin function
window:xfine = window:xmin :: window:xmax :: 0.125; // the fine data is used for outlining smooth polygons
// create the y dimension of the graph from x and function f(x) and some randomness
window:random = 10; // random variation, slider below
// this function called here, and from slider below
window:generatedata = Function( {}, // regenerate the points with new random error
window:ycoarse = window:f( window:xcoarse ) + J( 1, N Col( window:xcoarse ), Random Normal( 0, window:random ) );
// ycoarse is the y data for the points; limit it to stay on the y axis...
window:ycoarse[Loc( window:ycoarse > 99 )] = 99;
window:ycoarse[Loc( window:ycoarse < 1 )] = 1;
);
window:generatedata(); // prepare the initial data in the graph
// lambda is the tension on the spline interpolation, slider below
window:loglambda = 2;// spline tension, a nice middle value
// random patterns for filled areas. the exponents are artistically adjusted for blending the colors
// with gray drawn first, and dark, and yellow drawn last, medium, and blue between, but light.
// there are 7 overlaps with different shades.
window:patternsize = 299; // big square patch for a pattern
window:pat01 = J( window:patternsize, window:patternsize, (Random Integer( 0, 255 ) / 255) ^ 0.5 );//gray
window:pat02 = J( window:patternsize, window:patternsize, (Random Integer( 0, 255 ) / 255) ^ 3 );//blue
window:pat03 = J( window:patternsize, window:patternsize, (Random Integer( 0, 255 ) / 255) ^ 2 );//yellow
window:bar01 = 38;
window:bar02 = 44;// bar x-locations, in graph coordinates; they look good here, for this sine wave
window:bar03 = 50;
window:show = [1 1 1];
window:barwide = 5;
window:barbottom = 50;// bottom of chopped off bar
window:bartop = window:barbottom + 5;
// map values of the AUC onto the graph
window:aucMin = 1500;
window:aucMax = 4000;
window:aucToGraph = Function( {y}, // convert auc to graph Y to make bar heights; 0 is for a label
Interpolate( y, 0, window:barbottom - window:bartop, window:aucMin, 7, window:aucMax, 97 - window:bartop )
);
// draw a broken bar; x in graph units, y in auc units
window:drawAucBar = Function( {x, y},
y = window:aucToGraph( y );
Polygon(// ragged edge bottom poly below the break
x || x || x + .1 * window:barwide || x + .3 * window:barwide || x + .5 * window:barwide || x + .8 * window:barwide || x + window:barwide
|| x + window:barwide,
window:barbottom || window:barbottom + 5 || window:barbottom + 6 || window:barbottom + 4 || window:barbottom + 7 || window:barbottom + 3
|| window:barbottom + 5 || window:barbottom
);
If( y >= 0, // the bar is below the break, don't draw
Polygon(
x || x || x + .1 * window:barwide || x + .3 * window:barwide || x + .5 * window:barwide || x + .8 * window:barwide || x + window
:barwide || x + window:barwide,
window:bartop + y || window:bartop + 5 || window:bartop + 6 || window:bartop + 4 || window:bartop + 7 || window:bartop + 3 || window
:bartop + 5 || window:bartop + y
)
);
);
// make the GUI
window:g = Graph Box(
// this script runs when the graph needs to reshow, either the first time, or because a slider script uses <<RESHOW framesize=""></RESHOW>