ojalgo-user Mailing List for oj! Algorithms (Page 29)
Mathematics, linear algebra and optimisation
Brought to you by:
apete
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
(1) |
Mar
|
Apr
(14) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2005 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
(3) |
Oct
|
Nov
|
Dec
(1) |
2006 |
Jan
(1) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
(5) |
Sep
|
Oct
(3) |
Nov
(4) |
Dec
(2) |
2007 |
Jan
(8) |
Feb
(1) |
Mar
(2) |
Apr
(11) |
May
(6) |
Jun
|
Jul
(10) |
Aug
(2) |
Sep
|
Oct
(4) |
Nov
|
Dec
(11) |
2008 |
Jan
(22) |
Feb
(4) |
Mar
(2) |
Apr
(4) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(6) |
Nov
(17) |
Dec
(5) |
2009 |
Jan
(15) |
Feb
(2) |
Mar
(2) |
Apr
(3) |
May
(4) |
Jun
(5) |
Jul
(9) |
Aug
(2) |
Sep
|
Oct
(5) |
Nov
(14) |
Dec
|
2010 |
Jan
(3) |
Feb
(5) |
Mar
(2) |
Apr
(19) |
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
(5) |
Nov
(3) |
Dec
|
2011 |
Jan
|
Feb
(1) |
Mar
(7) |
Apr
(10) |
May
(1) |
Jun
(15) |
Jul
(1) |
Aug
|
Sep
|
Oct
(13) |
Nov
(9) |
Dec
(11) |
2012 |
Jan
|
Feb
(1) |
Mar
(9) |
Apr
(23) |
May
(16) |
Jun
(9) |
Jul
(13) |
Aug
|
Sep
(4) |
Oct
(1) |
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(12) |
Mar
(7) |
Apr
(24) |
May
|
Jun
(7) |
Jul
(4) |
Aug
|
Sep
(3) |
Oct
(16) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(2) |
Nov
(6) |
Dec
(2) |
2015 |
Jan
(11) |
Feb
(10) |
Mar
(1) |
Apr
(9) |
May
|
Jun
|
Jul
(1) |
Aug
(4) |
Sep
(6) |
Oct
(3) |
Nov
(15) |
Dec
(4) |
2016 |
Jan
(6) |
Feb
|
Mar
(18) |
Apr
(5) |
May
(9) |
Jun
(3) |
Jul
(5) |
Aug
(2) |
Sep
(5) |
Oct
(2) |
Nov
|
Dec
(5) |
2017 |
Jan
(4) |
Feb
(3) |
Mar
|
Apr
|
May
(12) |
Jun
(1) |
Jul
(4) |
Aug
|
Sep
(3) |
Oct
(1) |
Nov
|
Dec
(1) |
2018 |
Jan
(5) |
Feb
|
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
|
Jul
(4) |
Aug
(1) |
Sep
(8) |
Oct
|
Nov
|
Dec
(1) |
2019 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Inger, M. <In...@Sy...> - 2004-04-20 12:58:30
|
The basic slowdown is that the constructors are not cached. Finding the constructor each time is what makes that factory slow. If MatrixFactory was an interface, one could just call the appropriate constructurs directly without reflection. public interface MatrixFactory { public BasicMatrix create(double values[][]); } public class BigMatrixFactory implements MatrixFactory { public BasicMatrix create(double values[][]) { return new BigMatrix(values); } } You could still have the original vresion, but it would be named something different, and implement this new interface. -----Original Message----- From: Anders Peterson [mailto:and...@op...] Sent: Tuesday, April 20, 2004 4:40 AM To: Inger, Matthew Cc: 'oja...@li...' Subject: Re: [ojAlgo-user] Questions On 2004-04-19, at 22.39, Inger, Matthew wrote: > FYI: Using MatrixFactory is also extremely slow. > If i directly instantiate JamaMatrix for 100,000 > regressions, it takes ~ 2 seconds or so. If i use > MatrixFactory to instantiate, it goes up to 8 seconds. MatrixFactory uses reflection to call the appropriate constructor. Using it centralises matrix creation and allows you to switch implementation by changing one line of code - the call to the MatrixFactory constructor. (Make sure you re-use the factory instances.) This will naturally take longer than calling the constructor directly, but I am surprised it is that much slower. If this is a problem; call the constructors directly. Perhaps you should implement your own static factory method. > I'm a little curious why MatrixFactory is not an interface, > with implementations per different type of Matrix. Interfaces can't specify contructors. /Anders > -----Original Message----- > From: Inger, Matthew > Sent: Monday, April 19, 2004 3:04 PM > To: 'Anders Peterson'; Inger, Matthew > Subject: RE: [ojAlgo-user] Questions > > > There are a small number of variables. In most cases, we > have a single variable equation, and up to 24 points with > which to fit the linear regression. > > Then, we do that 10,000 times. > > Basically, each row in the database contains time elapsed > data (typically one value per month). We use the # of the > month as the x values, and the data as the y value, and try > to fit a line to it to determine short term trends. > > So for each row, we calculate 1 set of coefficients (b0 and b1, > aka intercept & slope), and make 1 more predictions. > > However, there are potentially millions of rows in the database. > > > -----Original Message----- > From: Anders Peterson [mailto:and...@op...] > Sent: Monday, April 19, 2004 2:32 PM > To: Inger, Matthew > Subject: Re: [ojAlgo-user] Questions > > > This is just a naive first attempt... > > On 2004-04-19, at 20.06, Inger, Matthew wrote: > >> PS: As far as solving the equations, i basically have two >> matrices. X and Y. Any kind of code snippet would help here. >> Keep in mind, equations are of the form >> >> y = b0 + b1*X > > 1*b0 + x*b1 = y > > A*X = B > > where > > A: > 1 x1 > 1 x2 > 1 x3 > ... ... > > B: > y1 > y2 > y3 > ... > > X: > b0 > b1 > > X = A.solve(B); > > Are you doing this 10 000 times with a relatively small number of x- > and y-values or do you have 10 000 x- and y-values for each > calculation? > > /Anders > >> -----Original Message----- >> From: Anders Peterson [mailto:and...@op...] >> Sent: Monday, April 19, 2004 2:02 PM >> To: Inger, Matthew >> Cc: 'oja...@li...' >> Subject: Re: [ojAlgo-user] Questions >> >> >> On 2004-04-19, at 18.33, Inger, Matthew wrote: >> >>> 1. Have any performance tests been run with BigMatrix? >> >> Not really... >> >>> I'm using >>> BigMatrix to do a >>> LinearRegression algorithm. I had previously been using Jama >>> directly, >>> but our FD >>> department noticed a difference between the results given by >>> java >>> and >>> the LINEST >>> function in Excel. I have determined that the difference is >>> DEFINATELY >>> due to rounding >>> limitations in the java double primitive type. >>> >>> These issues go away when i use ojAlgo library, >> >> That's great news to me - that is the reason I created ojAlgo! >> >>> however, the time >>> required to do the >>> calculations increases to about 12-13x what it was using regular >>> double >>> calculations. >>> >>> Doing 10,000 linear regressions with Jama took about .781s >>> (according >>> to junit), and >>> with BigMatrix, took 10.345s >> >> I wasn't aware the difference was that big. ;-) >> >>> Any idea why such a hug disparity? >> >> Try altering the scale. A larger scale means better results, but it >> takes longer. You can change a matrix' scale whenever you want - the >> new scale will be used from then on. Elements are not rounded unless >> you call enforceScale(). >> >> Internally BigMatrix uses various decompositions for some of the more >> complex calculations. These decompositions inherit a scale from the >> parent matrix. It is however not the same - it's bigger. I believe the >> formula is 2 * (3 + max(9, matrixScale)) and this formula is evaluated >> when the decomposition is created. After the decomposition is created >> its scale wont change even if you change the matrix' scale. The scale >> of a decomposition is never smaller than 24 (according to the above >> formula). >> >> I'm not happy with this, and have been meaning to change it. >> Decompositions should have the same scale as its parent matrix, and >> when it is changed, updated "everywhere". >> >> Would you prefer that? >> >>> 2. Is there a way to use the solvers in OjAlg to do the linear >>> regression? >>> Or is that not >>> something that is provided? >> >> How are you currently doing it? >> >> I imagine the best way would be to simply build an over-determined set >> of linear equations - Ax=B - and call A.solve(B). Internally BigMatrix >> would then use the QR decomposition to give a least squares estimation >> of x. That would be my first attempt. >> >> You could use the QP solver do the same thing, but I don't see how >> that >> would simplify or improve anything. >> >> What version of ojAlgo are you using - v1, v2 or CVS? >> >> I recommend working from CVS. Unfortunately I have moved things around >> a bit in between version... >> >> I don't have access to a profiling tool, but I know they can be very >> useful in finding bottlenecks. If you can identify a problem, and/or >> suggest a specific improvement, I'll be happy to help you implement >> it. >> >> /Anders >> >>> ---------------------- >>> Matthew Inger >>> Design Architect >>> Synygy, Inc >>> 610-664-7433 x7770 >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email is sponsored by: IBM Linux Tutorials >>> Free Linux tutorial presented by Daniel Robbins, President and CEO of >>> GenToo technologies. Learn everything from fundamentals to system >>> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >>> _______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > |
From: Anders P. <and...@op...> - 2004-04-20 09:15:52
|
I updated the code in CVS last night. You do now have better control of the scale used in decompositions. The downside is that now you have to think about it. Do not use BigMatrix without specifically setting the scale to an appropriate value. On 2004-04-19, at 20.04, Inger, Matthew wrote: > Let me at least see how turning the scale down helps. > It appears that the majority of the time is spent in multiply > and in the constructor. I can send you the screenshot of what > devpartner is telling me if you want. > > > -----Original Message----- > From: Anders Peterson [mailto:and...@op...] > Sent: Monday, April 19, 2004 2:02 PM > To: Inger, Matthew > Cc: 'oja...@li...' > Subject: Re: [ojAlgo-user] Questions > > > On 2004-04-19, at 18.33, Inger, Matthew wrote: > >> 1. Have any performance tests been run with BigMatrix? > > Not really... > >> I'm using >> BigMatrix to do a >> LinearRegression algorithm. I had previously been using Jama >> directly, >> but our FD >> department noticed a difference between the results given by java >> and >> the LINEST >> function in Excel. I have determined that the difference is >> DEFINATELY >> due to rounding >> limitations in the java double primitive type. >> >> These issues go away when i use ojAlgo library, > > That's great news to me - that is the reason I created ojAlgo! > >> however, the time >> required to do the >> calculations increases to about 12-13x what it was using regular >> double >> calculations. >> >> Doing 10,000 linear regressions with Jama took about .781s >> (according >> to junit), and >> with BigMatrix, took 10.345s > > I wasn't aware the difference was that big. ;-) > >> Any idea why such a hug disparity? > > Try altering the scale. A larger scale means better results, but it > takes longer. You can change a matrix' scale whenever you want - the > new scale will be used from then on. Elements are not rounded unless > you call enforceScale(). > > Internally BigMatrix uses various decompositions for some of the more > complex calculations. These decompositions inherit a scale from the > parent matrix. It is however not the same - it's bigger. I believe the > formula is 2 * (3 + max(9, matrixScale)) and this formula is evaluated > when the decomposition is created. After the decomposition is created > its scale wont change even if you change the matrix' scale. The scale > of a decomposition is never smaller than 24 (according to the above > formula). > > I'm not happy with this, and have been meaning to change it. > Decompositions should have the same scale as its parent matrix, and > when it is changed, updated "everywhere". > > Would you prefer that? > >> 2. Is there a way to use the solvers in OjAlg to do the linear >> regression? >> Or is that not >> something that is provided? > > How are you currently doing it? > > I imagine the best way would be to simply build an over-determined set > of linear equations - Ax=B - and call A.solve(B). Internally BigMatrix > would then use the QR decomposition to give a least squares estimation > of x. That would be my first attempt. > > You could use the QP solver do the same thing, but I don't see how that > would simplify or improve anything. > > What version of ojAlgo are you using - v1, v2 or CVS? > > I recommend working from CVS. Unfortunately I have moved things around > a bit in between version... > > I don't have access to a profiling tool, but I know they can be very > useful in finding bottlenecks. If you can identify a problem, and/or > suggest a specific improvement, I'll be happy to help you implement it. > > /Anders > >> ---------------------- >> Matthew Inger >> Design Architect >> Synygy, Inc >> 610-664-7433 x7770 >> >> >> >> ------------------------------------------------------- >> This SF.Net email is sponsored by: IBM Linux Tutorials >> Free Linux tutorial presented by Daniel Robbins, President and CEO of >> GenToo technologies. Learn everything from fundamentals to system >> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >> _______________________________________________ >> ojAlgo-user mailing list >> ojA...@li... >> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >> > |
From: Anders P. <and...@op...> - 2004-04-20 09:09:14
|
On 2004-04-19, at 20.56, Inger, Matthew wrote: > Sorry, > > about 28% is spent in multiplyRight, and 20% is spent in the BigMatrix > constructor. Generally speaking; working with BigDecimal will be slower than working with double. That's the price you pay to get rid of the rounding/representation errors. Would it help to implement multiplyRight in one of the MatrixStore subclasses? > If i switch to JamaMatrix, the time goes back down to what it was > using Jama by itself. This is a feature of ojAlgo! You can easily switch between three implementations with different characteristics: BigMatrix is more precise JamaMatrix is faster JampackMatrix works with complex numbers I'm sure each of the implementations can be improved in many respects, but you can't have it all. > -----Original Message----- > From: Anders Peterson [mailto:and...@op...] > Sent: Monday, April 19, 2004 2:14 PM > To: Inger, Matthew > Subject: Re: [ojAlgo-user] Questions > > > On 2004-04-19, at 20.04, Inger, Matthew wrote: > >> Let me at least see how turning the scale down helps. >> It appears that the majority of the time is spent in multiply >> and in the constructor. > > The BigMatrix or the QRDecomposition constructor? > >> I can send you the screenshot of what >> devpartner is telling me if you want. > > Yes, please. > > /Anders > >> -----Original Message----- >> From: Anders Peterson [mailto:and...@op...] >> Sent: Monday, April 19, 2004 2:02 PM >> To: Inger, Matthew >> Cc: 'oja...@li...' >> Subject: Re: [ojAlgo-user] Questions >> >> >> On 2004-04-19, at 18.33, Inger, Matthew wrote: >> >>> 1. Have any performance tests been run with BigMatrix? >> >> Not really... >> >>> I'm using >>> BigMatrix to do a >>> LinearRegression algorithm. I had previously been using Jama >>> directly, >>> but our FD >>> department noticed a difference between the results given by >>> java >>> and >>> the LINEST >>> function in Excel. I have determined that the difference is >>> DEFINATELY >>> due to rounding >>> limitations in the java double primitive type. >>> >>> These issues go away when i use ojAlgo library, >> >> That's great news to me - that is the reason I created ojAlgo! >> >>> however, the time >>> required to do the >>> calculations increases to about 12-13x what it was using regular >>> double >>> calculations. >>> >>> Doing 10,000 linear regressions with Jama took about .781s >>> (according >>> to junit), and >>> with BigMatrix, took 10.345s >> >> I wasn't aware the difference was that big. ;-) >> >>> Any idea why such a hug disparity? >> >> Try altering the scale. A larger scale means better results, but it >> takes longer. You can change a matrix' scale whenever you want - the >> new scale will be used from then on. Elements are not rounded unless >> you call enforceScale(). >> >> Internally BigMatrix uses various decompositions for some of the more >> complex calculations. These decompositions inherit a scale from the >> parent matrix. It is however not the same - it's bigger. I believe the >> formula is 2 * (3 + max(9, matrixScale)) and this formula is evaluated >> when the decomposition is created. After the decomposition is created >> its scale wont change even if you change the matrix' scale. The scale >> of a decomposition is never smaller than 24 (according to the above >> formula). >> >> I'm not happy with this, and have been meaning to change it. >> Decompositions should have the same scale as its parent matrix, and >> when it is changed, updated "everywhere". >> >> Would you prefer that? >> >>> 2. Is there a way to use the solvers in OjAlg to do the linear >>> regression? >>> Or is that not >>> something that is provided? >> >> How are you currently doing it? >> >> I imagine the best way would be to simply build an over-determined set >> of linear equations - Ax=B - and call A.solve(B). Internally BigMatrix >> would then use the QR decomposition to give a least squares estimation >> of x. That would be my first attempt. >> >> You could use the QP solver do the same thing, but I don't see how >> that >> would simplify or improve anything. >> >> What version of ojAlgo are you using - v1, v2 or CVS? >> >> I recommend working from CVS. Unfortunately I have moved things around >> a bit in between version... >> >> I don't have access to a profiling tool, but I know they can be very >> useful in finding bottlenecks. If you can identify a problem, and/or >> suggest a specific improvement, I'll be happy to help you implement >> it. >> >> /Anders >> >>> ---------------------- >>> Matthew Inger >>> Design Architect >>> Synygy, Inc >>> 610-664-7433 x7770 >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email is sponsored by: IBM Linux Tutorials >>> Free Linux tutorial presented by Daniel Robbins, President and CEO of >>> GenToo technologies. Learn everything from fundamentals to system >>> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >>> _______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user >>> >> > |
From: Anders P. <and...@op...> - 2004-04-20 08:54:45
|
Do you re-use the A-matrix? Are the x values the same for the 10k regressions? On 2004-04-19, at 21.03, Inger, Matthew wrote: > There are a small number of variables. In most cases, we > have a single variable equation, and up to 24 points with > which to fit the linear regression. > > Then, we do that 10,000 times. > > Basically, each row in the database contains time elapsed > data (typically one value per month). We use the # of the > month as the x values, and the data as the y value, and try > to fit a line to it to determine short term trends. > > So for each row, we calculate 1 set of coefficients (b0 and b1, > aka intercept & slope), and make 1 more predictions. > > However, there are potentially millions of rows in the database. > > > -----Original Message----- > From: Anders Peterson [mailto:and...@op...] > Sent: Monday, April 19, 2004 2:32 PM > To: Inger, Matthew > Subject: Re: [ojAlgo-user] Questions > > > This is just a naive first attempt... > > On 2004-04-19, at 20.06, Inger, Matthew wrote: > >> PS: As far as solving the equations, i basically have two >> matrices. X and Y. Any kind of code snippet would help here. >> Keep in mind, equations are of the form >> >> y = b0 + b1*X > > 1*b0 + x*b1 = y > > A*X = B > > where > > A: > 1 x1 > 1 x2 > 1 x3 > ... ... > > B: > y1 > y2 > y3 > ... > > X: > b0 > b1 > > X = A.solve(B); > > Are you doing this 10 000 times with a relatively small number of x- > and y-values or do you have 10 000 x- and y-values for each > calculation? > > /Anders > >> -----Original Message----- >> From: Anders Peterson [mailto:and...@op...] >> Sent: Monday, April 19, 2004 2:02 PM >> To: Inger, Matthew >> Cc: 'oja...@li...' >> Subject: Re: [ojAlgo-user] Questions >> >> >> On 2004-04-19, at 18.33, Inger, Matthew wrote: >> >>> 1. Have any performance tests been run with BigMatrix? >> >> Not really... >> >>> I'm using >>> BigMatrix to do a >>> LinearRegression algorithm. I had previously been using Jama >>> directly, >>> but our FD >>> department noticed a difference between the results given by >>> java >>> and >>> the LINEST >>> function in Excel. I have determined that the difference is >>> DEFINATELY >>> due to rounding >>> limitations in the java double primitive type. >>> >>> These issues go away when i use ojAlgo library, >> >> That's great news to me - that is the reason I created ojAlgo! >> >>> however, the time >>> required to do the >>> calculations increases to about 12-13x what it was using regular >>> double >>> calculations. >>> >>> Doing 10,000 linear regressions with Jama took about .781s >>> (according >>> to junit), and >>> with BigMatrix, took 10.345s >> >> I wasn't aware the difference was that big. ;-) >> >>> Any idea why such a hug disparity? >> >> Try altering the scale. A larger scale means better results, but it >> takes longer. You can change a matrix' scale whenever you want - the >> new scale will be used from then on. Elements are not rounded unless >> you call enforceScale(). >> >> Internally BigMatrix uses various decompositions for some of the more >> complex calculations. These decompositions inherit a scale from the >> parent matrix. It is however not the same - it's bigger. I believe the >> formula is 2 * (3 + max(9, matrixScale)) and this formula is evaluated >> when the decomposition is created. After the decomposition is created >> its scale wont change even if you change the matrix' scale. The scale >> of a decomposition is never smaller than 24 (according to the above >> formula). >> >> I'm not happy with this, and have been meaning to change it. >> Decompositions should have the same scale as its parent matrix, and >> when it is changed, updated "everywhere". >> >> Would you prefer that? >> >>> 2. Is there a way to use the solvers in OjAlg to do the linear >>> regression? >>> Or is that not >>> something that is provided? >> >> How are you currently doing it? >> >> I imagine the best way would be to simply build an over-determined set >> of linear equations - Ax=B - and call A.solve(B). Internally BigMatrix >> would then use the QR decomposition to give a least squares estimation >> of x. That would be my first attempt. >> >> You could use the QP solver do the same thing, but I don't see how >> that >> would simplify or improve anything. >> >> What version of ojAlgo are you using - v1, v2 or CVS? >> >> I recommend working from CVS. Unfortunately I have moved things around >> a bit in between version... >> >> I don't have access to a profiling tool, but I know they can be very >> useful in finding bottlenecks. If you can identify a problem, and/or >> suggest a specific improvement, I'll be happy to help you implement >> it. >> >> /Anders >> >>> ---------------------- >>> Matthew Inger >>> Design Architect >>> Synygy, Inc >>> 610-664-7433 x7770 >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email is sponsored by: IBM Linux Tutorials >>> Free Linux tutorial presented by Daniel Robbins, President and CEO of >>> GenToo technologies. Learn everything from fundamentals to system >>> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >>> _______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > |
From: Anders P. <and...@op...> - 2004-04-20 08:39:54
|
On 2004-04-19, at 22.39, Inger, Matthew wrote: > FYI: Using MatrixFactory is also extremely slow. > If i directly instantiate JamaMatrix for 100,000 > regressions, it takes ~ 2 seconds or so. If i use > MatrixFactory to instantiate, it goes up to 8 seconds. MatrixFactory uses reflection to call the appropriate constructor. Using it centralises matrix creation and allows you to switch implementation by changing one line of code - the call to the MatrixFactory constructor. (Make sure you re-use the factory instances.) This will naturally take longer than calling the constructor directly, but I am surprised it is that much slower. If this is a problem; call the constructors directly. Perhaps you should implement your own static factory method. > I'm a little curious why MatrixFactory is not an interface, > with implementations per different type of Matrix. Interfaces can't specify contructors. /Anders > -----Original Message----- > From: Inger, Matthew > Sent: Monday, April 19, 2004 3:04 PM > To: 'Anders Peterson'; Inger, Matthew > Subject: RE: [ojAlgo-user] Questions > > > There are a small number of variables. In most cases, we > have a single variable equation, and up to 24 points with > which to fit the linear regression. > > Then, we do that 10,000 times. > > Basically, each row in the database contains time elapsed > data (typically one value per month). We use the # of the > month as the x values, and the data as the y value, and try > to fit a line to it to determine short term trends. > > So for each row, we calculate 1 set of coefficients (b0 and b1, > aka intercept & slope), and make 1 more predictions. > > However, there are potentially millions of rows in the database. > > > -----Original Message----- > From: Anders Peterson [mailto:and...@op...] > Sent: Monday, April 19, 2004 2:32 PM > To: Inger, Matthew > Subject: Re: [ojAlgo-user] Questions > > > This is just a naive first attempt... > > On 2004-04-19, at 20.06, Inger, Matthew wrote: > >> PS: As far as solving the equations, i basically have two >> matrices. X and Y. Any kind of code snippet would help here. >> Keep in mind, equations are of the form >> >> y = b0 + b1*X > > 1*b0 + x*b1 = y > > A*X = B > > where > > A: > 1 x1 > 1 x2 > 1 x3 > ... ... > > B: > y1 > y2 > y3 > ... > > X: > b0 > b1 > > X = A.solve(B); > > Are you doing this 10 000 times with a relatively small number of x- > and y-values or do you have 10 000 x- and y-values for each > calculation? > > /Anders > >> -----Original Message----- >> From: Anders Peterson [mailto:and...@op...] >> Sent: Monday, April 19, 2004 2:02 PM >> To: Inger, Matthew >> Cc: 'oja...@li...' >> Subject: Re: [ojAlgo-user] Questions >> >> >> On 2004-04-19, at 18.33, Inger, Matthew wrote: >> >>> 1. Have any performance tests been run with BigMatrix? >> >> Not really... >> >>> I'm using >>> BigMatrix to do a >>> LinearRegression algorithm. I had previously been using Jama >>> directly, >>> but our FD >>> department noticed a difference between the results given by >>> java >>> and >>> the LINEST >>> function in Excel. I have determined that the difference is >>> DEFINATELY >>> due to rounding >>> limitations in the java double primitive type. >>> >>> These issues go away when i use ojAlgo library, >> >> That's great news to me - that is the reason I created ojAlgo! >> >>> however, the time >>> required to do the >>> calculations increases to about 12-13x what it was using regular >>> double >>> calculations. >>> >>> Doing 10,000 linear regressions with Jama took about .781s >>> (according >>> to junit), and >>> with BigMatrix, took 10.345s >> >> I wasn't aware the difference was that big. ;-) >> >>> Any idea why such a hug disparity? >> >> Try altering the scale. A larger scale means better results, but it >> takes longer. You can change a matrix' scale whenever you want - the >> new scale will be used from then on. Elements are not rounded unless >> you call enforceScale(). >> >> Internally BigMatrix uses various decompositions for some of the more >> complex calculations. These decompositions inherit a scale from the >> parent matrix. It is however not the same - it's bigger. I believe the >> formula is 2 * (3 + max(9, matrixScale)) and this formula is evaluated >> when the decomposition is created. After the decomposition is created >> its scale wont change even if you change the matrix' scale. The scale >> of a decomposition is never smaller than 24 (according to the above >> formula). >> >> I'm not happy with this, and have been meaning to change it. >> Decompositions should have the same scale as its parent matrix, and >> when it is changed, updated "everywhere". >> >> Would you prefer that? >> >>> 2. Is there a way to use the solvers in OjAlg to do the linear >>> regression? >>> Or is that not >>> something that is provided? >> >> How are you currently doing it? >> >> I imagine the best way would be to simply build an over-determined set >> of linear equations - Ax=B - and call A.solve(B). Internally BigMatrix >> would then use the QR decomposition to give a least squares estimation >> of x. That would be my first attempt. >> >> You could use the QP solver do the same thing, but I don't see how >> that >> would simplify or improve anything. >> >> What version of ojAlgo are you using - v1, v2 or CVS? >> >> I recommend working from CVS. Unfortunately I have moved things around >> a bit in between version... >> >> I don't have access to a profiling tool, but I know they can be very >> useful in finding bottlenecks. If you can identify a problem, and/or >> suggest a specific improvement, I'll be happy to help you implement >> it. >> >> /Anders >> >>> ---------------------- >>> Matthew Inger >>> Design Architect >>> Synygy, Inc >>> 610-664-7433 x7770 >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email is sponsored by: IBM Linux Tutorials >>> Free Linux tutorial presented by Daniel Robbins, President and CEO of >>> GenToo technologies. Learn everything from fundamentals to system >>> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click >>> _______________________________________________ >>> ojAlgo-user mailing list >>> ojA...@li... >>> https://lists.sourceforge.net/lists/listinfo/ojalgo-user > |
From: Anders P. <and...@op...> - 2004-04-19 18:02:38
|
On 2004-04-19, at 18.33, Inger, Matthew wrote: > 1. Have any performance tests been run with BigMatrix? Not really... > I'm using > BigMatrix to do a > LinearRegression algorithm. I had previously been using Jama > directly, > but our FD > department noticed a difference between the results given by java > and > the LINEST > function in Excel. I have determined that the difference is > DEFINATELY > due to rounding > limitations in the java double primitive type. > > These issues go away when i use ojAlgo library, That's great news to me - that is the reason I created ojAlgo! > however, the time > required to do the > calculations increases to about 12-13x what it was using regular > double > calculations. > > Doing 10,000 linear regressions with Jama took about .781s > (according > to junit), and > with BigMatrix, took 10.345s I wasn't aware the difference was that big. ;-) > Any idea why such a hug disparity? Try altering the scale. A larger scale means better results, but it takes longer. You can change a matrix' scale whenever you want - the new scale will be used from then on. Elements are not rounded unless you call enforceScale(). Internally BigMatrix uses various decompositions for some of the more complex calculations. These decompositions inherit a scale from the parent matrix. It is however not the same - it's bigger. I believe the formula is 2 * (3 + max(9, matrixScale)) and this formula is evaluated when the decomposition is created. After the decomposition is created its scale wont change even if you change the matrix' scale. The scale of a decomposition is never smaller than 24 (according to the above formula). I'm not happy with this, and have been meaning to change it. Decompositions should have the same scale as its parent matrix, and when it is changed, updated "everywhere". Would you prefer that? > 2. Is there a way to use the solvers in OjAlg to do the linear > regression? > Or is that not > something that is provided? How are you currently doing it? I imagine the best way would be to simply build an over-determined set of linear equations - Ax=B - and call A.solve(B). Internally BigMatrix would then use the QR decomposition to give a least squares estimation of x. That would be my first attempt. You could use the QP solver do the same thing, but I don't see how that would simplify or improve anything. What version of ojAlgo are you using - v1, v2 or CVS? I recommend working from CVS. Unfortunately I have moved things around a bit in between version... I don't have access to a profiling tool, but I know they can be very useful in finding bottlenecks. If you can identify a problem, and/or suggest a specific improvement, I'll be happy to help you implement it. /Anders > ---------------------- > Matthew Inger > Design Architect > Synygy, Inc > 610-664-7433 x7770 > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > ojAlgo-user mailing list > ojA...@li... > https://lists.sourceforge.net/lists/listinfo/ojalgo-user > |
From: Inger, M. <In...@Sy...> - 2004-04-19 16:35:24
|
1. Have any performance tests been run with BigMatrix? I'm using BigMatrix to do a LinearRegression algorithm. I had previously been using Jama directly, but our FD department noticed a difference between the results given by java and the LINEST function in Excel. I have determined that the difference is DEFINATELY due to rounding limitations in the java double primitive type. These issues go away when i use ojAlgo library, however, the time required to do the calculations increases to about 12-13x what it was using regular double calculations. Doing 10,000 linear regressions with Jama took about .781s (according to junit), and with BigMatrix, took 10.345s Any idea why such a hug disparity? 2. Is there a way to use the solvers in OjAlg to do the linear regression? Or is that not something that is provided? ---------------------- Matthew Inger Design Architect Synygy, Inc 610-664-7433 x7770 |
From: Anders P. <and...@op...> - 2004-02-27 20:28:40
|
The release contains contains: 1) License agreement 2) ojalgo_2.jar 3) Source code 4) Generated JavaDoc 5) Output from JUnit tests Please visit: http://ojalgo.org/ and join the mailing list ojalgo-user. Don't hesitate to get the latest source code from CVS. |
From: Anders P. <and...@op...> - 2003-07-31 13:25:22
|
BigMatrix works at least as good as it did before refactoring, and some bugs were fixed in JampackMatrix. There are more bugs in JampackMatrix (that package). The reason is that the original code used a mix of 0-based and 1-based array references, and they are now all 0-based. /Anders |
From: Anders P. <and...@op...> - 2003-06-29 23:20:15
|
Hi list reader, During the comming weeks there will be major refactoring of the org.ojalgo.math.big package. Until it's done the BigMatrix implementation will not function. Use tag Date20030630 to check out working code from CVS. /Anders |