Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- How to calc. the area under a curve?

Topic Options

- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 4, 2009 1:41 PM
(8706 views)

i m new to JMP 7.

I want to**calculate** the **area** under a **Curve**, using the **Trapezium rule**.

can any one tell me how to do this?

thank you ....

Message was edited by: pg_microbio

I want to

can any one tell me how to do this?

thank you ....

Message was edited by: pg_microbio

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

I love JMP and use it all the time. But- there are so many packages for area under a curve that are superior to JMP. Mathematica is in my opinion the very best. A good cheap contender is the free cousin of MatLab, called FreeMat

http://freemat.sourceforge.net/

However, if all you want is to connect your data points with lines, then calculate the area underneath, and if your points are all 30 units apart from each other, then the answer is simple, because each area part is a trapezoid with a horizontal base, and all the bases are 30 wide. The area under each trapezoid is then the width (30) times the average height. For two points (x1,y1), (x2,y2) that average is (y1 + y2)/2 .

Let y1 be your first point, yn your last point. The area under your plot is then

[(y1+yn)/2 + (y2 + y3 + ... + yn-1) ]*30

The first and last points are included only once in the area calculations, thus they need to be halved. The others are in there twice, so you just sum them up.

Re Gompertz, any nonlinear fitting is dependent on starting values. JMP seems to do a great job with its default starting values, so give it a try. You might not get convergence according to the JMP stopping rule, so just choose to accept the current values if the parameters are stable (unchanging) enough. Or try resetting, and selecting the option of numeric derivatives. That sometimes will help. Good luck.

http://freemat.sourceforge.net/

However, if all you want is to connect your data points with lines, then calculate the area underneath, and if your points are all 30 units apart from each other, then the answer is simple, because each area part is a trapezoid with a horizontal base, and all the bases are 30 wide. The area under each trapezoid is then the width (30) times the average height. For two points (x1,y1), (x2,y2) that average is (y1 + y2)/2 .

Let y1 be your first point, yn your last point. The area under your plot is then

[(y1+yn)/2 + (y2 + y3 + ... + yn-1) ]*30

The first and last points are included only once in the area calculations, thus they need to be halved. The others are in there twice, so you just sum them up.

Re Gompertz, any nonlinear fitting is dependent on starting values. JMP seems to do a great job with its default starting values, so give it a try. You might not get convergence according to the JMP stopping rule, so just choose to accept the current values if the parameters are stable (unchanging) enough. Or try resetting, and selecting the option of numeric derivatives. That sometimes will help. Good luck.

12 REPLIES 12

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

The JSL code below uses the trapezoid rule. You must enter the range of integration ("xmin" and "xmax"). Enter the function you want to integrate into the variable called "pdf". The trapezoid rule divides the range of integration into sevaral intervals, and approximates the area under the curve for each interval by the area of a trapezoid. But how many intervals do you use? The code approximates the area using 1 interval, then 2 intervals, so on. It keeps increasing the number of intervals until the incremental difference is less than "stop". That way you don't have to specify the number of intervals, the code just keeps going until it converges.

The example in the code is the standard normal distribution between -10 and 10. The code outputs the results into the log window: the number of intervals it used, and the answer it converged to. In this example. it takes 26 intervals, and converges to 1.00000000000001. The total area under the normal curve is 1. Pretty close I would say.

Also of interest to you may be the midpoint rule and Simpsons rule. See Wikipedia for details. The code below can be easily altered to use those other rules.

You can also use a data table to do numerical integration. The more rows you use to span the range of integration, the better the approximation.

The code is below:

```
Clear Globals();
xmin=-10;
xmax=10;
stop=0.0000000000001;
pdf=function( {x} , 1/(sqrt(2*pi()))*exp(-x^2/2) );
intervals=1;
last=0;
new=0;
flag=0;
while(flag==0,
intervals=intervals+1;
increment=(xmax-xmin)/intervals;
total=0;
for(i=1, i<=intervals, i++,
if(i==1, x=xmin);
if(i>1, x=x+increment);
total=total + ((pdf(x)+pdf(x+increment))/2)*increment;
);
last=new;
new=total;
diff=abs(last-new);
if(diff<=stop, flag=1);
);
show(intervals);
show(total);
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

dear Jonathan,

thanks for the reply. but actually i cant understand it.

i am writing down the data.

i am using, for which i want the fractional area(area under the curve)....

y-axis:(this is the Optical density)

0.2405

0.26675

0.3205

0.3635

0.401

Time(on x axis, interval is 30 mins): 0, 30, 60, 90, 120

All the data i have is in of this type, so if please help me with this one , i will be able to deal with the rest of the analysis.

Message was edited by: pg_microbio

thanks for the reply. but actually i cant understand it.

i am writing down the data.

i am using, for which i want the fractional area(area under the curve)....

y-axis:(this is the Optical density)

0.2405

0.26675

0.3205

0.3635

0.401

Time(on x axis, interval is 30 mins): 0, 30, 60, 90, 120

All the data i have is in of this type, so if please help me with this one , i will be able to deal with the rest of the analysis.

Message was edited by: pg_microbio

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

I'm a little confused as to what you want to do. You say you want the area under the curve, but you gave me data, not the equation of a curve. Do you want to fit a model for Y as a function of X, and then integrate the model? If not, I'm afraid I don't understand what you want to do.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

from this data i want to plot a graph, then calculate the area under it.

there is no equation just the data which i collected experimentally with a spectrophotometer.

the data i gave you is the growth profile(Optical density, O.D.) of a bacteria, against an antibiotic at a specific concentration in ppm.

Now after i calculate the area, under this, O.D. by time curve, at 10 different concentrations.

then i will use that data to plot a graph, Area(y-axis) by Concentration(x-axis).

then apply a modified Gompertz function to the data to analyse it.

basically i dont know what a Gompertz function is, but i know the formula and in the research paper it says a non linear fitting procedure was used in JMP.

But for all that, first i have to know how to calc. the area???

can i some how send you the JMP file of my data?

there is no equation just the data which i collected experimentally with a spectrophotometer.

the data i gave you is the growth profile(Optical density, O.D.) of a bacteria, against an antibiotic at a specific concentration in ppm.

Now after i calculate the area, under this, O.D. by time curve, at 10 different concentrations.

then i will use that data to plot a graph, Area(y-axis) by Concentration(x-axis).

then apply a modified Gompertz function to the data to analyse it.

basically i dont know what a Gompertz function is, but i know the formula and in the research paper it says a non linear fitting procedure was used in JMP.

But for all that, first i have to know how to calc. the area???

can i some how send you the JMP file of my data?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

http://freemat.sourceforge.net/

However, if all you want is to connect your data points with lines, then calculate the area underneath, and if your points are all 30 units apart from each other, then the answer is simple, because each area part is a trapezoid with a horizontal base, and all the bases are 30 wide. The area under each trapezoid is then the width (30) times the average height. For two points (x1,y1), (x2,y2) that average is (y1 + y2)/2 .

Let y1 be your first point, yn your last point. The area under your plot is then

[(y1+yn)/2 + (y2 + y3 + ... + yn-1) ]*30

The first and last points are included only once in the area calculations, thus they need to be halved. The others are in there twice, so you just sum them up.

Re Gompertz, any nonlinear fitting is dependent on starting values. JMP seems to do a great job with its default starting values, so give it a try. You might not get convergence according to the JMP stopping rule, so just choose to accept the current values if the parameters are stable (unchanging) enough. Or try resetting, and selecting the option of numeric derivatives. That sometimes will help. Good luck.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

yes i do think i want to fit y by x, then integrate it to get the area under the curve..

p.s. read the other post to for details

p.s. read the other post to for details

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

I am not able to recieve or send files. But, I will give instruction on using non-linear fitting in JMP, particularly the Gompertz model, then using the JSL code I provided to find the area under the fitted curve. I will use JMP 8 for the demo. You can download a free 30 day trial of JMP 8 from JMP's website.

Create a data table with the Time (x) and Optical Density (y) data. The table will have 5 rows and 2 columns. Select Analyze>Modeling>Nonlinear. Click the Model Library button. Scroll down till you find "Model H (Gompertz growth model, 3P)", and select it. Click the Make Formula button. Assign y to the**Y** role and x to the **X** role, then click OK. Move the theta1 slider to close to 0.3611. Click Make Formula. That created a new column in the table with the model and initial parameter estimates. Back on the Nonlinear window, assign Model H (Gompertz growth model, 3P) to the **X, Predictor Formula** role, and assign y to the **Y, Response** role. Click OK. Click Go a few times till the result pane give the message "Converged in Gradient". Click the Save Estimates button. If you want to save the predicted model to a column, select Save Formula>Save Prediction Formula. That is the basics of using the nonlinear platform.

Now we'll integrate that fitted model to get the area. Turn our attention to the JSL code I provided above. Copy and paste the code into an empty script window. I'm assuming you want to integrate between 0 and 120. Therefore, change the "xmin" variable to 0 and "xmax" to 120. Change the "stop" variable to 0.000000001. The line with the "pdf" variable should read:

pdf=function( {x} , 1.16929740059737 * Exp( -Exp( 0.46956698638041 - 0.00339164235623826 * x ) ) );

The pdf line contains the fitted model.

Make sure your log window is open. On the View menu, make sure Log is checked. Now run the script by selecting Edit>Run Script. It should finish in about 3 seconds.

The result shows in the log window. The variable Total gives the area. It should be about 38.161.

Good luck with trying it out. I hope this helps point you in the right direction.

Create a data table with the Time (x) and Optical Density (y) data. The table will have 5 rows and 2 columns. Select Analyze>Modeling>Nonlinear. Click the Model Library button. Scroll down till you find "Model H (Gompertz growth model, 3P)", and select it. Click the Make Formula button. Assign y to the

Now we'll integrate that fitted model to get the area. Turn our attention to the JSL code I provided above. Copy and paste the code into an empty script window. I'm assuming you want to integrate between 0 and 120. Therefore, change the "xmin" variable to 0 and "xmax" to 120. Change the "stop" variable to 0.000000001. The line with the "pdf" variable should read:

pdf=function( {x} , 1.16929740059737 * Exp( -Exp( 0.46956698638041 - 0.00339164235623826 * x ) ) );

The pdf line contains the fitted model.

Make sure your log window is open. On the View menu, make sure Log is checked. Now run the script by selecting Edit>Run Script. It should finish in about 3 seconds.

The result shows in the log window. The variable Total gives the area. It should be about 38.161.

Good luck with trying it out. I hope this helps point you in the right direction.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

Thanks a lot, for the Gompertz function thing!

the script is running fine, (its a bit like a C++ program).

this is about the area problem, what i wanted to ask was that " the interval is constant for every set of values ie. from 0 to 120, but the O.D. values(on y-axis) will change with every table, so how do i do that, so i get the area for every different set of values?"

this area which i am getting would be for the values i gave you, right?

the script is running fine, (its a bit like a C++ program).

this is about the area problem, what i wanted to ask was that " the interval is constant for every set of values ie. from 0 to 120, but the O.D. values(on y-axis) will change with every table, so how do i do that, so i get the area for every different set of values?"

this area which i am getting would be for the values i gave you, right?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to calc. the area under a curve?

Yes, the area result I got was for the specific optical density values (Y) values you gave.

You can repeat the process with different Y values.

You can repeat the process with different Y values.