473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Correlation Analysis - 'Not Enough Memory to Run Excel' & other strange behavior

Ben
I have written a procedure which calls the CORREL function of Excel to
run correlation analysis on two arrays, then populate a table with the
resulting correlation coefficient. This process loops through several
records and recordsets. The procedure works well for awhile
(sometimes upwards of 10,000 times!), but then mysteriously begins
populating "0" as the correlation coefficient (even though I know this
to be inaccurate). Sometimes, I receive the error 'Not Enough Memory
to Run Excel', sometimes not. Sometimes, the computer freaks out
after I break the code, diplaying various pieces of open windows,
flashing, etc.

HOWEVER, once I shut down/restart the computer and start the procedure
again from where I left off, it ALWAYS works properly again for
another 10,000 or so passes, then repeats the error(s). Is there some
way I can prevent this behavior??
Thank you.
Ben.

Using:
Win2K
Access 2000

and tried on:

WinXP
Access2000
(same results)

below is the code I'm using to create Excel object and run correl
analysis:
(slightly modifed code of Jeff Brady)

IS IT NECESSARY TO CREATE/QUIT EXCEL OBJECT EACH TIME I RUN ANALYSIS,
OR CAN I JUST CREATE IT ONCE, RUN ANALYSIS THOUSANDS OF TIME, THEN
QUIT??

Public Function PValue(sSQL As String) As Single
'Function receives SQL string as argument and returns paired TTest
value
'Note: No error checking is done in this function so be sure that the
SQL
' string passed has the data to be calculated in the first two
columns.
'Author: Jeff Brady 11/29/96

Dim xlApp As Object
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim A1() As Double
Dim A2() As Double
Dim idx As Integer

Set xlApp = CreateObject("Excel.application")
Set db = CurrentDb()
Set rs = db.OpenRecordset(sSQL)

Do Until rs.EOF
ReDim Preserve A1(idx)
ReDim Preserve A2(idx)
A1(idx) = rs.Fields(0)
A2(idx) = rs.Fields(1)
idx = idx + 1
rs.MoveNext
Loop

PValue = xlApp.CORREL(A1, A2)
xlApp.Quit
Set xlApp = Nothing
rs.Close

End Function
Nov 12 '05 #1
1 5875
br*******@yahoo.com (Ben) wrote in news:6b67292f.0310030819.90fb202
@posting.google.com:
I have written a procedure which calls the CORREL function of Excel to
run correlation analysis on two arrays, then populate a table with the
resulting correlation coefficient. This process loops through several
records and recordsets. The procedure works well for awhile
(sometimes upwards of 10,000 times!), but then mysteriously begins
populating "0" as the correlation coefficient (even though I know this
to be inaccurate). Sometimes, I receive the error 'Not Enough Memory
to Run Excel', sometimes not. Sometimes, the computer freaks out
after I break the code, diplaying various pieces of open windows,
flashing, etc.

HOWEVER, once I shut down/restart the computer and start the procedure
again from where I left off, it ALWAYS works properly again for
another 10,000 or so passes, then repeats the error(s). Is there some
way I can prevent this behavior??
Thank you.
Ben.

Using:
Win2K
Access 2000

and tried on:

WinXP
Access2000
(same results)

below is the code I'm using to create Excel object and run correl
analysis:
(slightly modifed code of Jeff Brady)

IS IT NECESSARY TO CREATE/QUIT EXCEL OBJECT EACH TIME I RUN ANALYSIS,
OR CAN I JUST CREATE IT ONCE, RUN ANALYSIS THOUSANDS OF TIME, THEN
QUIT??

Public Function PValue(sSQL As String) As Single
'Function receives SQL string as argument and returns paired TTest
value
'Note: No error checking is done in this function so be sure that the
SQL
' string passed has the data to be calculated in the first two
columns.
'Author: Jeff Brady 11/29/96

Dim xlApp As Object
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim A1() As Double
Dim A2() As Double
Dim idx As Integer

Set xlApp = CreateObject("Excel.application")
Set db = CurrentDb()
Set rs = db.OpenRecordset(sSQL)

Do Until rs.EOF
ReDim Preserve A1(idx)
ReDim Preserve A2(idx)
A1(idx) = rs.Fields(0)
A2(idx) = rs.Fields(1)
idx = idx + 1
rs.MoveNext
Loop

PValue = xlApp.CORREL(A1, A2)
xlApp.Quit
Set xlApp = Nothing
rs.Close

End Function


The function seems to be stunningly inefficient. Redimming the arrays and
slam-dunking values when GetRows is available? Where do you release the
recordset object pointer, rs? Why the late binding?

Access is completely capable of calculating simple stats without going to
Excel, if one is familiar with the required formula. Probably a
"programmer" could speed this up by a factor of a few thousand. Pop it into
VB, do a native code compile and you might hit a million.

My advice is trash this and find a new function.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Daniele | last post by:
I have a 40 MB database in excel format. I need to use it in Analysis Services, I imported the data by DTS (Data Transformation Services), everything is working I can see the database, but I can't...
30
by: jimjim | last post by:
Hello, This is a simple question for you all, I guess . int main(){ double *g= new double; *g = 9; delete g; cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl; *g =...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
25
by: Zeng | last post by:
I finally narrowed down my code to this situation, quite a few (not all) of my CMyClass objects got hold up after each run of this function via the simple webpage that shows NumberEd editbox. My...
3
by: Elliot | last post by:
The program loops through a dataset and creates several spreadsheets based on a change in a particular column. With each new spreadsheet I launch a new instance of excel. After about 100...
18
by: robert | last post by:
Is there a ready made function in numpy/scipy to compute the correlation y=mx+o of an X and Y fast: m, m-err, o, o-err, r-coef,r-coef-err ? Or a formula to to compute the 3 error ranges? ...
2
by: truthinlife | last post by:
I am running the following commands on an AIX 5.2 server, using db2 udb v8.2.2. my ipcs -mb command gives me the following: IPC status from /dev/mem as of Mon Nov 20 12:47:25 EST 2006 T ID...
5
by: John Kotuby | last post by:
Hi all, This is my first time trying to creaet and use a custome Web Control in a Web Site project in ASP.NET 2.0 with VS 2005 and VB. I created the control in a separate Web Control Library...
1
by: ray pulbrook | last post by:
My questions are can you use access to query correlation and regression analysis or should i link an excel spreadsheet to the database that has those functions specific to the analysis. if you can do...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.