Re: [math] Add module-info.java

2024-03-14 Thread Gili
Hi Gary,

I noticed that you are generating both Automatic-Module and
module-info.java. Isn't this problematic? Shouldn't you drop the automatic
module?

Also, I don't see the root pom adding any "export" statement to the
module-info file. Has anyone tested that thr output actually works as
expected?

Gili

On Thu, Mar 14, 2024, 20:50 Gary Gregory  wrote:

> The commons-parent POM automatically creates module-info.java files. A
> Commons component should not have to do anything beyond using a recent
> version.
>
> Gary
>
> On Thu, Mar 14, 2024, 8:03 PM Gili Tzabari  wrote:
>
> > Hi,
> >
> > I'd like Commons Math to add module-info.java to all the components. I
> > noticed that you are adding a "Automatic-Module" entry in META-INF but
> > this isn't enough for jlink (and related tools) to work properly. We
> > absolutely need to add module-info.java.
> >
> > You just need to add a few lines to pom.xml to turn your releases into
> > multirelease JAR files and you're done. Here is the code I lifted from
> >
> >
> https://medium.com/@ankitagrahari.rkgit/multi-release-functionality-8fc423b6c94e
> > :
> >
> > | java11 compile
> >  11
> >
> ${project.basedir}/src/main/java11
> >
> > true 
> >  |
> >
> > ||
> >
> > |Gili|
> >
>


Re: [math] Add module-info.java

2024-03-14 Thread Gary Gregory
The commons-parent POM automatically creates module-info.java files. A
Commons component should not have to do anything beyond using a recent
version.

Gary

On Thu, Mar 14, 2024, 8:03 PM Gili Tzabari  wrote:

> Hi,
>
> I'd like Commons Math to add module-info.java to all the components. I
> noticed that you are adding a "Automatic-Module" entry in META-INF but
> this isn't enough for jlink (and related tools) to work properly. We
> absolutely need to add module-info.java.
>
> You just need to add a few lines to pom.xml to turn your releases into
> multirelease JAR files and you're done. Here is the code I lifted from
>
> https://medium.com/@ankitagrahari.rkgit/multi-release-functionality-8fc423b6c94e
> :
>
> | java11 compile
>  11
> ${project.basedir}/src/main/java11
>
> true 
>  |
>
> ||
>
> |Gili|
>


[math] Add module-info.java

2024-03-14 Thread Gili Tzabari

Hi,

I'd like Commons Math to add module-info.java to all the components. I 
noticed that you are adding a "Automatic-Module" entry in META-INF but 
this isn't enough for jlink (and related tools) to work properly. We 
absolutely need to add module-info.java.


You just need to add a few lines to pom.xml to turn your releases into 
multirelease JAR files and you're done. Here is the code I lifted from 
https://medium.com/@ankitagrahari.rkgit/multi-release-functionality-8fc423b6c94e:


| java11 compile 
 11 
${project.basedir}/src/main/java11 
true   |


||

|Gili|


Re: math: how to initialize a custom prob. distribution function

2023-09-29 Thread Alex Herbert
On Fri, 29 Sept 2023 at 18:49, Siddharth Jain  wrote:
>
> thanks. i see this is filed under legacy namespace with the comment
> Implementations
> of common discrete and continuous distributions. [Mostly moved to the
> "Commons Statistics" project (cf. JIRA: MATH-1443).]
> i then checked
> https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/apidocs/allclasses-noframe.html
> but could not see this class there. should i still use commons-math? and
> the 4.0-beta1 does not seem to be in maven repository. could i get link to
> mvn coordinates if its published on maven?

https://central.sonatype.com/artifact/org.apache.commons/commons-math4-legacy

There are some distribution classes that remain in Commons Math as
they use more math code than just the functions required to implement
standard distributions.

The legacy module contains most of what was in Commons Math 3. This is
code that has not been refactored into modules within the modular
Commons Math 4 layout, or undergone a complete rewrite as a new
project (see Commons RNG, Numbers, Statistics and Geometry).

Alex

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: math: how to initialize a custom prob. distribution function

2023-09-29 Thread Siddharth Jain
thanks. i see this is filed under legacy namespace with the comment
Implementations
of common discrete and continuous distributions. [Mostly moved to the
"Commons Statistics" project (cf. JIRA: MATH-1443).]
i then checked
https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/apidocs/allclasses-noframe.html
but could not see this class there. should i still use commons-math? and
the 4.0-beta1 does not seem to be in maven repository. could i get link to
mvn coordinates if its published on maven?

On Fri, Sep 29, 2023 at 10:10 AM Alex Herbert 
wrote:

> This may be what you require:
>
>
> https://commons.apache.org/proper/commons-math/javadocs/api-4.0-beta1/org/apache/commons/math4/legacy/distribution/EmpiricalDistribution.html
>
> You will have to convert your float values to double and then specify
> the bin size:
>
> float[] x = ...
> int bins = 100;
> ContinuousDistribution d = EmpiricalDistribution.from(bins,
> IntStream.range(0, x.length).mapToDouble(i -> x[i]).toArray());
>
> On Fri, 29 Sept 2023 at 17:44, Siddharth Jain  wrote:
> >
> > I have a vector float[] x containing samples of a random variable. I
> would
> > like to initialize a prob. distribution fn. using these samples and then
> be
> > able to call methods like
> >
> https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/apidocs/org/apache/commons/statistics/distribution/ContinuousDistribution.html
> >
> > I am looking for an API like:
> >
> > var f = ContinuousDistribution.of(x)
> >
> > is this available in commons-math? thanks.
> >
> > S.
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>


Re: math: how to initialize a custom prob. distribution function

2023-09-29 Thread Alex Herbert
This may be what you require:

https://commons.apache.org/proper/commons-math/javadocs/api-4.0-beta1/org/apache/commons/math4/legacy/distribution/EmpiricalDistribution.html

You will have to convert your float values to double and then specify
the bin size:

float[] x = ...
int bins = 100;
ContinuousDistribution d = EmpiricalDistribution.from(bins,
IntStream.range(0, x.length).mapToDouble(i -> x[i]).toArray());

On Fri, 29 Sept 2023 at 17:44, Siddharth Jain  wrote:
>
> I have a vector float[] x containing samples of a random variable. I would
> like to initialize a prob. distribution fn. using these samples and then be
> able to call methods like
> https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/apidocs/org/apache/commons/statistics/distribution/ContinuousDistribution.html
>
> I am looking for an API like:
>
> var f = ContinuousDistribution.of(x)
>
> is this available in commons-math? thanks.
>
> S.

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



math: how to initialize a custom prob. distribution function

2023-09-29 Thread Siddharth Jain
I have a vector float[] x containing samples of a random variable. I would
like to initialize a prob. distribution fn. using these samples and then be
able to call methods like
https://commons.apache.org/proper/commons-statistics/commons-statistics-distribution/apidocs/org/apache/commons/statistics/distribution/ContinuousDistribution.html

I am looking for an API like:

var f = ContinuousDistribution.of(x)

is this available in commons-math? thanks.

S.


Re: user guide section 1.8 of commons-math

2023-08-17 Thread Gilles Sadowski
Hi.

Thanks for your interest in Commons Math.

Below there is a copy of your message, as it appears on this mailing list.
Some parts are obviously missing (perhaps because they were attachments).

If you'd like to suggest an improvement, please file a report on JIRA:
https://issues.apache.org/jira/projects/MATH

Regards,
Gilles

Le ven. 18 août 2023 à 00:41, 杨心文 蚊子  a écrit :
>
> Hello,
> These are something need to be modify in user guide of commons.math.
>
>
> Math – The Commons Math User Guide - Statistics (apache.org)
>
>
>
>
> The code above will display the t-statistic associated with a one-sample 
> t-test comparing the mean of theobservedvalues againstmu.To 
> compare the mean of a dataset described by aStatisticalSummaryto 
> a fixed value:double[] observed ={1d, 2d, 3d}; double mu = 2.5d; 
> SummaryStatistics sampleStats = new SummaryStatistics(); for (int i = 0; i < 
> observed.length; i++) {   sampleStats.addValue(observed[i]); } 
> System.out.println(TestUtils.t(mu, observed)); To be:
>
>
>
> The code above will display the t-statistic associated with a one-sample 
> t-test comparing the mean of theobservedvalues againstmu.
> To compare the mean of a dataset described by 
> aSummaryStatisticsto a fixed value:
>
> double[] observed ={1d, 2d, 3d}; double mu = 2.5d; SummaryStatistics 
> sampleStats = new SummaryStatistics(); for (int i = 0; i < observed.length; 
> i++) {   sampleStats.addValue(observed[i]); } 
> System.out.println(TestUtils.t(mu, sampleStats));
>
>
>
>
>
> 杨心文蚊子
> maliu...@qq.com

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[ANNOUNCE] Commons Math 4.0-beta1

2022-12-22 Thread Gilles Sadowski
More than 6.5 years after the last release, the ASF "Commons"
team is pleased to announce the availability of
  Commons Math (version 4.0-beta1)

The release notes can be reviewed at
  https://www.apache.org/dist/commons/math/RELEASE-NOTES.txt

Distribution packages can be downloaded from
  https://commons.apache.org/math/download_math.cgi

When downloading, please verify signatures using
  https://downloads.apache.org/commons/KEYS

Maven artifacts are also available from the Maven Central repository:
  https://repo.maven.apache.org/maven2/org/apache/commons


Best regards,
Gilles (for the "Commons" PMC)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [EXTERNAL] Re: [net] [logging] [math] [codec] Commons-net as dependency in other java projects?

2022-12-13 Thread Kearns, Aaron (Contractor)
Yes, this would appear to be the issue in question. Thanks for confirming as FP.

Aaron Kearns
KBR  |  Software Engineer, Government Solutions
Office: +1 505.853.2582  |  Mobile: +1 304.997.0148   
aaron.kea...@kbr.com<mailto:aaron.kea...@us.kbr.com> 
akea...@contractor.usgs.gov<mailto:akea...@contractor.usgs.gov>


This email, including any attached files, may contain confidential and 
privileged information for the sole use of the intended recipient.  Any review, 
use, distribution, or disclosure by others is strictly prohibited.  If you are 
not the intended recipient (or authorized to receive information for the 
intended recipient), please contact the sender by reply e-mail and delete all 
copies of this message.


From: Jurrie Overgoor 
Date: Monday, December 12, 2022 at 11:31 PM
To: user@commons.apache.org 
Subject: [EXTERNAL] Re: [net] [logging] [math] [codec] Commons-net as 
dependency in other java projects?


 This email has been received from outside of DOI - Use caution before clicking 
on links, opening attachments, or responding.



Hello Aaron,

Are you perhaps encountering
https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjeremylong%2FDependencyCheck%2Fissues%2F5132data=05%7C01%7Cakearns%40contractor.usgs.gov%7C4a58b2863e254987a6f008dadcd3a8ae%7C0693b5ba4b184d7b9341f32f400a5494%7C0%7C0%7C638065098895443475%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=D0wKU6%2F8XZHLVsg7dm0U88zrkycS5iHrnlhz%2BBM7T0g%3Dreserved=0
 ?

This should be fixed in 7.4.1 which was released only a few days ago.

With kind regards,

Jurrie


On 12-12-2022 23:54, Kearns, Aaron (Contractor) wrote:
>
> Hello all,
>
> I am a developer/maintainer of several java projects. Part of this is
> to keep aware of potential vulnerabilities in project imports. I am
> using the OWASP dependency checker plugin with gradle to identify
> potentially vulnerable projects. One project is getting flagged for
> its use of commons-math3 (directly imported by the project),
> commons-codec, and commons-logging (imported by other dependencies),
> which the checker claims have a vulnerability inherited from commons-net.
>
> The problem is that I cannot find a reference to commons-net as a
> dependency anywhere in any of these projects (either the gradle
> dependency list or the project pages themselves), which makes me
> wonder why this error is occurring. I am attempting to fix this issue
> by both excluding commons-net from the dependencies.
>
> I am sending this email in hopes of verifying that this would be a
> useful action. It is possible that the vulnerability checker is
> reporting a false-positive (this is not the first time it has done
> so), in which case I just need to add an exclusion and don’t actually
> have to set any manual exclusions in the imports and don’t need to do
> any gradle manipulations to fix it; if I don’t have to, I’d rather
> not, as it clutters up the dependency list rather significantly.
>
> *Aaron Kearns*
>
> KBR  |  Software Engineer, Government Solutions
>
> Office: +1 505.853.2582  |  Mobile: +1 304.997.0148
> aaron.kea...@kbr.com
> <mailto:aaron.kea...@us.kbr.com>akea...@contractor.usgs.gov
> <mailto:akea...@contractor.usgs.gov>
>
> This email, including any attached files, may contain confidential and
> privileged information for the sole use of the intended recipient.
> Any review, use, distribution, or disclosure by others is strictly
> prohibited.  If you are not the intended recipient (or authorized to
> receive information for the intended recipient), please contact the
> sender by reply e-mail and delete all copies of this message.
>


Re: [net] [logging] [math] [codec] Commons-net as dependency in other java projects?

2022-12-12 Thread Jurrie Overgoor

Hello Aaron,

Are you perhaps encountering 
https://github.com/jeremylong/DependencyCheck/issues/5132 ?


This should be fixed in 7.4.1 which was released only a few days ago.

With kind regards,

Jurrie


On 12-12-2022 23:54, Kearns, Aaron (Contractor) wrote:


Hello all,

I am a developer/maintainer of several java projects. Part of this is 
to keep aware of potential vulnerabilities in project imports. I am 
using the OWASP dependency checker plugin with gradle to identify 
potentially vulnerable projects. One project is getting flagged for 
its use of commons-math3 (directly imported by the project), 
commons-codec, and commons-logging (imported by other dependencies), 
which the checker claims have a vulnerability inherited from commons-net.


The problem is that I cannot find a reference to commons-net as a 
dependency anywhere in any of these projects (either the gradle 
dependency list or the project pages themselves), which makes me 
wonder why this error is occurring. I am attempting to fix this issue 
by both excluding commons-net from the dependencies.


I am sending this email in hopes of verifying that this would be a 
useful action. It is possible that the vulnerability checker is 
reporting a false-positive (this is not the first time it has done 
so), in which case I just need to add an exclusion and don’t actually 
have to set any manual exclusions in the imports and don’t need to do 
any gradle manipulations to fix it; if I don’t have to, I’d rather 
not, as it clutters up the dependency list rather significantly.


*Aaron Kearns*

KBR  |  Software Engineer, Government Solutions

Office: +1 505.853.2582  |  Mobile: +1 304.997.0148 
aaron.kea...@kbr.com 
akea...@contractor.usgs.gov 



This email, including any attached files, may contain confidential and 
privileged information for the sole use of the intended recipient.  
Any review, use, distribution, or disclosure by others is strictly 
prohibited.  If you are not the intended recipient (or authorized to 
receive information for the intended recipient), please contact the 
sender by reply e-mail and delete all copies of this message.


Re: [net] [logging] [math] [codec] Commons-net as dependency in other java projects?

2022-12-12 Thread Gilles Sadowski
Hi.

Le mar. 13 déc. 2022 à 00:40, Kearns, Aaron (Contractor)
 a écrit :
>
> Hello all,
>
>
>
> I am a developer/maintainer of several java projects. Part of this is to keep 
> aware of potential vulnerabilities in project imports. I am using the OWASP 
> dependency checker plugin with gradle to identify potentially vulnerable 
> projects. One project is getting flagged for its use of commons-math3 
> (directly imported by the project), commons-codec, and commons-logging 
> (imported by other dependencies), which the checker claims have a 
> vulnerability inherited from commons-net.
>
>
>
> The problem is that I cannot find a reference to commons-net as a dependency 
> anywhere in any of these projects (either the gradle dependency list or the 
> project pages themselves), which makes me wonder why this error is occurring. 
> I am attempting to fix this issue by both excluding commons-net from the 
> dependencies.
>
>
>
> I am sending this email in hopes of verifying that this would be a useful 
> action. It is possible that the vulnerability checker is reporting a 
> false-positive (this is not the first time it has done so), in which case I 
> just need to add an exclusion and don’t actually have to set any manual 
> exclusions in the imports and don’t need to do any gradle manipulations to 
> fix it; if I don’t have to, I’d rather not, as it clutters up the dependency 
> list rather significantly.
>
>

Commons Math v3.6.1 (and earlier) has no dependencies, except for
running the test suite.
The upcoming release (v4.0-beta1) will depend on other Commons
components ("Numbers", "Geometry", "RNG" and "Statistics").

Regards,
Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[net] [logging] [math] [codec] Commons-net as dependency in other java projects?

2022-12-12 Thread Kearns, Aaron (Contractor)
Hello all,

I am a developer/maintainer of several java projects. Part of this is to keep 
aware of potential vulnerabilities in project imports. I am using the OWASP 
dependency checker plugin with gradle to identify potentially vulnerable 
projects. One project is getting flagged for its use of commons-math3 (directly 
imported by the project), commons-codec, and commons-logging (imported by other 
dependencies), which the checker claims have a vulnerability inherited from 
commons-net.

The problem is that I cannot find a reference to commons-net as a dependency 
anywhere in any of these projects (either the gradle dependency list or the 
project pages themselves), which makes me wonder why this error is occurring. I 
am attempting to fix this issue by both excluding commons-net from the 
dependencies.

I am sending this email in hopes of verifying that this would be a useful 
action. It is possible that the vulnerability checker is reporting a 
false-positive (this is not the first time it has done so), in which case I 
just need to add an exclusion and don’t actually have to set any manual 
exclusions in the imports and don’t need to do any gradle manipulations to fix 
it; if I don’t have to, I’d rather not, as it clutters up the dependency list 
rather significantly.

Aaron Kearns
KBR  |  Software Engineer, Government Solutions
Office: +1 505.853.2582  |  Mobile: +1 304.997.0148   
aaron.kea...@kbr.com 
akea...@contractor.usgs.gov


This email, including any attached files, may contain confidential and 
privileged information for the sole use of the intended recipient.  Any review, 
use, distribution, or disclosure by others is strictly prohibited.  If you are 
not the intended recipient (or authorized to receive information for the 
intended recipient), please contact the sender by reply e-mail and delete all 
copies of this message.



Re: [math] Compute derivatives for bidimensional interpolated function

2022-07-20 Thread Gilles Sadowski
Le mer. 20 juil. 2022 à 21:34, Alessandro Moscatelli
 a écrit :
>
> It seems that the SplineInterpolator per row/columns is exactly what the 
> depracted Cubic Interpolator was doing.
> So, nevermind, I got my answer. It made sense indeed.
>
> Looking further into the code for PR porpuses.

Great, thanks!

Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



R: [math] Compute derivatives for bidimensional interpolated function

2022-07-20 Thread Alessandro Moscatelli
It seems that the SplineInterpolator per row/columns is exactly what the 
depracted Cubic Interpolator was doing.
So, nevermind, I got my answer. It made sense indeed.

Looking further into the code for PR porpuses.

Thank you
Alessandro

Da: Alessandro Moscatelli<mailto:alessandro.moscate...@live.com>
Inviato: mercoledì 20 luglio 2022 15:01
A: Commons Users List<mailto:user@commons.apache.org>
Oggetto: R: [math] Compute derivatives for bidimensional interpolated function

We are talking about making a PR, am I right ?
So, I guess, there is no way to do this at the moment.

Isn’t there any way to combine multiple UnivariateDifferentiableFunction and/or 
DerivativeStructure computed on different free parameters (es x and y) ?
I dunno if I am exaplining this correctly :

I am talking about using a SplineInterpolator to compute multiple 
SplineInterpolatorFunction, one for each row and column of the grid …
Can this make sense ?

Anyway I’ll take a look at the source code and try to understand what’s needed 
to make BicubicInterpolatingFunction an implementation for that new interface 
BivariateDifferentiableFunction.

Thank you
Alessandro

Da: Gilles Sadowski<mailto:gillese...@gmail.com>
Inviato: mercoledì 20 luglio 2022 14:10
A: Commons Users List<mailto:user@commons.apache.org>
Oggetto: Re: [math] Compute derivatives for bidimensional interpolated function

Hello.

Le mer. 20 juil. 2022 à 12:29, Alessandro Moscatelli
 a écrit :
>
> Hi everybody !
>
> I have an xyz grid of points.
> I want to interpolate and compute derivations along x, along y, and along xy.
>
> If I understood correctly, I can’t use PiecewiseBicubicSplineInterpolator 
> (this was my first attempt), since it interpolates into 
> PiecewiseBicubicSplineInterpolatingFunction which doesn’t implements 
> MultivariateDifferentiableFunction .
>
> I need a function able to return DerivativeStructure, am I right ?

I think so.

>
> Then I double checked and found a deprecated BicubicSplineInterpolator.
> That interpolator lets me directly compute derivatives I need.

This class does not exist in the development version that will become
the next major version (4.0).

> Am I missing something ?
> How can I do what I need without using deprecated BicubicSplineInterpolator.

As you suggest, it would be great that you explore how to provide
access to the derivatives (which the interpolating functions are able
to compute, since they are polynomials).

A minimal change would perhaps be that "BicubicInterpolatingFunction"
implements a new "BivariateDifferentiableFunction" interface:
---CUT---
public interface BivariateDifferentiableFunction extends
BinaryOperator
{}
---CUT---

Regards,
Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



R: [math] Compute derivatives for bidimensional interpolated function

2022-07-20 Thread Alessandro Moscatelli
We are talking about making a PR, am I right ?
So, I guess, there is no way to do this at the moment.

Isn’t there any way to combine multiple UnivariateDifferentiableFunction and/or 
DerivativeStructure computed on different free parameters (es x and y) ?
I dunno if I am exaplining this correctly :

I am talking about using a SplineInterpolator to compute multiple 
SplineInterpolatorFunction, one for each row and column of the grid …
Can this make sense ?

Anyway I’ll take a look at the source code and try to understand what’s needed 
to make BicubicInterpolatingFunction an implementation for that new interface 
BivariateDifferentiableFunction.

Thank you
Alessandro

Da: Gilles Sadowski<mailto:gillese...@gmail.com>
Inviato: mercoledì 20 luglio 2022 14:10
A: Commons Users List<mailto:user@commons.apache.org>
Oggetto: Re: [math] Compute derivatives for bidimensional interpolated function

Hello.

Le mer. 20 juil. 2022 à 12:29, Alessandro Moscatelli
 a écrit :
>
> Hi everybody !
>
> I have an xyz grid of points.
> I want to interpolate and compute derivations along x, along y, and along xy.
>
> If I understood correctly, I can’t use PiecewiseBicubicSplineInterpolator 
> (this was my first attempt), since it interpolates into 
> PiecewiseBicubicSplineInterpolatingFunction which doesn’t implements 
> MultivariateDifferentiableFunction .
>
> I need a function able to return DerivativeStructure, am I right ?

I think so.

>
> Then I double checked and found a deprecated BicubicSplineInterpolator.
> That interpolator lets me directly compute derivatives I need.

This class does not exist in the development version that will become
the next major version (4.0).

> Am I missing something ?
> How can I do what I need without using deprecated BicubicSplineInterpolator.

As you suggest, it would be great that you explore how to provide
access to the derivatives (which the interpolating functions are able
to compute, since they are polynomials).

A minimal change would perhaps be that "BicubicInterpolatingFunction"
implements a new "BivariateDifferentiableFunction" interface:
---CUT---
public interface BivariateDifferentiableFunction extends
BinaryOperator
{}
---CUT---

Regards,
Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] Compute derivatives for bidimensional interpolated function

2022-07-20 Thread Gilles Sadowski
Hello.

Le mer. 20 juil. 2022 à 12:29, Alessandro Moscatelli
 a écrit :
>
> Hi everybody !
>
> I have an xyz grid of points.
> I want to interpolate and compute derivations along x, along y, and along xy.
>
> If I understood correctly, I can’t use PiecewiseBicubicSplineInterpolator 
> (this was my first attempt), since it interpolates into 
> PiecewiseBicubicSplineInterpolatingFunction which doesn’t implements 
> MultivariateDifferentiableFunction .
>
> I need a function able to return DerivativeStructure, am I right ?

I think so.

>
> Then I double checked and found a deprecated BicubicSplineInterpolator.
> That interpolator lets me directly compute derivatives I need.

This class does not exist in the development version that will become
the next major version (4.0).

> Am I missing something ?
> How can I do what I need without using deprecated BicubicSplineInterpolator.

As you suggest, it would be great that you explore how to provide
access to the derivatives (which the interpolating functions are able
to compute, since they are polynomials).

A minimal change would perhaps be that "BicubicInterpolatingFunction"
implements a new "BivariateDifferentiableFunction" interface:
---CUT---
public interface BivariateDifferentiableFunction extends
BinaryOperator
{}
---CUT---

Regards,
Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] Compute derivatives for bidimensional interpolated function

2022-07-20 Thread Alessandro Moscatelli
Hi everybody !

I have an xyz grid of points.
I want to interpolate and compute derivations along x, along y, and along xy.

If I understood correctly, I can’t use PiecewiseBicubicSplineInterpolator (this 
was my first attempt), since it interpolates into 
PiecewiseBicubicSplineInterpolatingFunction which doesn’t implements 
MultivariateDifferentiableFunction .

I need a function able to return DerivativeStructure, am I right ?

Then I double checked and found a deprecated BicubicSplineInterpolator.
That interpolator lets me directly compute derivatives I need.

Am I missing something ?
How can I do what I need without using deprecated BicubicSplineInterpolator.

Thank you in advance
Alessandro Moscatelli



Re: Apache Commons Math of Curve Fitting how to constraint Parameters

2022-01-24 Thread Gilles Sadowski
Hello.

Le lun. 24 janv. 2022 à 08:21, qiqi tang  a écrit :
>
> *HI Gilles Sadowski,*
>
>
>
> @Overridepublic double[] fit(Collection points) {
> final double[] p = super.fit(points);
> return new double[] {
> constrainedM.value(p[0]),
> constrainedK.value(p[1]),
> p[2]
> };
> }
>
> This method Just maps  the end result to the range I want.

You've cut several pieces of the suggested code.
[Also, please keep this discussion within a unique
ML thread.]

Did you try the proposed full set of changes?
Was the output of the code not a local optimum?

The feature you need deserves to be part of the test suite,
so you are welcome to file a report on the issue-tracking
system (see detailed information on the project's page).
You should then rewrite your case in the form of a (JUnit)
unit test (see the "test" part of the source repository).

> I think I need to
> let the return value of the fit method fall within the set range,

What do you mean by
> let the [...] value [...] fall within the [...] range
?

What happens if you don't use the suggested trick?
If the value doesn't settle in that range by itself, it means
that there are local minima.

> rather
> than processing the return value of the fit method twice. Just like example:
>
> @Overridepublic double[] fit(Collection points) {
> return  super.fit(points);}
>
> The above method returns a value that is directly in the range of the
> parameter variable I want.

In your previous message, you asked:

> What should I do to limit the parameters 'm' to 1 to 100 and 'k'
> to 100 to 10,000

So indeed, bugs notwithstanding, my proposed solution is
supposed to reach that goal by assuming that the domain
of those parameters are the given ranges.

Regards,
Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Apache Commons Math of Curve Fitting how to constraint Parameters

2022-01-23 Thread qiqi tang
*HI Gilles Sadowski,*



@Overridepublic double[] fit(Collection points) {
final double[] p = super.fit(points);
return new double[] {
constrainedM.value(p[0]),
constrainedK.value(p[1]),
p[2]
};
}

This method Just maps  the end result to the range I want.I think I need to
let the return value of the fit method fall within the set range, rather
than processing the return value of the fit method twice. Just like example:

@Overridepublic double[] fit(Collection points) {
return  super.fit(points);}

The above method returns a value that is directly in the range of the
parameter variable I want.

Regards,
Qiqi


Re: Apache Commons Math of Curve Fitting how to constraint Parameters

2022-01-20 Thread Gilles Sadowski
Hello.

Le jeu. 20 janv. 2022 à 15:06, qiqi tang  a écrit :
>
> Dear Sir/Madam,
>I recently used the CurveFitter tool inside the commons package and
> I found a problem that I couldn't constrain the relevant parameters.

A possible approach is to transform the relevant parameters so
that whatever value is tried by the optimizer, it always maps to a
value within the allowed range (see below).

> The specific relevant codes are as follows:

import org.apache.commons.math4.legacy.analysis.function.Logit;
import org.apache.commons.math4.legacy.analysis.function.Sigmoid;

> public class MyFuncFitter extends AbstractCurveFitter {
private Sigmoid constrainedM;
private Logit unconstrainedK;
private Sigmoid constrainedK;
private Logit unconstrainedK

public MyFuncFitter(minM, maxM, minK, maxK) {
constrainedM = new Sigmoid(minM, maxM);
unconstrainedM = new Logit(minM, maxM);
constrainedK = new Sigmoid(minK, maxK);
unconstrainedK = new Logit(minK, maxK);
   }

> @Override
> protected LeastSquaresProblem
> getProblem(Collection points) {
> final int len = points.size();
> final double[] target = new double[len];
> final double[] weights = new double[len];
> final double[] initialGuess = {
  unconstrainedM.value(50),
  unconstrainedK.value(1.0),
  1.0
   };
>
> int i = 0;
> for (WeightedObservedPoint point : points) {
> target[i] = point.getY();
> weights[i] = point.getWeight();
> i += 1;
> }
>
> final AbstractCurveFitter.TheoreticalValuesFunction model =
> new AbstractCurveFitter.TheoreticalValuesFunction(new MyFunc(),
> points);
>
> return new LeastSquaresBuilder().
> maxEvaluations(Integer.MAX_VALUE).
> maxIterations(Integer.MAX_VALUE).
> start(initialGuess).
> target(target).
> weight(new DiagonalMatrix(weights)).
> model(model.getModelFunction(),
> model.getModelFunctionJacobian()).build();
> }}
>
> public class MyFunc implements ParametricUnivariateFunction {
> @Override
> public double value(double x, double... parameters) {
 final double m = constrainedM.value(parameters[0]);
 final double k = constrainedK.value(parameters[1]);
 final double b = parameters[2];

> return m * k * b * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k
> * x), b - 1);
> }
>
> @Override
> public double[] gradient(double x, double... parameters) {
 final double m = constrainedM.value(parameters[0]);
 final double k = constrainedK.value(parameters[1]);
 final double b = parameters[2];

> return new double[]{
> b * k * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k *
> x), b - 1),
> (b - 1) * b * k * m * x * Math.exp(-2 * k * x) *
> Math.pow(1 - Math.exp(-k * x), b - 2) + b * m * Math.exp(-k * x) *
> Math.pow(1 - Math.exp(-k * x), b - 1) - b * k * m * x * Math.exp(-k *
> x) * Math.pow(1 - Math.exp(-k * x), b - 1),
> k * m * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k *
> x), b - 1) + b * k * m * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k *
> x), b - 1) * Math.log(1 - Math.exp(-k * x))
> };

@Override
public double[] fit(Collection points) {
final double[] p = super.fit(points);
return new double[] {
constrainedM.value(p[0]),
constrainedK.value(p[1]),
p[2]
};
}

> }
>
> public static void main(String[] args) {
> MyFuncFitter fitter = new MyFuncFitter();
> ArrayList points = new ArrayList<>();
> points.add(new WeightedObservedPoint(1.0, 0.25, 3.801713179));
> points.add(new WeightedObservedPoint(1.0, 4, 10.46561902));
> final double coeffs[] = fitter.fit(points);
> System.out.println(Arrays.toString(coeffs));
> }}
>
> Then, What should I do to limit the parameters 'm' to 1 to 100 and 'k'
> to 100 to 10,000,It would be nice if the code dome was available.

I don't understand what "code dome" means.

> Please help me thank you very much!

Let us know how the above suggestion (untested code) went.

Best regards,
Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Apache Commons Math of Curve Fitting how to constraint Parameters

2022-01-20 Thread qiqi tang
Dear Sir/Madam,
   I recently used the CurveFitter tool inside the commons package and
I found a problem that I couldn't constrain the relevant parameters.
The specific relevant codes are as follows:

public class MyFuncFitter extends AbstractCurveFitter {

@Override
protected LeastSquaresProblem
getProblem(Collection points) {
final int len = points.size();
final double[] target = new double[len];
final double[] weights = new double[len];
final double[] initialGuess = {50, 1.0, 1.0};

int i = 0;
for (WeightedObservedPoint point : points) {
target[i] = point.getY();
weights[i] = point.getWeight();
i += 1;
}

final AbstractCurveFitter.TheoreticalValuesFunction model =
new AbstractCurveFitter.TheoreticalValuesFunction(new MyFunc(),
points);

return new LeastSquaresBuilder().
maxEvaluations(Integer.MAX_VALUE).
maxIterations(Integer.MAX_VALUE).
start(initialGuess).
target(target).
weight(new DiagonalMatrix(weights)).
model(model.getModelFunction(),
model.getModelFunctionJacobian()).build();
}}

public class MyFunc implements ParametricUnivariateFunction {
@Override
public double value(double x, double... parameters) {
double m = parameters[0], k = parameters[1], b = parameters[2];
return m * k * b * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k
* x), b - 1);
}

@Override
public double[] gradient(double x, double... parameters) {
final double m = parameters[0];
final double k = parameters[1];
final double b = parameters[2];
return new double[]{
b * k * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k *
x), b - 1),
(b - 1) * b * k * m * x * Math.exp(-2 * k * x) *
Math.pow(1 - Math.exp(-k * x), b - 2) + b * m * Math.exp(-k * x) *
Math.pow(1 - Math.exp(-k * x), b - 1) - b * k * m * x * Math.exp(-k *
x) * Math.pow(1 - Math.exp(-k * x), b - 1),
k * m * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k *
x), b - 1) + b * k * m * Math.exp(-k * x) * Math.pow(1 - Math.exp(-k *
x), b - 1) * Math.log(1 - Math.exp(-k * x))
};
}

public static void main(String[] args) {
MyFuncFitter fitter = new MyFuncFitter();
ArrayList points = new ArrayList<>();
points.add(new WeightedObservedPoint(1.0, 0.25, 3.801713179));
points.add(new WeightedObservedPoint(1.0, 4, 10.46561902));
final double coeffs[] = fitter.fit(points);
System.out.println(Arrays.toString(coeffs));
}}

Then, What should I do to limit the parameters 'm' to 1 to 100 and 'k'
to 100 to 10,000,It would be nice if the code dome was available.
Please help me thank you very much!
Best Regards


Re: [math] Reduce density of a point cloud

2021-11-23 Thread Matt Juntunen
Hi Patrik,

It's funny that you mention this because I am currently working on
GEOMETRY-142 [1] in commons-geometry which exactly addresses this
issue. The idea is to have PointMapXD and PointSetXD classes that
store point keys using a precision context, which allows "fuzzy"
comparisons. So, if you create a set with a
Precision.DoubleEquivalence instance with an epsilon of 0.1 and add
all of the points, the "unique" points left in the map will all be at
least a distance of 0.1 away from each other. I'm very early on in the
ticket so I haven't decided what type of algorithm and data structure
to use. If you have any input, it would be most helpful.

Regards,
Matt J

[1] https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-142

On Tue, Nov 23, 2021 at 10:14 AM Patrik Karlström  wrote:
>
> Hi,
> I am working with metric coordinates captured with a 3d scanner.
> The data set tends to be unnecessary large for a simple visualization and a
> bit heavy too.
>
> Does math have something ready made that I can feed my data along with a
> parameter of let's say 0.1 meter rendering a set where no remaining point
> is located closer than 0.1 meter to another?
>
> I have some ideas on how to do this "manually" but I suspect this might be
> an existing feature of commons-math.
>
> Patrik

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] Reduce density of a point cloud

2021-11-23 Thread Patrik Karlström
Hi,
I am working with metric coordinates captured with a 3d scanner.
The data set tends to be unnecessary large for a simple visualization and a
bit heavy too.

Does math have something ready made that I can feed my data along with a
parameter of let's say 0.1 meter rendering a set where no remaining point
is located closer than 0.1 meter to another?

I have some ideas on how to do this "manually" but I suspect this might be
an existing feature of commons-math.

Patrik


distribution fitting with commons math

2021-10-10 Thread Jorge Garcia de Alba
Hello,

I would like to use commons math to fit a probability distribution to
my data and then test for close fit using the kolmogorov-smirnov test.
Where can I find example code on how to do this? Have a great day.

Jorge

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Using Apache Commons Math in Java Language Routines (SQL/JRT) in HSQLDB

2021-08-10 Thread Gilles Sadowski
Le mar. 10 août 2021 à 20:23, Gilles Sadowski  a écrit :
>
> Hi.
>
> Le mar. 10 août 2021 à 17:38, Jorge Garcia de Alba
>  a écrit :
> >
> > Hello,
> >
> > Would apache commons math be interested in adding code that could
> > easily be used in java language routines or is this out of scope? I
> > think they would be the best choice for implementing this.
> >
> > This is how I imagine it would be used.
> > https://github.com/xjrga/linearprogramming
>
> Is the "LPModel" class[1] which I should look at?
>
> This code is extremely fragile: All the callers within a single JVM
> are mutating the same data (a global variable indeed).
>
> If you require C-like behaviour (through Java "static" functions),
> you should at least have the caller create his own "LPModel"
> instance and have the function(s) take that as an argument.
> For example:
>
> public class LPModel {
> private final ArrayList constraints;
> // etc..
> // -> Remove "static" from _all_ fields (no global data).
>
> // Define a constructor.
> public LPModel(/* arguments */) {
> constraints = ... // Initialize from the constructor's arguments.
> }
>
> public static class Solution {
> // -> A container for the result of a computation.
> }
>
> public Solution solve() {
>// ...
> }
> }
>
> Then if there is a high-level requirement for calling through static
> functions, you'd create a "utility" class:
>
> public class LPModelUtils {
> // Instance creation function.
> public static LPModel create(/* arguments */) {
> return new LPModel(/* arguments */);
> }
>
> // Solver function.
> public LPModel.solution solve(LPModel instance) {
> return instance.solve();
> }
> }

public static LPModel.solution solve(LPModel instance) { ... }

>
> > Here is information on java language routines.
> > http://hsqldb.org/doc/guide/sqlroutines-chapt.html#src_jrt_routines
>
> Thanks.  This is high-level requirement that would probably
> call into an intermediate level doing the adaptation to the
> low-level Commons Math (CM) API; I don't think that it can
> provide useful hints about what the CM API should look like.
>
> Best regards,
> Gilles
>
> [1] 
> https://github.com/xjrga/linearprogramming/blob/master/src/main/java/io/github/xjrga/linearprogram/LPModel.java

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Using Apache Commons Math in Java Language Routines (SQL/JRT) in HSQLDB

2021-08-10 Thread Gilles Sadowski
Hi.

Le mar. 10 août 2021 à 17:38, Jorge Garcia de Alba
 a écrit :
>
> Hello,
>
> Would apache commons math be interested in adding code that could
> easily be used in java language routines or is this out of scope? I
> think they would be the best choice for implementing this.
>
> This is how I imagine it would be used.
> https://github.com/xjrga/linearprogramming

Is the "LPModel" class[1] which I should look at?

This code is extremely fragile: All the callers within a single JVM
are mutating the same data (a global variable indeed).

If you require C-like behaviour (through Java "static" functions),
you should at least have the caller create his own "LPModel"
instance and have the function(s) take that as an argument.
For example:

public class LPModel {
private final ArrayList constraints;
// etc..
// -> Remove "static" from _all_ fields (no global data).

// Define a constructor.
public LPModel(/* arguments */) {
constraints = ... // Initialize from the constructor's arguments.
}

public static class Solution {
// -> A container for the result of a computation.
}

public Solution solve() {
   // ...
}
}

Then if there is a high-level requirement for calling through static
functions, you'd create a "utility" class:

public class LPModelUtils {
// Instance creation function.
public static LPModel create(/* arguments */) {
return new LPModel(/* arguments */);
}

// Solver function.
public LPModel.solution solve(LPModel instance) {
return instance.solve();
}
}

> Here is information on java language routines.
> http://hsqldb.org/doc/guide/sqlroutines-chapt.html#src_jrt_routines

Thanks.  This is high-level requirement that would probably
call into an intermediate level doing the adaptation to the
low-level Commons Math (CM) API; I don't think that it can
provide useful hints about what the CM API should look like.

Best regards,
Gilles

[1] 
https://github.com/xjrga/linearprogramming/blob/master/src/main/java/io/github/xjrga/linearprogram/LPModel.java

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Using Apache Commons Math in Java Language Routines (SQL/JRT) in HSQLDB

2021-08-10 Thread Jorge Garcia de Alba
Hello,

Would apache commons math be interested in adding code that could
easily be used in java language routines or is this out of scope? I
think they would be the best choice for implementing this.

This is how I imagine it would be used.
https://github.com/xjrga/linearprogramming

Here is information on java language routines.
http://hsqldb.org/doc/guide/sqlroutines-chapt.html#src_jrt_routines

Thanks.

Jorge Garcia de Alba

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: Using Apache Commons Math in Java Language Routines (SQL/JRT) in HSQLDB

2021-08-04 Thread Gilles Sadowski
Hello.

Le mer. 4 août 2021 à 14:03, Jorge Garcia de Alba
 a écrit :
>
> Hello,
>
> I am interested in using the simplexsolver in a java language routine
> in hsqldb. Hsqldb requires that the body of the java language routine
> to be a static method. I wonder if such methods could be created and
> implemented so they could be easily be used in java language routines.

What is a "routine" in this context?

Writing a static function (in your application) would be fairly easy:
---CUT---
import org.apache.commons.math4.legacy.optim.OptimizationData;
import org.apache.commons.math4.legacy.optim.PointValuePair;
import org.apache.commons.math4.legacy.optim.linear.SimplexSolver;

public class MyMathUtils {
public static PointValuePair solve(/* list of params */) {
final SimplexSolver s = new SimplexSolver();
final OptimizationData[] data = /* populate with params */;
return s.optimize(data);
}
}
---CUT---

Best regards,
Gilles

> Great job.
>
> org.apache.commons.math3.optim.linear.SimplexSolver
>
> Jorge Garcia de Alba

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Using Apache Commons Math in Java Language Routines (SQL/JRT) in HSQLDB

2021-08-04 Thread Jorge Garcia de Alba
Hello,

I am interested in using the simplexsolver in a java language routine
in hsqldb. Hsqldb requires that the body of the java language routine
to be a static method. I wonder if such methods could be created and
implemented so they could be easily be used in java language routines.
Great job.

org.apache.commons.math3.optim.linear.SimplexSolver

Jorge Garcia de Alba

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2021-06-08 Thread Christoph Läubrich

Hi Gilles and Randy,

that sounds really interesting I'll try this out, both the sigmodial and 
the scaling stuff!


I'm relative new to all this least squares things and I'm not a 
mathematician so I need to learn a lot, so don't hesitate to point out 
things that might seem obvious to the advanced user, that's really 
welcome :-)


Am 08.06.21 um 15:23 schrieb Gilles Sadowski:

Hello.

Le mar. 8 juin 2021 à 08:14, Christoph Läubrich
 a écrit :


Hi Gilles,

I have used the the INFINITY approach for a while now and it works quite
good. I just recently found a problem where I got very bad fits after a
handful of iterations using the LevenbergMarquardtOptimizer.

The problem arises whenever there is a relative small range of valid
values for *one* parameter.

Too keep up with the Gausian example assume that the mean is only valid
in a small window, but norm and sigma are completely free.

My guess is, if in the data there are outlier that indicates a strong
maximum outside this range the optimizer try to go in that 'direction'
because I reject this solution it 'gives up' as it seems evident that
there is no better solution. This then can result in a gausian that is
very thin and a really bad fit (cost e.g about 1E4).

If I help the optimizer (e.g. by adjusting the initial guess of sigma)
it finds a much better solution (cost about 1E-9).

So what I would need to tell the Optimizer (not sure if this is possible
at all!) that not the *whole* solution is bad, but only the choice of
*one* variable so it could use larger increments for the other variables.


If you want to restrict the range of, say, the mean:

public class MyFunc implements ParametricUnivariateFunction {
 private final Sigmoid meanTransform;

 public MyFunc(double minMean, double maxMean) {
 meanTransform = new Sigmoid(minMean, maxMean);
 }

 public double value(double x, double ... param) {
  final double mu = meanTransform.value(param[1]); // param[1]
is the mean.
  final double diff = x - mu;
  final double norm = param[0]; // param[0] is the height.
  final double s = param[2]; // param[2] is the standard deviation.
  final double i2s2 = 1 / (2 * s * s);
  return Gaussian.value(diff, norm, i2s2);
 }
}

// ...
final MyFunc f = new MyFunc(min, max);
final double[] best = fitter.fit(f); // Perform fit.
final double bestMean = new Logit(min, max).value(best[1]);

HTH,
Gilles



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2021-06-08 Thread Randy Motluck
 Hi Gilles,
I may be wrong in understanding your issue,  but in general, I believe you 
should scale your features.
https://towardsdatascience.com/gradient-descent-the-learning-rate-and-the-importance-of-feature-scaling-6c0b416596e1

https://societyofai.medium.com/simplest-way-for-feature-scaling-in-gradient-descent-ae0aaa383039

It becomes important when one feature is of greatly different scale than 
another.  Say for example X is 0-100.0 while Y is 0-10 or something.
Hope this finds you well and best of luck,
Randy Motluck

On Tuesday, June 8, 2021, 08:24:54 AM CDT, Gilles Sadowski 
 wrote:  
 
 Hello.

Le mar. 8 juin 2021 à 08:14, Christoph Läubrich
 a écrit :
>
> Hi Gilles,
>
> I have used the the INFINITY approach for a while now and it works quite
> good. I just recently found a problem where I got very bad fits after a
> handful of iterations using the LevenbergMarquardtOptimizer.
>
> The problem arises whenever there is a relative small range of valid
> values for *one* parameter.
>
> Too keep up with the Gausian example assume that the mean is only valid
> in a small window, but norm and sigma are completely free.
>
> My guess is, if in the data there are outlier that indicates a strong
> maximum outside this range the optimizer try to go in that 'direction'
> because I reject this solution it 'gives up' as it seems evident that
> there is no better solution. This then can result in a gausian that is
> very thin and a really bad fit (cost e.g about 1E4).
>
> If I help the optimizer (e.g. by adjusting the initial guess of sigma)
> it finds a much better solution (cost about 1E-9).
>
> So what I would need to tell the Optimizer (not sure if this is possible
> at all!) that not the *whole* solution is bad, but only the choice of
> *one* variable so it could use larger increments for the other variables.

If you want to restrict the range of, say, the mean:

public class MyFunc implements ParametricUnivariateFunction {
    private final Sigmoid meanTransform;

    public MyFunc(double minMean, double maxMean) {
        meanTransform = new Sigmoid(minMean, maxMean);
    }

    public double value(double x, double ... param) {
        final double mu = meanTransform.value(param[1]); // param[1]
is the mean.
        final double diff = x - mu;
        final double norm = param[0]; // param[0] is the height.
        final double s = param[2]; // param[2] is the standard deviation.
        final double i2s2 = 1 / (2 * s * s);
        return Gaussian.value(diff, norm, i2s2);
    }
}

// ...
final MyFunc f = new MyFunc(min, max);
final double[] best = fitter.fit(f); // Perform fit.
final double bestMean = new Logit(min, max).value(best[1]);

HTH,
Gilles

 [...]

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

  

Re: [math] example for constrain parameters for Least squares

2021-06-08 Thread Gilles Sadowski
Hello.

Le mar. 8 juin 2021 à 08:14, Christoph Läubrich
 a écrit :
>
> Hi Gilles,
>
> I have used the the INFINITY approach for a while now and it works quite
> good. I just recently found a problem where I got very bad fits after a
> handful of iterations using the LevenbergMarquardtOptimizer.
>
> The problem arises whenever there is a relative small range of valid
> values for *one* parameter.
>
> Too keep up with the Gausian example assume that the mean is only valid
> in a small window, but norm and sigma are completely free.
>
> My guess is, if in the data there are outlier that indicates a strong
> maximum outside this range the optimizer try to go in that 'direction'
> because I reject this solution it 'gives up' as it seems evident that
> there is no better solution. This then can result in a gausian that is
> very thin and a really bad fit (cost e.g about 1E4).
>
> If I help the optimizer (e.g. by adjusting the initial guess of sigma)
> it finds a much better solution (cost about 1E-9).
>
> So what I would need to tell the Optimizer (not sure if this is possible
> at all!) that not the *whole* solution is bad, but only the choice of
> *one* variable so it could use larger increments for the other variables.

If you want to restrict the range of, say, the mean:

public class MyFunc implements ParametricUnivariateFunction {
private final Sigmoid meanTransform;

public MyFunc(double minMean, double maxMean) {
meanTransform = new Sigmoid(minMean, maxMean);
}

public double value(double x, double ... param) {
 final double mu = meanTransform.value(param[1]); // param[1]
is the mean.
 final double diff = x - mu;
 final double norm = param[0]; // param[0] is the height.
 final double s = param[2]; // param[2] is the standard deviation.
 final double i2s2 = 1 / (2 * s * s);
 return Gaussian.value(diff, norm, i2s2);
}
}

// ...
final MyFunc f = new MyFunc(min, max);
final double[] best = fitter.fit(f); // Perform fit.
final double bestMean = new Logit(min, max).value(best[1]);

HTH,
Gilles

 [...]

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2021-06-08 Thread Christoph Läubrich
id solutions to this area. The same might apply to the
norm: I know it must be between a given range and I want to restrict the
optimizer here even though there might be a solution outside of the
range that (compared of the R^2) fits better, e.g. a gausian fit well
inside the -1..1.

I hope it is a little bit clearer.


I'm not sure.  The picture shows a function that is not a Gaussian.
Do you mean that you want to fit only *part* of the data with a
function that would not fit well *all* the data?

Regards,
Gilles




[1]
https://ascelibrary.org/cms/asset/6ca2b016-1a4f-4eed-80da-71219777cac1/1.jpg

Am 11.08.20 um 00:42 schrieb Gilles Sadowski:

Hello.

Le lun. 10 août 2020 à 17:09, Christoph Läubrich
 a écrit :


The userguide [1] mentions that it is currently not directly possible to
contrain parameters directly but suggest one can use the
ParameterValidator, is there any example code for both mentioned
alternatives?

For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
archive that the mean is within a closed bound e.g from 5 to 6 where my
datapoints ranges from 0..90, how would this be archived?


Could you set up a unit test as a practical example of what
you need to achieve?


I'm especially interested because the FUNCTION inside
GaussianCurveFitter seems to reject invalid values (e.g. negative
valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
either approach described in the user-docs.


What I don't quite get is why you need to force the mean within a
certain range; if the data match a Gaussian with a mean within that
range, I would assume that the fitter will find the correct value...
Sorry if I missed something.  Hopefully the example will clarify.

Best,
Gilles




[1]
https://commons.apache.org/proper/commons-math/userguide/leastsquares.html


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] AffineTransformMatrix2D

2021-03-22 Thread Matt Juntunen
Hello,

> its a bit bad to code against internal representations.

I would not consider the utility method above as a use of an internal 
representation. The toArray() method is a part of the public API and was 
created for use cases such as this.

> What do you think about two methods, transformX and transformY that take a 
> single double and return the transformed value?

That's an interesting idea. Create a new JIRA issue for it and we can go from 
there.

> I also noticed that there is no dedicated "shear" method, if I open a PR 
> could it be in-cooperated?

You bet. That is definitely something lacking in the API. Same as above, create 
a JIRA issue for it and we can talk about it there.

Note that if you plan on submitting PRs, make sure you've gone through the 
documentation in the CONTRIBUTING.md file in the repo. Specifically, you'll 
need a signed Contributor License Agreement on file with the ASF.

Regards,
Matt



From: Christoph Läubrich 
Sent: Monday, March 22, 2021 3:24 AM
To: user@commons.apache.org 
Subject: Re: [math] AffineTransformMatrix2D

Hi Matt,

thanks for the feedback, I have commented on the bug.

Regarding the "direct" method you are most probably right. I have arrays
that are easily can extend 10k or even 100k points that means in extreme
cases 200k Objects created and instantly destroyed as well as the
corresponding method calls. Even if this is not noticeable in some
scenarios it adds an unnecessary penalty.

I have already thought about the util method (and actually using it
currently) but its a bit bad to code against internal representations.
In the end of course I do not need to use the Affine transform at all
and can work on transform-matrix itself but thats not really the goal :-)

What do you think about two methods, transformX and transformY that take
a single double and return the transformed value?

public double transformX(final double x, double y) {
 return LinearCombination.value(m00, x, m01, y) + m02;
}

public double transformY(final double x, double y) {
 return LinearCombination.value(m10, x, m11, y) + m12;
}

I also noticed that there is no dedicated "shear" method, if I open a PR
could it be in-cooperated?


Am 21.03.21 um 19:07 schrieb Matt Juntunen:
> Hello,
>
> It's entirely possible that the OSGi headers are incorrect. I've created a 
> new issue (GEOMETRY-116 [1]) for it. We can continue that part of this 
> discussion there.
>
> The "internal" package in commons-geometry-core is intended to be internal 
> from the standpoint of the library. Classes under this package (and 
> "internal" packages in other modules) are not considered part of the public 
> API and are not guaranteed to be binary compatible with previous releases. 
> From a practical standpoint, however, these packages do need to be exported 
> and available for use by the other modules in the library.
>
> In regard to the new method you mentioned, I am hesitant to add that to the 
> API. The main reason is that there are a large number of possible ways to 
> represent 2D vectors as arrays. For example, the xy components could be in 
> two parallel arrays (as in your example), a single array with interleaved xy 
> components (eg, [x1,y1,x2,y2,...]), a multidimensional array (eg, 
> [[x1,y1],[x2,y2]...]), etc. Adding this method could open up a can of worms 
> as to which formats are accepted by the API. It would keep the API cleaner by 
> leaving this functionality to consuming applications. You could, for example, 
> use AffineTransformMatrix2D as-is for matrix creation and manipulation and 
> create a utility method in your application that performs the required 
> transformations using the target format.
>
> public static void applyTransform(AffineTransformMatrix2D m, double[] x, 
> double[] y) {
>  // input checking, etc
>  double[] mArr = m.toArray();
>  for (int i = 0; i < x.length; ++i {
>  x[i] = LinearCombination.value(mArr[0], x[i], mArr[1], y[i]) + 
> mArr[2];
>  y[i] = LinearCombination.value(mArr[3], x[i], mArr[4], y[i]) + 
> mArr[5];
>  }
> }
>
> I would also be interested in seeing if there is an actual performance 
> improvement when skipping the Vector2D instantiations. In my experience, 
> optimizations such as this sometimes don't really make a difference.
>
> Regards,
> Matt J
>
> [1] https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-116
> 
> From: Christoph Läubrich 
> Sent: Sunday, March 21, 2021 8:40 AM
> To: user@commons.apache.org 
> Subject: Re: [math] 2D Line getOffset and natural orientation
>
> Hi Matt,
>
> just some feedback on the AffineTransformMatrix2D in general I think it
> would be good to have methods th

Re: [math] AffineTransformMatrix2D

2021-03-22 Thread Christoph Läubrich

Hi Matt,

thanks for the feedback, I have commented on the bug.

Regarding the "direct" method you are most probably right. I have arrays 
that are easily can extend 10k or even 100k points that means in extreme 
cases 200k Objects created and instantly destroyed as well as the 
corresponding method calls. Even if this is not noticeable in some 
scenarios it adds an unnecessary penalty.


I have already thought about the util method (and actually using it 
currently) but its a bit bad to code against internal representations. 
In the end of course I do not need to use the Affine transform at all 
and can work on transform-matrix itself but thats not really the goal :-)


What do you think about two methods, transformX and transformY that take 
a single double and return the transformed value?


public double transformX(final double x, double y) {
return LinearCombination.value(m00, x, m01, y) + m02;
}

public double transformY(final double x, double y) {
return LinearCombination.value(m10, x, m11, y) + m12;
}

I also noticed that there is no dedicated "shear" method, if I open a PR 
could it be in-cooperated?



Am 21.03.21 um 19:07 schrieb Matt Juntunen:

Hello,

It's entirely possible that the OSGi headers are incorrect. I've created a new 
issue (GEOMETRY-116 [1]) for it. We can continue that part of this discussion 
there.

The "internal" package in commons-geometry-core is intended to be internal from the 
standpoint of the library. Classes under this package (and "internal" packages in other 
modules) are not considered part of the public API and are not guaranteed to be binary compatible 
with previous releases. From a practical standpoint, however, these packages do need to be exported 
and available for use by the other modules in the library.

In regard to the new method you mentioned, I am hesitant to add that to the 
API. The main reason is that there are a large number of possible ways to 
represent 2D vectors as arrays. For example, the xy components could be in two 
parallel arrays (as in your example), a single array with interleaved xy 
components (eg, [x1,y1,x2,y2,...]), a multidimensional array (eg, 
[[x1,y1],[x2,y2]...]), etc. Adding this method could open up a can of worms as 
to which formats are accepted by the API. It would keep the API cleaner by 
leaving this functionality to consuming applications. You could, for example, 
use AffineTransformMatrix2D as-is for matrix creation and manipulation and 
create a utility method in your application that performs the required 
transformations using the target format.

public static void applyTransform(AffineTransformMatrix2D m, double[] x, 
double[] y) {
 // input checking, etc
 double[] mArr = m.toArray();
 for (int i = 0; i < x.length; ++i {
 x[i] = LinearCombination.value(mArr[0], x[i], mArr[1], y[i]) + mArr[2];
 y[i] = LinearCombination.value(mArr[3], x[i], mArr[4], y[i]) + mArr[5];
 }
}

I would also be interested in seeing if there is an actual performance 
improvement when skipping the Vector2D instantiations. In my experience, 
optimizations such as this sometimes don't really make a difference.

Regards,
Matt J

[1] https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-116

From: Christoph Läubrich 
Sent: Sunday, March 21, 2021 8:40 AM
To: user@commons.apache.org 
Subject: Re: [math] 2D Line getOffset and natural orientation

Hi Matt,

just some feedback on the AffineTransformMatrix2D in general I think it
would be good to have methods that accept a plain array. for example I
have an array of x and y values and like to transform them.

Currently I need to first construct a Vector of each x/y pair, then
apply the transform (what create another Vector), and copy the data back
to the array.

so a method apply [double[] x, double[] y) that simply performs the
transform in-place would prevent a lot of instantiation overhead.


Am 20.03.21 um 13:25 schrieb Matt Juntunen:

It's available on maven central [1]. You can find the code on the Apache git 
repo [2] or on Github [3]. The user guide [4] gives an overview of the library 
along with code examples so you can get a feel for how it works. Don't hesitate 
to ask if you have any questions.

-Matt


[1] 
https://mvnrepository.com/artifact/org.apache.commons/commons-geometry-euclidean
[2] https://gitbox.apache.org/repos/asf?p=commons-geometry.git
[3] https://github.com/apache/commons-geometry
[4] https://commons.apache.org/proper/commons-geometry/userguide/index.html



From: Patrik Karlström 
Sent: Saturday, March 20, 2021 4:30 AM
To: Commons Users List 
Subject: Re: [math] 2D Line getOffset and natural orientation

Thanks for the clarification, I would be happy to try out beta1 of
commons-geometry, is there a staging repo for it?

/Patrik

Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen 
:



Hello.

I agree that th

Re: [math] 2D Line getOffset and natural orientation

2021-03-21 Thread Matt Juntunen
Hello,

It's entirely possible that the OSGi headers are incorrect. I've created a new 
issue (GEOMETRY-116 [1]) for it. We can continue that part of this discussion 
there.

The "internal" package in commons-geometry-core is intended to be internal from 
the standpoint of the library. Classes under this package (and "internal" 
packages in other modules) are not considered part of the public API and are 
not guaranteed to be binary compatible with previous releases. From a practical 
standpoint, however, these packages do need to be exported and available for 
use by the other modules in the library.

In regard to the new method you mentioned, I am hesitant to add that to the 
API. The main reason is that there are a large number of possible ways to 
represent 2D vectors as arrays. For example, the xy components could be in two 
parallel arrays (as in your example), a single array with interleaved xy 
components (eg, [x1,y1,x2,y2,...]), a multidimensional array (eg, 
[[x1,y1],[x2,y2]...]), etc. Adding this method could open up a can of worms as 
to which formats are accepted by the API. It would keep the API cleaner by 
leaving this functionality to consuming applications. You could, for example, 
use AffineTransformMatrix2D as-is for matrix creation and manipulation and 
create a utility method in your application that performs the required 
transformations using the target format.

public static void applyTransform(AffineTransformMatrix2D m, double[] x, 
double[] y) {
// input checking, etc
double[] mArr = m.toArray();
for (int i = 0; i < x.length; ++i {
x[i] = LinearCombination.value(mArr[0], x[i], mArr[1], y[i]) + mArr[2];
y[i] = LinearCombination.value(mArr[3], x[i], mArr[4], y[i]) + mArr[5];
}
}

I would also be interested in seeing if there is an actual performance 
improvement when skipping the Vector2D instantiations. In my experience, 
optimizations such as this sometimes don't really make a difference.

Regards,
Matt J

[1] https://issues.apache.org/jira/projects/GEOMETRY/issues/GEOMETRY-116

From: Christoph Läubrich 
Sent: Sunday, March 21, 2021 8:40 AM
To: user@commons.apache.org 
Subject: Re: [math] 2D Line getOffset and natural orientation

Hi Matt,

just some feedback on the AffineTransformMatrix2D in general I think it
would be good to have methods that accept a plain array. for example I
have an array of x and y values and like to transform them.

Currently I need to first construct a Vector of each x/y pair, then
apply the transform (what create another Vector), and copy the data back
to the array.

so a method apply [double[] x, double[] y) that simply performs the
transform in-place would prevent a lot of instantiation overhead.


Am 20.03.21 um 13:25 schrieb Matt Juntunen:
> It's available on maven central [1]. You can find the code on the Apache git 
> repo [2] or on Github [3]. The user guide [4] gives an overview of the 
> library along with code examples so you can get a feel for how it works. 
> Don't hesitate to ask if you have any questions.
>
> -Matt
>
>
> [1] 
> https://mvnrepository.com/artifact/org.apache.commons/commons-geometry-euclidean
> [2] https://gitbox.apache.org/repos/asf?p=commons-geometry.git
> [3] https://github.com/apache/commons-geometry
> [4] https://commons.apache.org/proper/commons-geometry/userguide/index.html
>
>
> 
> From: Patrik Karlström 
> Sent: Saturday, March 20, 2021 4:30 AM
> To: Commons Users List 
> Subject: Re: [math] 2D Line getOffset and natural orientation
>
> Thanks for the clarification, I would be happy to try out beta1 of
> commons-geometry, is there a staging repo for it?
>
> /Patrik
>
> Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen > :
>
>> Hello.
>>
>> I agree that the docs are not really clear on the "natural orientation"
>> part there. Basically, the possible results are as follows:
>>
>>*   positive - The argument lies on the right side of the calling line,
>> with the "right side" defined as the side on the right when looking along
>> the calling line in its defined direction. (This is what I believe is meant
>> by "natural orientation".)
>>*   negative - The argument lies on the left side of the calling line.
>>*   zero - The lines have points in common, meaning they intersect or
>> are coincident.
>>
>> On a side note, if you're writing geometric code, I would suggest trying
>> out the new(-ish) commons-geometry library [1]. It is a rewrite and
>> extension of the commons-math geometry code and, IMHO, the API is more
>> user-friendly. (Disclaimer: I wrote the majority of it so I am completely
>> biased 
>>
>> Regards,
>> Matt J
>>
>> [1] http

Re: [math] 2D Line getOffset and natural orientation

2021-03-21 Thread Christoph Läubrich

Hi Matt,

just some feedback on the AffineTransformMatrix2D in general I think it 
would be good to have methods that accept a plain array. for example I 
have an array of x and y values and like to transform them.


Currently I need to first construct a Vector of each x/y pair, then 
apply the transform (what create another Vector), and copy the data back 
to the array.


so a method apply [double[] x, double[] y) that simply performs the 
transform in-place would prevent a lot of instantiation overhead.



Am 20.03.21 um 13:25 schrieb Matt Juntunen:

It's available on maven central [1]. You can find the code on the Apache git 
repo [2] or on Github [3]. The user guide [4] gives an overview of the library 
along with code examples so you can get a feel for how it works. Don't hesitate 
to ask if you have any questions.

-Matt


[1] 
https://mvnrepository.com/artifact/org.apache.commons/commons-geometry-euclidean
[2] https://gitbox.apache.org/repos/asf?p=commons-geometry.git
[3] https://github.com/apache/commons-geometry
[4] https://commons.apache.org/proper/commons-geometry/userguide/index.html



From: Patrik Karlström 
Sent: Saturday, March 20, 2021 4:30 AM
To: Commons Users List 
Subject: Re: [math] 2D Line getOffset and natural orientation

Thanks for the clarification, I would be happy to try out beta1 of
commons-geometry, is there a staging repo for it?

/Patrik

Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen 
:



Hello.

I agree that the docs are not really clear on the "natural orientation"
part there. Basically, the possible results are as follows:

   *   positive - The argument lies on the right side of the calling line,
with the "right side" defined as the side on the right when looking along
the calling line in its defined direction. (This is what I believe is meant
by "natural orientation".)
   *   negative - The argument lies on the left side of the calling line.
   *   zero - The lines have points in common, meaning they intersect or
are coincident.

On a side note, if you're writing geometric code, I would suggest trying
out the new(-ish) commons-geometry library [1]. It is a rewrite and
extension of the commons-math geometry code and, IMHO, the API is more
user-friendly. (Disclaimer: I wrote the majority of it so I am completely
biased 

Regards,
Matt J

[1] https://commons.apache.org/proper/commons-geometry/
[https://avatars.githubusercontent.com/u/47359?s=400=4]<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



apache/commons-geometry<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



Apache Commons Geometry. Contribute to apache/commons-geometry development
by creating an account on GitHub.
github.com



From: Patrik Karlström 
Sent: Thursday, March 18, 2021 3:42 AM
To: user@commons.apache.org 
Subject: Re: [math] 2D Line getOffset and natural orientation

Oh, scratch that!

I had three parallel lines and picked the wrong pair (and the correct
values came from another calculation).

Still interested in "natural orientation" though.

Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :


Sometimes (50/50?) I'm getting an unexpected signum from
org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
line).
The absolute value itself is correct.

 From the javadoc:
"The offset is 0 if both lines are the same, it is positive if the
line is on the right side of the instance and negative if it is on the
left side, according to its natural orientation."

I suspect my problem relates to "according to its natural orientation."
What is a natural orientation and what can I do to adapt to it, when
to reverse my lines? If that's the case.



https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] 2D Line getOffset and natural orientation

2021-03-20 Thread Christoph Läubrich
Taking a deeper look the whole package 
org.apache.commons.geometry.core.internal seems to be required elsewhere 
and should be public+exported. Is there any rationale to make this 
"internal"? Internal packages should really only be used in the module 
itself.


If its proven to be usefull in other modules too it should be proper 
exported. Otherwise the module is not usable in an OSGi framework.


Am 20.03.21 um 13:25 schrieb Matt Juntunen:

It's available on maven central [1]. You can find the code on the Apache git 
repo [2] or on Github [3]. The user guide [4] gives an overview of the library 
along with code examples so you can get a feel for how it works. Don't hesitate 
to ask if you have any questions.

-Matt


[1] 
https://mvnrepository.com/artifact/org.apache.commons/commons-geometry-euclidean
[2] https://gitbox.apache.org/repos/asf?p=commons-geometry.git
[3] https://github.com/apache/commons-geometry
[4] https://commons.apache.org/proper/commons-geometry/userguide/index.html



From: Patrik Karlström 
Sent: Saturday, March 20, 2021 4:30 AM
To: Commons Users List 
Subject: Re: [math] 2D Line getOffset and natural orientation

Thanks for the clarification, I would be happy to try out beta1 of
commons-geometry, is there a staging repo for it?

/Patrik

Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen 
:



Hello.

I agree that the docs are not really clear on the "natural orientation"
part there. Basically, the possible results are as follows:

   *   positive - The argument lies on the right side of the calling line,
with the "right side" defined as the side on the right when looking along
the calling line in its defined direction. (This is what I believe is meant
by "natural orientation".)
   *   negative - The argument lies on the left side of the calling line.
   *   zero - The lines have points in common, meaning they intersect or
are coincident.

On a side note, if you're writing geometric code, I would suggest trying
out the new(-ish) commons-geometry library [1]. It is a rewrite and
extension of the commons-math geometry code and, IMHO, the API is more
user-friendly. (Disclaimer: I wrote the majority of it so I am completely
biased 

Regards,
Matt J

[1] https://commons.apache.org/proper/commons-geometry/
[https://avatars.githubusercontent.com/u/47359?s=400=4]<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



apache/commons-geometry<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



Apache Commons Geometry. Contribute to apache/commons-geometry development
by creating an account on GitHub.
github.com



From: Patrik Karlström 
Sent: Thursday, March 18, 2021 3:42 AM
To: user@commons.apache.org 
Subject: Re: [math] 2D Line getOffset and natural orientation

Oh, scratch that!

I had three parallel lines and picked the wrong pair (and the correct
values came from another calculation).

Still interested in "natural orientation" though.

Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :


Sometimes (50/50?) I'm getting an unexpected signum from
org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
line).
The absolute value itself is correct.

 From the javadoc:
"The offset is 0 if both lines are the same, it is positive if the
line is on the right side of the instance and negative if it is on the
left side, according to its natural orientation."

I suspect my problem relates to "according to its natural orientation."
What is a natural orientation and what can I do to adapt to it, when
to reverse my lines? If that's the case.



https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] 2D Line getOffset and natural orientation

2021-03-20 Thread Christoph Läubrich

Another thing I noted:

DoubleFunction2N is used but resides in the 
org.apache.commons.geometry.core.internal package and thus is also not 
exported/useable in an OSGi environment this would give CNF exceptions 
if actually run inside one.


Am 20.03.21 um 13:25 schrieb Matt Juntunen:

It's available on maven central [1]. You can find the code on the Apache git 
repo [2] or on Github [3]. The user guide [4] gives an overview of the library 
along with code examples so you can get a feel for how it works. Don't hesitate 
to ask if you have any questions.

-Matt


[1] 
https://mvnrepository.com/artifact/org.apache.commons/commons-geometry-euclidean
[2] https://gitbox.apache.org/repos/asf?p=commons-geometry.git
[3] https://github.com/apache/commons-geometry
[4] https://commons.apache.org/proper/commons-geometry/userguide/index.html



From: Patrik Karlström 
Sent: Saturday, March 20, 2021 4:30 AM
To: Commons Users List 
Subject: Re: [math] 2D Line getOffset and natural orientation

Thanks for the clarification, I would be happy to try out beta1 of
commons-geometry, is there a staging repo for it?

/Patrik

Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen 
:



Hello.

I agree that the docs are not really clear on the "natural orientation"
part there. Basically, the possible results are as follows:

   *   positive - The argument lies on the right side of the calling line,
with the "right side" defined as the side on the right when looking along
the calling line in its defined direction. (This is what I believe is meant
by "natural orientation".)
   *   negative - The argument lies on the left side of the calling line.
   *   zero - The lines have points in common, meaning they intersect or
are coincident.

On a side note, if you're writing geometric code, I would suggest trying
out the new(-ish) commons-geometry library [1]. It is a rewrite and
extension of the commons-math geometry code and, IMHO, the API is more
user-friendly. (Disclaimer: I wrote the majority of it so I am completely
biased 

Regards,
Matt J

[1] https://commons.apache.org/proper/commons-geometry/
[https://avatars.githubusercontent.com/u/47359?s=400=4]<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



apache/commons-geometry<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



Apache Commons Geometry. Contribute to apache/commons-geometry development
by creating an account on GitHub.
github.com



From: Patrik Karlström 
Sent: Thursday, March 18, 2021 3:42 AM
To: user@commons.apache.org 
Subject: Re: [math] 2D Line getOffset and natural orientation

Oh, scratch that!

I had three parallel lines and picked the wrong pair (and the correct
values came from another calculation).

Still interested in "natural orientation" though.

Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :


Sometimes (50/50?) I'm getting an unexpected signum from
org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
line).
The absolute value itself is correct.

 From the javadoc:
"The offset is 0 if both lines are the same, it is positive if the
line is on the right side of the instance and negative if it is on the
left side, according to its natural orientation."

I suspect my problem relates to "according to its natural orientation."
What is a natural orientation and what can I do to adapt to it, when
to reverse my lines? If that's the case.



https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] 2D Line getOffset and natural orientation

2021-03-20 Thread Christoph Läubrich

Hi Matt,

I try to use the new package in an OSGi application but only the 
org.apache.commons.geometry.euclidean package is exported. Is thsi 
intentional?


I'd like to use AffineTransformMatrix2D from the 
org.apache.commons.geometry.euclidean.twod package for example but don't 
understand how one is created if the package is private...


Am 20.03.21 um 13:25 schrieb Matt Juntunen:

It's available on maven central [1]. You can find the code on the Apache git 
repo [2] or on Github [3]. The user guide [4] gives an overview of the library 
along with code examples so you can get a feel for how it works. Don't hesitate 
to ask if you have any questions.

-Matt


[1] 
https://mvnrepository.com/artifact/org.apache.commons/commons-geometry-euclidean
[2] https://gitbox.apache.org/repos/asf?p=commons-geometry.git
[3] https://github.com/apache/commons-geometry
[4] https://commons.apache.org/proper/commons-geometry/userguide/index.html



From: Patrik Karlström 
Sent: Saturday, March 20, 2021 4:30 AM
To: Commons Users List 
Subject: Re: [math] 2D Line getOffset and natural orientation

Thanks for the clarification, I would be happy to try out beta1 of
commons-geometry, is there a staging repo for it?

/Patrik

Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen 
:



Hello.

I agree that the docs are not really clear on the "natural orientation"
part there. Basically, the possible results are as follows:

   *   positive - The argument lies on the right side of the calling line,
with the "right side" defined as the side on the right when looking along
the calling line in its defined direction. (This is what I believe is meant
by "natural orientation".)
   *   negative - The argument lies on the left side of the calling line.
   *   zero - The lines have points in common, meaning they intersect or
are coincident.

On a side note, if you're writing geometric code, I would suggest trying
out the new(-ish) commons-geometry library [1]. It is a rewrite and
extension of the commons-math geometry code and, IMHO, the API is more
user-friendly. (Disclaimer: I wrote the majority of it so I am completely
biased 

Regards,
Matt J

[1] https://commons.apache.org/proper/commons-geometry/
[https://avatars.githubusercontent.com/u/47359?s=400=4]<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



apache/commons-geometry<
https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370



Apache Commons Geometry. Contribute to apache/commons-geometry development
by creating an account on GitHub.
github.com



From: Patrik Karlström 
Sent: Thursday, March 18, 2021 3:42 AM
To: user@commons.apache.org 
Subject: Re: [math] 2D Line getOffset and natural orientation

Oh, scratch that!

I had three parallel lines and picked the wrong pair (and the correct
values came from another calculation).

Still interested in "natural orientation" though.

Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :


Sometimes (50/50?) I'm getting an unexpected signum from
org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
line).
The absolute value itself is correct.

 From the javadoc:
"The offset is 0 if both lines are the same, it is positive if the
line is on the right side of the instance and negative if it is on the
left side, according to its natural orientation."

I suspect my problem relates to "according to its natural orientation."
What is a natural orientation and what can I do to adapt to it, when
to reverse my lines? If that's the case.



https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] 2D Line getOffset and natural orientation

2021-03-20 Thread Matt Juntunen
It's available on maven central [1]. You can find the code on the Apache git 
repo [2] or on Github [3]. The user guide [4] gives an overview of the library 
along with code examples so you can get a feel for how it works. Don't hesitate 
to ask if you have any questions.

-Matt


[1] 
https://mvnrepository.com/artifact/org.apache.commons/commons-geometry-euclidean
[2] https://gitbox.apache.org/repos/asf?p=commons-geometry.git
[3] https://github.com/apache/commons-geometry
[4] https://commons.apache.org/proper/commons-geometry/userguide/index.html



From: Patrik Karlström 
Sent: Saturday, March 20, 2021 4:30 AM
To: Commons Users List 
Subject: Re: [math] 2D Line getOffset and natural orientation

Thanks for the clarification, I would be happy to try out beta1 of
commons-geometry, is there a staging repo for it?

/Patrik

Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen :

> Hello.
>
> I agree that the docs are not really clear on the "natural orientation"
> part there. Basically, the possible results are as follows:
>
>   *   positive - The argument lies on the right side of the calling line,
> with the "right side" defined as the side on the right when looking along
> the calling line in its defined direction. (This is what I believe is meant
> by "natural orientation".)
>   *   negative - The argument lies on the left side of the calling line.
>   *   zero - The lines have points in common, meaning they intersect or
> are coincident.
>
> On a side note, if you're writing geometric code, I would suggest trying
> out the new(-ish) commons-geometry library [1]. It is a rewrite and
> extension of the commons-math geometry code and, IMHO, the API is more
> user-friendly. (Disclaimer: I wrote the majority of it so I am completely
> biased 
>
> Regards,
> Matt J
>
> [1] https://commons.apache.org/proper/commons-geometry/
> [https://avatars.githubusercontent.com/u/47359?s=400=4]<
> https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370
> >
> apache/commons-geometry<
> https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370
> >
> Apache Commons Geometry. Contribute to apache/commons-geometry development
> by creating an account on GitHub.
> github.com
>
>
> 
> From: Patrik Karlström 
> Sent: Thursday, March 18, 2021 3:42 AM
> To: user@commons.apache.org 
> Subject: Re: [math] 2D Line getOffset and natural orientation
>
> Oh, scratch that!
>
> I had three parallel lines and picked the wrong pair (and the correct
> values came from another calculation).
>
> Still interested in "natural orientation" though.
>
> Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :
> >
> > Sometimes (50/50?) I'm getting an unexpected signum from
> > org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
> > line).
> > The absolute value itself is correct.
> >
> > From the javadoc:
> > "The offset is 0 if both lines are the same, it is positive if the
> > line is on the right side of the instance and negative if it is on the
> > left side, according to its natural orientation."
> >
> > I suspect my problem relates to "according to its natural orientation."
> > What is a natural orientation and what can I do to adapt to it, when
> > to reverse my lines? If that's the case.
> >
> >
> https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>


Re: [math] 2D Line getOffset and natural orientation

2021-03-20 Thread Patrik Karlström
Thanks for the clarification, I would be happy to try out beta1 of
commons-geometry, is there a staging repo for it?

/Patrik

Den fre 19 mars 2021 kl 00:29 skrev Matt Juntunen :

> Hello.
>
> I agree that the docs are not really clear on the "natural orientation"
> part there. Basically, the possible results are as follows:
>
>   *   positive - The argument lies on the right side of the calling line,
> with the "right side" defined as the side on the right when looking along
> the calling line in its defined direction. (This is what I believe is meant
> by "natural orientation".)
>   *   negative - The argument lies on the left side of the calling line.
>   *   zero - The lines have points in common, meaning they intersect or
> are coincident.
>
> On a side note, if you're writing geometric code, I would suggest trying
> out the new(-ish) commons-geometry library [1]. It is a rewrite and
> extension of the commons-math geometry code and, IMHO, the API is more
> user-friendly. (Disclaimer: I wrote the majority of it so I am completely
> biased 
>
> Regards,
> Matt J
>
> [1] https://commons.apache.org/proper/commons-geometry/
> [https://avatars.githubusercontent.com/u/47359?s=400=4]<
> https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370
> >
> apache/commons-geometry<
> https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370
> >
> Apache Commons Geometry. Contribute to apache/commons-geometry development
> by creating an account on GitHub.
> github.com
>
>
> 
> From: Patrik Karlström 
> Sent: Thursday, March 18, 2021 3:42 AM
> To: user@commons.apache.org 
> Subject: Re: [math] 2D Line getOffset and natural orientation
>
> Oh, scratch that!
>
> I had three parallel lines and picked the wrong pair (and the correct
> values came from another calculation).
>
> Still interested in "natural orientation" though.
>
> Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :
> >
> > Sometimes (50/50?) I'm getting an unexpected signum from
> > org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
> > line).
> > The absolute value itself is correct.
> >
> > From the javadoc:
> > "The offset is 0 if both lines are the same, it is positive if the
> > line is on the right side of the instance and negative if it is on the
> > left side, according to its natural orientation."
> >
> > I suspect my problem relates to "according to its natural orientation."
> > What is a natural orientation and what can I do to adapt to it, when
> > to reverse my lines? If that's the case.
> >
> >
> https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>


Re: [math] 2D Line getOffset and natural orientation

2021-03-18 Thread Matt Juntunen
Hello.

I agree that the docs are not really clear on the "natural orientation" part 
there. Basically, the possible results are as follows:

  *   positive - The argument lies on the right side of the calling line, with 
the "right side" defined as the side on the right when looking along the 
calling line in its defined direction. (This is what I believe is meant by 
"natural orientation".)
  *   negative - The argument lies on the left side of the calling line.
  *   zero - The lines have points in common, meaning they intersect or are 
coincident.

On a side note, if you're writing geometric code, I would suggest trying out 
the new(-ish) commons-geometry library [1]. It is a rewrite and extension of 
the commons-math geometry code and, IMHO, the API is more user-friendly. 
(Disclaimer: I wrote the majority of it so I am completely biased 

Regards,
Matt J

[1] https://commons.apache.org/proper/commons-geometry/
[https://avatars.githubusercontent.com/u/47359?s=400=4]<https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370>
apache/commons-geometry<https://github.com/apache/commons-geometry/blob/master/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Line.java#L370>
Apache Commons Geometry. Contribute to apache/commons-geometry development by 
creating an account on GitHub.
github.com



From: Patrik Karlström 
Sent: Thursday, March 18, 2021 3:42 AM
To: user@commons.apache.org 
Subject: Re: [math] 2D Line getOffset and natural orientation

Oh, scratch that!

I had three parallel lines and picked the wrong pair (and the correct
values came from another calculation).

Still interested in "natural orientation" though.

Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :
>
> Sometimes (50/50?) I'm getting an unexpected signum from
> org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
> line).
> The absolute value itself is correct.
>
> From the javadoc:
> "The offset is 0 if both lines are the same, it is positive if the
> line is on the right side of the instance and negative if it is on the
> left side, according to its natural orientation."
>
> I suspect my problem relates to "according to its natural orientation."
> What is a natural orientation and what can I do to adapt to it, when
> to reverse my lines? If that's the case.
>
> https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] 2D Line getOffset and natural orientation

2021-03-18 Thread Patrik Karlström
Oh, scratch that!

I had three parallel lines and picked the wrong pair (and the correct
values came from another calculation).

Still interested in "natural orientation" though.

Den tors 18 mars 2021 kl 07:19 skrev Patrik Karlström :
>
> Sometimes (50/50?) I'm getting an unexpected signum from
> org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
> line).
> The absolute value itself is correct.
>
> From the javadoc:
> "The offset is 0 if both lines are the same, it is positive if the
> line is on the right side of the instance and negative if it is on the
> left side, according to its natural orientation."
>
> I suspect my problem relates to "according to its natural orientation."
> What is a natural orientation and what can I do to adapt to it, when
> to reverse my lines? If that's the case.
>
> https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] 2D Line getOffset and natural orientation

2021-03-18 Thread Patrik Karlström
Sometimes (50/50?) I'm getting an unexpected signum from
org.apache.commons.math3.geometry.euclidean.twod.Line.getOffset(Line
line).
The absolute value itself is correct.

>From the javadoc:
"The offset is 0 if both lines are the same, it is positive if the
line is on the right side of the instance and negative if it is on the
left side, according to its natural orientation."

I suspect my problem relates to "according to its natural orientation."
What is a natural orientation and what can I do to adapt to it, when
to reverse my lines? If that's the case.

https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/twod/Line.html#getOffset(org.apache.commons.math3.geometry.euclidean.twod.Line)

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] How to Convert 'RealMatrix' Object to Array

2021-02-16 Thread Oscar Bastidas
Awesome!  Thank you so much for this.

Oscar

Oscar Bastidas, Ph.D.
Postdoctoral Research Associate
University of Minnesota

On Tue, Feb 16, 2021, 5:25 AM Alex Herbert  wrote:

> The methods:
>
> double[][] getData();
> double[][] getDataRef();
>
> Provide access to the underlying 2D matrix as a copy or a direct reference.
>
> The method:
>
>double getEntry(int, int);
>
> Provides access to an element of the matrix.
>
> So you can do for example:
>
> Array2DRowRealMatrix m = ...;
>
> int cols = m.getColumnDimension();
> int rows = m.getRowDimension();
> double[][] data = m.getDataRef();
> for (int row = 0; row < rows; row++) {
>   for (int column = 0; column < cols; column++) {
> double d = m.getEntry(row, column);
> double d2 = data[row][column];
> assert d == d2;
>   }
> }
>
> If you need to visit a part of the matrix then you can use the visitor API.
> For example to sum a sub-matrix:
>
> int startRow = 2;
> int endRow = 5;
> int startColumn = 15;
> int endColumn = 20;
> double sum = m.walkInOptimizedOrder(
> new DefaultRealMatrixPreservingVisitor() {
>   double s = 0;
>   @Override
>   public void visit(int row, int column, double value) {
> s += value;
>   }
>   @Override
>   public double end() {
> return s;
>   }
> }, startRow, endRow, startColumn, endColumn);
>
> You can read about the available operations in the API here:
>
>
> https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/index.html
>
> Regards,
>
> Alex
>
>
>
> On Tue, 16 Feb 2021 at 09:28, Oscar Bastidas 
> wrote:
>
> > Hello,
> >
> > Would someone please tell me how I can go about converting a 'RealMatrix'
> > object to an array?  When I just print out the RealMatrix object I get
> > something that looks like:
> >
> >
> > Array2DRowRealMatrix{{123},{456},{789}}
> >
> >
> > I would like to be able to selectively cycle through each number
> > individually.
> >
> > Thanks.
> >
> > Oscar
> >
> > Oscar Bastidas, Ph.D.
> > Postdoctoral Research Associate
> > University of Minnesota
> >
>


Re: [math] How to Convert 'RealMatrix' Object to Array

2021-02-16 Thread Alex Herbert
The methods:

double[][] getData();
double[][] getDataRef();

Provide access to the underlying 2D matrix as a copy or a direct reference.

The method:

   double getEntry(int, int);

Provides access to an element of the matrix.

So you can do for example:

Array2DRowRealMatrix m = ...;

int cols = m.getColumnDimension();
int rows = m.getRowDimension();
double[][] data = m.getDataRef();
for (int row = 0; row < rows; row++) {
  for (int column = 0; column < cols; column++) {
double d = m.getEntry(row, column);
double d2 = data[row][column];
assert d == d2;
  }
}

If you need to visit a part of the matrix then you can use the visitor API.
For example to sum a sub-matrix:

int startRow = 2;
int endRow = 5;
int startColumn = 15;
int endColumn = 20;
double sum = m.walkInOptimizedOrder(
new DefaultRealMatrixPreservingVisitor() {
  double s = 0;
  @Override
  public void visit(int row, int column, double value) {
s += value;
  }
  @Override
  public double end() {
return s;
  }
}, startRow, endRow, startColumn, endColumn);

You can read about the available operations in the API here:

https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/index.html

Regards,

Alex



On Tue, 16 Feb 2021 at 09:28, Oscar Bastidas 
wrote:

> Hello,
>
> Would someone please tell me how I can go about converting a 'RealMatrix'
> object to an array?  When I just print out the RealMatrix object I get
> something that looks like:
>
>
> Array2DRowRealMatrix{{123},{456},{789}}
>
>
> I would like to be able to selectively cycle through each number
> individually.
>
> Thanks.
>
> Oscar
>
> Oscar Bastidas, Ph.D.
> Postdoctoral Research Associate
> University of Minnesota
>


[math] How to Convert 'RealMatrix' Object to Array

2021-02-16 Thread Oscar Bastidas
Hello,

Would someone please tell me how I can go about converting a 'RealMatrix'
object to an array?  When I just print out the RealMatrix object I get
something that looks like:


Array2DRowRealMatrix{{123},{456},{789}}


I would like to be able to selectively cycle through each number
individually.

Thanks.

Oscar

Oscar Bastidas, Ph.D.
Postdoctoral Research Associate
University of Minnesota


Re: [math] DerivativeStructure and erf/erfx

2020-10-02 Thread Gilles Sadowski
Hello.

[Cc'ing to the "dev" ML, as this discussion belongs there.]

Le ven. 2 oct. 2020 à 18:17, Christoph Läubrich
 a écrit :
>
> Thanks Gilles, I'm currently trying to dive into all of this a bit

Your help is very welcome.

> and
> just wondering:
>
> Will there still be new releases of commons-math3,

The general issue of what is released is in the hand of
the "community" that is willing to support the development.

My short answer is "no", a.o. things because there hasn't
been any update to the 3.x branch while a lot of work has
gone into the 4.0 ("master") branch over the last 4 years.[1]
A community could be willing to invest in back-porting
work (but it hasn't shown up yet...).
Releasing a version 3.7 would imply that we are ready to fix
bugs filed against it.  [Personally I am not.]

> or is it postponed in
> favor of math4?
>
> I'm asking this because it might be an option to add erf(x) support to
> Derivative structure in math3 first (as it is not ported yet), but of
> course this only makes sense if it will be released some day.

Why not work on the development ("master") branch?
[I recall that there have been other suggestions towards improving
the API of the "autodiff" implementation.]
There are many identified issues still to be fixed in CM, but that
shouldn't prevent us from releasing a "4.0-beta" version.

Best regards,
Gilles

[1] https://issues.apache.org/jira/projects/MATH/versions/12317577

>
> Am 19.08.20 um 23:51 schrieb Gilles Sadowski:
> > Hi.
> >
> > Le mer. 19 août 2020 à 08:38, Christoph Läubrich
> >  a écrit :
> >>
> >> Im mostly using
> >>
> >> - math3.analysis
> >
> > In view of the next major version of CM, it would be nice
> > to refactor codes in that package using the JDK
> > java.util.function
> > package, e.g. replace
> >o.a.c.m.analysis.UnivariateFunction
> > with
> >java.util.function.DoubleUnaryOperator
> > and drop redundant utilities in
> >o.a.c.m.analysis.FuncitonUtils
> >
> >> - math3.fitting
> >> - math3.linear
> >> - math3.fitting.leastsquares
> >
> > IMO, a way to modernize CM is to modularize it.
> > A first step could consist in "fitting" and "linear" becoming
> > (maven) modules.
> >
> > Regards,
> > Gilles
> >
> >> And some of the common util/exception things that drip in when using the
> >> above.
> >>
> >> Am 14.08.20 um 18:42 schrieb Gilles Sadowski:
> >>> Le jeu. 13 août 2020 à 15:46, Christoph Läubrich
> >>>  a écrit :
> >>>>
> >>>> Hi,
> >>>>
> >>>> thnaks for the information, I'm currently using the "old" commons-math3
> >>>> package, would it be possible to use erf with DerivativeStructure there?
> >>>
> >>> Technically, the issue could be that the tools in the "o.a.c.m.special"
> >>> package were not designed as those in the "o.a.c.m.analysis.function"
> >>> package.  And IIUC, "DerivativeStructure" builds on the latter.
> >>> But that doesn't mean it cannot be done (I've not used it personally).
> >>>
> >>> A lot of work has been done on the "master" branch; a 3.7 release
> >>> would mean backporting everything; not a trivial task and (if at all
> >>> possible) it would take more time (by a tall order) than anyone is
> >>> willing to devote to that library.
> >>>
> >>> IMHO, it's about time that we release v4.0 (which has been delayed
> >>> by more than 4 years, according to when the decision has been taken
> >>> to start development on that next major version).
> >>>
> >>>>> We are looking for volunteer maintainers for the math tools 
> >>>> available
> >>>>
> >>>> for commons math in general or for "commons-numbers"?
> >>>
> >>> Both and more:
> >>>
> >>> * Commons Geometry (spun off the "o.a.c.m.geometry" package)
> >>> * Commons Statistics (intended to replace the "o.a.c.m.stat" package)
> >>> * Commons RNG (replacement of the "o.a.c.m.random" package, and
> >>> pretty feature-complete as of v1.3).
> >>>
> >>>> I must confess I have only recently noticed that there is development in
> >>>> commons-math-4 and might be out of date with my knowledge a bit as an
> >>>> "old" math3 user

Re: [math] DerivativeStructure and erf/erfx

2020-10-02 Thread Christoph Läubrich
Thanks Gilles, I'm currently trying to dive into all of this a bit and 
just wondering:


Will there still be new releases of commons-math3, or is it postponed in 
favor of math4?


I'm asking this because it might be an option to add erf(x) support to 
Derivative structure in math3 first (as it is not ported yet), but of 
course this only makes sense if it will be released some day.




Am 19.08.20 um 23:51 schrieb Gilles Sadowski:

Hi.

Le mer. 19 août 2020 à 08:38, Christoph Läubrich
 a écrit :


Im mostly using

- math3.analysis


In view of the next major version of CM, it would be nice
to refactor codes in that package using the JDK
java.util.function
package, e.g. replace
   o.a.c.m.analysis.UnivariateFunction
with
   java.util.function.DoubleUnaryOperator
and drop redundant utilities in
   o.a.c.m.analysis.FuncitonUtils


- math3.fitting
- math3.linear
- math3.fitting.leastsquares


IMO, a way to modernize CM is to modularize it.
A first step could consist in "fitting" and "linear" becoming
(maven) modules.

Regards,
Gilles


And some of the common util/exception things that drip in when using the
above.

Am 14.08.20 um 18:42 schrieb Gilles Sadowski:

Le jeu. 13 août 2020 à 15:46, Christoph Läubrich
 a écrit :


Hi,

thnaks for the information, I'm currently using the "old" commons-math3
package, would it be possible to use erf with DerivativeStructure there?


Technically, the issue could be that the tools in the "o.a.c.m.special"
package were not designed as those in the "o.a.c.m.analysis.function"
package.  And IIUC, "DerivativeStructure" builds on the latter.
But that doesn't mean it cannot be done (I've not used it personally).

A lot of work has been done on the "master" branch; a 3.7 release
would mean backporting everything; not a trivial task and (if at all
possible) it would take more time (by a tall order) than anyone is
willing to devote to that library.

IMHO, it's about time that we release v4.0 (which has been delayed
by more than 4 years, according to when the decision has been taken
to start development on that next major version).


   > We are looking for volunteer maintainers for the math tools available

for commons math in general or for "commons-numbers"?


Both and more:

* Commons Geometry (spun off the "o.a.c.m.geometry" package)
* Commons Statistics (intended to replace the "o.a.c.m.stat" package)
* Commons RNG (replacement of the "o.a.c.m.random" package, and
pretty feature-complete as of v1.3).


I must confess I have only recently noticed that there is development in
commons-math-4 and might be out of date with my knowledge a bit as an
"old" math3 user :-)


Which classes/packages have you been using?

Gilles



Am 13.08.20 um 15:12 schrieb Gilles Sadowski:

Hi.

Le jeu. 13 août 2020 à 12:48, Christoph Läubrich
 a écrit :


I'd like to use the org.apache.commons.math3.special.Erf with a
DerivativeStructure but is seems there is no pre-defined function for
this (like exp()...).

So the question is, can Erf transformed inside a DerivativeStructure
somehow or does the DerivativeStructure need to support that function
directly?


Please note that "Erf" has been moved to the new "Commons Numbers"
component[1], along with the other Gamma-related functions.
The "DerivativeStructure" is one among several utilities that still need to
be ported (and refactored) there.[2]

We are looking for volunteer maintainers for the math tools available from
the Commons libraries.  The move to more focused, smaller, components
should hopefully simplify development...

Best,
Gilles

[1] 
https://gitbox.apache.org/repos/asf?p=commons-numbers.git;a=tree;f=commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma;h=cb95316a3be45ebfcf938eab63f362f59e590fca;hb=HEAD
[2] https://issues.apache.org/jira/browse/NUMBERS-69


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] DerivativeStructure and erf/erfx

2020-08-19 Thread Gilles Sadowski
Hi.

Le mer. 19 août 2020 à 08:38, Christoph Läubrich
 a écrit :
>
> Im mostly using
>
> - math3.analysis

In view of the next major version of CM, it would be nice
to refactor codes in that package using the JDK
   java.util.function
package, e.g. replace
  o.a.c.m.analysis.UnivariateFunction
with
  java.util.function.DoubleUnaryOperator
and drop redundant utilities in
  o.a.c.m.analysis.FuncitonUtils

> - math3.fitting
> - math3.linear
> - math3.fitting.leastsquares

IMO, a way to modernize CM is to modularize it.
A first step could consist in "fitting" and "linear" becoming
(maven) modules.

Regards,
Gilles

> And some of the common util/exception things that drip in when using the
> above.
>
> Am 14.08.20 um 18:42 schrieb Gilles Sadowski:
> > Le jeu. 13 août 2020 à 15:46, Christoph Läubrich
> >  a écrit :
> >>
> >> Hi,
> >>
> >> thnaks for the information, I'm currently using the "old" commons-math3
> >> package, would it be possible to use erf with DerivativeStructure there?
> >
> > Technically, the issue could be that the tools in the "o.a.c.m.special"
> > package were not designed as those in the "o.a.c.m.analysis.function"
> > package.  And IIUC, "DerivativeStructure" builds on the latter.
> > But that doesn't mean it cannot be done (I've not used it personally).
> >
> > A lot of work has been done on the "master" branch; a 3.7 release
> > would mean backporting everything; not a trivial task and (if at all
> > possible) it would take more time (by a tall order) than anyone is
> > willing to devote to that library.
> >
> > IMHO, it's about time that we release v4.0 (which has been delayed
> > by more than 4 years, according to when the decision has been taken
> > to start development on that next major version).
> >
> >>   > We are looking for volunteer maintainers for the math tools available
> >>
> >> for commons math in general or for "commons-numbers"?
> >
> > Both and more:
> >
> > * Commons Geometry (spun off the "o.a.c.m.geometry" package)
> > * Commons Statistics (intended to replace the "o.a.c.m.stat" package)
> > * Commons RNG (replacement of the "o.a.c.m.random" package, and
> >pretty feature-complete as of v1.3).
> >
> >> I must confess I have only recently noticed that there is development in
> >> commons-math-4 and might be out of date with my knowledge a bit as an
> >> "old" math3 user :-)
> >
> > Which classes/packages have you been using?
> >
> > Gilles
> >
> >>
> >> Am 13.08.20 um 15:12 schrieb Gilles Sadowski:
> >>> Hi.
> >>>
> >>> Le jeu. 13 août 2020 à 12:48, Christoph Läubrich
> >>>  a écrit :
> >>>>
> >>>> I'd like to use the org.apache.commons.math3.special.Erf with a
> >>>> DerivativeStructure but is seems there is no pre-defined function for
> >>>> this (like exp()...).
> >>>>
> >>>> So the question is, can Erf transformed inside a DerivativeStructure
> >>>> somehow or does the DerivativeStructure need to support that function
> >>>> directly?
> >>>
> >>> Please note that "Erf" has been moved to the new "Commons Numbers"
> >>> component[1], along with the other Gamma-related functions.
> >>> The "DerivativeStructure" is one among several utilities that still need 
> >>> to
> >>> be ported (and refactored) there.[2]
> >>>
> >>> We are looking for volunteer maintainers for the math tools available from
> >>> the Commons libraries.  The move to more focused, smaller, components
> >>> should hopefully simplify development...
> >>>
> >>> Best,
> >>> Gilles
> >>>
> >>> [1] 
> >>> https://gitbox.apache.org/repos/asf?p=commons-numbers.git;a=tree;f=commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma;h=cb95316a3be45ebfcf938eab63f362f59e590fca;hb=HEAD
> >>> [2] https://issues.apache.org/jira/browse/NUMBERS-69

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] DfpField

2020-08-19 Thread schophil
Hi,

Thank you for the answer.

I can indeed have an instance per thread. I was just wondering if it was
thread safe. Having one instance is easier to manage, especially with DI
frameworks.

As for the use case. I actually need to solve an ODE. I was afraid of using
plain double's since I know precision errors can arise.
The other option in Commons Math is to use a Field integrator; that's why I
went for the DfpField.

Does this make sense?

Anyway, I will remove the single instance; just to be safe.

Regards,

Philippe

On Wed, Aug 19, 2020 at 1:19 PM Gilles Sadowski 
wrote:

> Hi.
>
> 2020-08-19 8:09 UTC+02:00, schophil :
> > Hi,
> >
> > I have a question regarding the use of DfpField.
> >
> > Is an instance of DfpField thread safe?
>
> Personally I don't know. Sorry.
> I've just looked at some of the code, and there is an occurrence
> of the "synchronized" keyword; so it seems that thread-safety
> was at least taken into account.
> Maybe someone else can provide a more accurate answer...
>
> This functionality is implemented by old classes, dating before
> the project had decided to focus on immutable instances in
> order to ensure their thread-safety.
>
> And IIRC, it's the first time, in more than 10 years, that someone
> mentions using "Dfp"...
>
> > Can I use a single instance to
> > perform Dfp calculations in different threads?
>
> Could you provide an example of your use-cases?
> Isn't it possible to make copies, rather than share a single
> instance?
>
> More generally, I'm curious: why would you use it rather
> than JDK's "BigDecimal"?
>
> > I have looked at the code of Dfp and I am a bit worried by the calls to
> > DfpField.setIEEEFlagsBits().
> > Can I just set the flags in advance?
>
> You can, of course; but there are several places where the
> question of thread-safety could be raised...
>
> Also, in the new "Commons Numbers" component[1], there is an
> attempt to implement the concept of "field" in a cleaner (IMHO)
> way than in "Commons Math" (CM).
> Functionality in "Commons Numbers" is probably incomplete.
> Looking for volunteers in order to continue porting more useful
> stuff from CM (refactoring them on the way by making use of
> Java 8 features).
>
> Regards,
> Gilles
>
> [1] http://commons.apache.org/proper/commons-numbers/
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>


Re: [math] DfpField

2020-08-19 Thread Gilles Sadowski
Hi.

2020-08-19 8:09 UTC+02:00, schophil :
> Hi,
>
> I have a question regarding the use of DfpField.
>
> Is an instance of DfpField thread safe?

Personally I don't know. Sorry.
I've just looked at some of the code, and there is an occurrence
of the "synchronized" keyword; so it seems that thread-safety
was at least taken into account.
Maybe someone else can provide a more accurate answer...

This functionality is implemented by old classes, dating before
the project had decided to focus on immutable instances in
order to ensure their thread-safety.

And IIRC, it's the first time, in more than 10 years, that someone
mentions using "Dfp"...

> Can I use a single instance to
> perform Dfp calculations in different threads?

Could you provide an example of your use-cases?
Isn't it possible to make copies, rather than share a single
instance?

More generally, I'm curious: why would you use it rather
than JDK's "BigDecimal"?

> I have looked at the code of Dfp and I am a bit worried by the calls to
> DfpField.setIEEEFlagsBits().
> Can I just set the flags in advance?

You can, of course; but there are several places where the
question of thread-safety could be raised...

Also, in the new "Commons Numbers" component[1], there is an
attempt to implement the concept of "field" in a cleaner (IMHO)
way than in "Commons Math" (CM).
Functionality in "Commons Numbers" is probably incomplete.
Looking for volunteers in order to continue porting more useful
stuff from CM (refactoring them on the way by making use of
Java 8 features).

Regards,
Gilles

[1] http://commons.apache.org/proper/commons-numbers/

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] DerivativeStructure and erf/erfx

2020-08-19 Thread Christoph Läubrich

Im mostly using

- math3.analysis
- math3.fitting
- math3.linear
- math3.fitting.leastsquares

And some of the common util/exception things that drip in when using the 
above.


Am 14.08.20 um 18:42 schrieb Gilles Sadowski:

Le jeu. 13 août 2020 à 15:46, Christoph Läubrich
 a écrit :


Hi,

thnaks for the information, I'm currently using the "old" commons-math3
package, would it be possible to use erf with DerivativeStructure there?


Technically, the issue could be that the tools in the "o.a.c.m.special"
package were not designed as those in the "o.a.c.m.analysis.function"
package.  And IIUC, "DerivativeStructure" builds on the latter.
But that doesn't mean it cannot be done (I've not used it personally).

A lot of work has been done on the "master" branch; a 3.7 release
would mean backporting everything; not a trivial task and (if at all
possible) it would take more time (by a tall order) than anyone is
willing to devote to that library.

IMHO, it's about time that we release v4.0 (which has been delayed
by more than 4 years, according to when the decision has been taken
to start development on that next major version).


  > We are looking for volunteer maintainers for the math tools available

for commons math in general or for "commons-numbers"?


Both and more:

* Commons Geometry (spun off the "o.a.c.m.geometry" package)
* Commons Statistics (intended to replace the "o.a.c.m.stat" package)
* Commons RNG (replacement of the "o.a.c.m.random" package, and
   pretty feature-complete as of v1.3).


I must confess I have only recently noticed that there is development in
commons-math-4 and might be out of date with my knowledge a bit as an
"old" math3 user :-)


Which classes/packages have you been using?

Gilles



Am 13.08.20 um 15:12 schrieb Gilles Sadowski:

Hi.

Le jeu. 13 août 2020 à 12:48, Christoph Läubrich
 a écrit :


I'd like to use the org.apache.commons.math3.special.Erf with a
DerivativeStructure but is seems there is no pre-defined function for
this (like exp()...).

So the question is, can Erf transformed inside a DerivativeStructure
somehow or does the DerivativeStructure need to support that function
directly?


Please note that "Erf" has been moved to the new "Commons Numbers"
component[1], along with the other Gamma-related functions.
The "DerivativeStructure" is one among several utilities that still need to
be ported (and refactored) there.[2]

We are looking for volunteer maintainers for the math tools available from
the Commons libraries.  The move to more focused, smaller, components
should hopefully simplify development...

Best,
Gilles

[1] 
https://gitbox.apache.org/repos/asf?p=commons-numbers.git;a=tree;f=commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma;h=cb95316a3be45ebfcf938eab63f362f59e590fca;hb=HEAD
[2] https://issues.apache.org/jira/browse/NUMBERS-69


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] DfpField

2020-08-19 Thread schophil
Hi,

I have a question regarding the use of DfpField.

Is an instance of DfpField thread safe? Can I use a single instance to
perform Dfp calculations in different threads?

I have looked at the code of Dfp and I am a bit worried by the calls to
DfpField.setIEEEFlagsBits().
Can I just set the flags in advance?

Regards,

Philippe


Re: [math] DerivativeStructure and erf/erfx

2020-08-14 Thread Gilles Sadowski
Le jeu. 13 août 2020 à 15:46, Christoph Läubrich
 a écrit :
>
> Hi,
>
> thnaks for the information, I'm currently using the "old" commons-math3
> package, would it be possible to use erf with DerivativeStructure there?

Technically, the issue could be that the tools in the "o.a.c.m.special"
package were not designed as those in the "o.a.c.m.analysis.function"
package.  And IIUC, "DerivativeStructure" builds on the latter.
But that doesn't mean it cannot be done (I've not used it personally).

A lot of work has been done on the "master" branch; a 3.7 release
would mean backporting everything; not a trivial task and (if at all
possible) it would take more time (by a tall order) than anyone is
willing to devote to that library.

IMHO, it's about time that we release v4.0 (which has been delayed
by more than 4 years, according to when the decision has been taken
to start development on that next major version).

>  > We are looking for volunteer maintainers for the math tools available
>
> for commons math in general or for "commons-numbers"?

Both and more:

* Commons Geometry (spun off the "o.a.c.m.geometry" package)
* Commons Statistics (intended to replace the "o.a.c.m.stat" package)
* Commons RNG (replacement of the "o.a.c.m.random" package, and
  pretty feature-complete as of v1.3).

> I must confess I have only recently noticed that there is development in
> commons-math-4 and might be out of date with my knowledge a bit as an
> "old" math3 user :-)

Which classes/packages have you been using?

Gilles

>
> Am 13.08.20 um 15:12 schrieb Gilles Sadowski:
> > Hi.
> >
> > Le jeu. 13 août 2020 à 12:48, Christoph Läubrich
> >  a écrit :
> >>
> >> I'd like to use the org.apache.commons.math3.special.Erf with a
> >> DerivativeStructure but is seems there is no pre-defined function for
> >> this (like exp()...).
> >>
> >> So the question is, can Erf transformed inside a DerivativeStructure
> >> somehow or does the DerivativeStructure need to support that function
> >> directly?
> >
> > Please note that "Erf" has been moved to the new "Commons Numbers"
> > component[1], along with the other Gamma-related functions.
> > The "DerivativeStructure" is one among several utilities that still need to
> > be ported (and refactored) there.[2]
> >
> > We are looking for volunteer maintainers for the math tools available from
> > the Commons libraries.  The move to more focused, smaller, components
> > should hopefully simplify development...
> >
> > Best,
> > Gilles
> >
> > [1] 
> > https://gitbox.apache.org/repos/asf?p=commons-numbers.git;a=tree;f=commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma;h=cb95316a3be45ebfcf938eab63f362f59e590fca;hb=HEAD
> > [2] https://issues.apache.org/jira/browse/NUMBERS-69

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] DerivativeStructure and erf/erfx

2020-08-13 Thread Christoph Läubrich

Hi,

thnaks for the information, I'm currently using the "old" commons-math3 
package, would it be possible to use erf with DerivativeStructure there?


> We are looking for volunteer maintainers for the math tools available

for commons math in general or for "commons-numbers"?

I must confess I have only recently noticed that there is development in 
commons-math-4 and might be out of date with my knowledge a bit as an 
"old" math3 user :-)



Am 13.08.20 um 15:12 schrieb Gilles Sadowski:

Hi.

Le jeu. 13 août 2020 à 12:48, Christoph Läubrich
 a écrit :


I'd like to use the org.apache.commons.math3.special.Erf with a
DerivativeStructure but is seems there is no pre-defined function for
this (like exp()...).

So the question is, can Erf transformed inside a DerivativeStructure
somehow or does the DerivativeStructure need to support that function
directly?


Please note that "Erf" has been moved to the new "Commons Numbers"
component[1], along with the other Gamma-related functions.
The "DerivativeStructure" is one among several utilities that still need to
be ported (and refactored) there.[2]

We are looking for volunteer maintainers for the math tools available from
the Commons libraries.  The move to more focused, smaller, components
should hopefully simplify development...

Best,
Gilles

[1] 
https://gitbox.apache.org/repos/asf?p=commons-numbers.git;a=tree;f=commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma;h=cb95316a3be45ebfcf938eab63f362f59e590fca;hb=HEAD
[2] https://issues.apache.org/jira/browse/NUMBERS-69

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] DerivativeStructure and erf/erfx

2020-08-13 Thread Gilles Sadowski
Hi.

Le jeu. 13 août 2020 à 12:48, Christoph Läubrich
 a écrit :
>
> I'd like to use the org.apache.commons.math3.special.Erf with a
> DerivativeStructure but is seems there is no pre-defined function for
> this (like exp()...).
>
> So the question is, can Erf transformed inside a DerivativeStructure
> somehow or does the DerivativeStructure need to support that function
> directly?

Please note that "Erf" has been moved to the new "Commons Numbers"
component[1], along with the other Gamma-related functions.
The "DerivativeStructure" is one among several utilities that still need to
be ported (and refactored) there.[2]

We are looking for volunteer maintainers for the math tools available from
the Commons libraries.  The move to more focused, smaller, components
should hopefully simplify development...

Best,
Gilles

[1] 
https://gitbox.apache.org/repos/asf?p=commons-numbers.git;a=tree;f=commons-numbers-gamma/src/main/java/org/apache/commons/numbers/gamma;h=cb95316a3be45ebfcf938eab63f362f59e590fca;hb=HEAD
[2] https://issues.apache.org/jira/browse/NUMBERS-69

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] DerivativeStructure and erf/erfx

2020-08-13 Thread Christoph Läubrich
I'd like to use the org.apache.commons.math3.special.Erf with a 
DerivativeStructure but is seems there is no pre-defined function for 
this (like exp()...).


So the question is, can Erf transformed inside a DerivativeStructure 
somehow or does the DerivativeStructure need to support that function 
directly?


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2020-08-12 Thread Christoph Läubrich
se the
ParameterValidator, is there any example code for both mentioned
alternatives?

For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
archive that the mean is within a closed bound e.g from 5 to 6 where my
datapoints ranges from 0..90, how would this be archived?


Could you set up a unit test as a practical example of what
you need to achieve?


I'm especially interested because the FUNCTION inside
GaussianCurveFitter seems to reject invalid values (e.g. negative
valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
either approach described in the user-docs.


What I don't quite get is why you need to force the mean within a
certain range; if the data match a Gaussian with a mean within that
range, I would assume that the fitter will find the correct value...
Sorry if I missed something.  Hopefully the example will clarify.

Best,
Gilles




[1]
https://commons.apache.org/proper/commons-math/userguide/leastsquares.html


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2020-08-11 Thread Gilles Sadowski
t;
> >> [1]
> >> https://ascelibrary.org/cms/asset/6ca2b016-1a4f-4eed-80da-71219777cac1/1.jpg
> >>
> >> Am 11.08.20 um 00:42 schrieb Gilles Sadowski:
> >>> Hello.
> >>>
> >>> Le lun. 10 août 2020 à 17:09, Christoph Läubrich
> >>>  a écrit :
> >>>>
> >>>> The userguide [1] mentions that it is currently not directly possible to
> >>>> contrain parameters directly but suggest one can use the
> >>>> ParameterValidator, is there any example code for both mentioned
> >>>> alternatives?
> >>>>
> >>>> For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
> >>>> archive that the mean is within a closed bound e.g from 5 to 6 where my
> >>>> datapoints ranges from 0..90, how would this be archived?
> >>>
> >>> Could you set up a unit test as a practical example of what
> >>> you need to achieve?
> >>>
> >>>> I'm especially interested because the FUNCTION inside
> >>>> GaussianCurveFitter seems to reject invalid values (e.g. negative
> >>>> valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
> >>>> either approach described in the user-docs.
> >>>
> >>> What I don't quite get is why you need to force the mean within a
> >>> certain range; if the data match a Gaussian with a mean within that
> >>> range, I would assume that the fitter will find the correct value...
> >>> Sorry if I missed something.  Hopefully the example will clarify.
> >>>
> >>> Best,
> >>> Gilles
> >>>
> >>>>
> >>>>
> >>>> [1]
> >>>> https://commons.apache.org/proper/commons-math/userguide/leastsquares.html

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2020-08-11 Thread Christoph Läubrich
Thanks for your patience, maybe a better/simpler example would be [1], I 
want to find the best fit using LSB under the constraint that the height 
of the curve never is above 0.7 (even though without constrains the 
optimizer would find a better solution around 8.5).


So my first idea way to copy/extend GausianCurveFitter to accept some 
kind of "maxHeight(...)", adjust the function to return INF for 
h>maxHeight, I was just unsure that return INF is allowed (per 
definition) as it is not mentioned anywhere in the userdocs. And if I 
want to limit others (like max position) it would work the same way.


In my final problem I need to limit the height, width and position of 
the bell-curve to fall into certain bounds, but there is no direct 
relation (e.g. width must be three times the height).




[1] 
https://crlbucophysics101.files.wordpress.com/2015/02/gaussian.png?w=538=294





Am 11.08.20 um 11:18 schrieb Gilles Sadowski:

Hi.

2020-08-11 8:51 UTC+02:00, Christoph Läubrich :

Hi Gilles,


Just to make clear I don't suspect any error with GausianCurveFitter, I
just don't understand how the advice in the user-doc to restrict
parameter (for general problems) could be applied to a concrete problem
and thus chosen GausianCurvefitter as an example as it uses
LeastSquaresBuilder.

I also noticed that Gaussian Fitter has a restriction on parameters
(norm can't be negative) that is handled in a third way (returning
Double.POSITIVE_INFINITY instead of Parameter Validator) not mentioned
in the userdoc at all, so I wonder if this is a general purpose solution
for restricting parameters (seems the simplest approach).


I'd indeed suggest to first try the same trick as in "GaussianCurveFitter"
(i.e. return a "high" value for arguments outside a known range).
That way, you only have to define a suitable "ParametricUnivariateFunction"
and pass it to "SimpleCurveFitter".

One case for the "ParameterValidator" is when some of the model
parameters might be correlated to others.
But using it makes it necessary that you handle yourself all the
arguments to be passed to the "LeastSquaresProblem".


To take the gausian example for my use case, consider an observed signal
similar to [1], given I know (from other source as the plain data) for
example that the result must be found in the range of 2...3 and I wanted
to restrict valid solutions to this area. The same might apply to the
norm: I know it must be between a given range and I want to restrict the
optimizer here even though there might be a solution outside of the
range that (compared of the R^2) fits better, e.g. a gausian fit well
inside the -1..1.

I hope it is a little bit clearer.


I'm not sure.  The picture shows a function that is not a Gaussian.
Do you mean that you want to fit only *part* of the data with a
function that would not fit well *all* the data?

Regards,
Gilles




[1]
https://ascelibrary.org/cms/asset/6ca2b016-1a4f-4eed-80da-71219777cac1/1.jpg

Am 11.08.20 um 00:42 schrieb Gilles Sadowski:

Hello.

Le lun. 10 août 2020 à 17:09, Christoph Läubrich
 a écrit :


The userguide [1] mentions that it is currently not directly possible to
contrain parameters directly but suggest one can use the
ParameterValidator, is there any example code for both mentioned
alternatives?

For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
archive that the mean is within a closed bound e.g from 5 to 6 where my
datapoints ranges from 0..90, how would this be archived?


Could you set up a unit test as a practical example of what
you need to achieve?


I'm especially interested because the FUNCTION inside
GaussianCurveFitter seems to reject invalid values (e.g. negative
valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
either approach described in the user-docs.


What I don't quite get is why you need to force the mean within a
certain range; if the data match a Gaussian with a mean within that
range, I would assume that the fitter will find the correct value...
Sorry if I missed something.  Hopefully the example will clarify.

Best,
Gilles




[1]
https://commons.apache.org/proper/commons-math/userguide/leastsquares.html



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2020-08-11 Thread Gilles Sadowski
Hi.

2020-08-11 8:51 UTC+02:00, Christoph Läubrich :
> Hi Gilles,
>
>
> Just to make clear I don't suspect any error with GausianCurveFitter, I
> just don't understand how the advice in the user-doc to restrict
> parameter (for general problems) could be applied to a concrete problem
> and thus chosen GausianCurvefitter as an example as it uses
> LeastSquaresBuilder.
>
> I also noticed that Gaussian Fitter has a restriction on parameters
> (norm can't be negative) that is handled in a third way (returning
> Double.POSITIVE_INFINITY instead of Parameter Validator) not mentioned
> in the userdoc at all, so I wonder if this is a general purpose solution
> for restricting parameters (seems the simplest approach).

I'd indeed suggest to first try the same trick as in "GaussianCurveFitter"
(i.e. return a "high" value for arguments outside a known range).
That way, you only have to define a suitable "ParametricUnivariateFunction"
and pass it to "SimpleCurveFitter".

One case for the "ParameterValidator" is when some of the model
parameters might be correlated to others.
But using it makes it necessary that you handle yourself all the
arguments to be passed to the "LeastSquaresProblem".

> To take the gausian example for my use case, consider an observed signal
> similar to [1], given I know (from other source as the plain data) for
> example that the result must be found in the range of 2...3 and I wanted
> to restrict valid solutions to this area. The same might apply to the
> norm: I know it must be between a given range and I want to restrict the
> optimizer here even though there might be a solution outside of the
> range that (compared of the R^2) fits better, e.g. a gausian fit well
> inside the -1..1.
>
> I hope it is a little bit clearer.

I'm not sure.  The picture shows a function that is not a Gaussian.
Do you mean that you want to fit only *part* of the data with a
function that would not fit well *all* the data?

Regards,
Gilles

>
>
> [1]
> https://ascelibrary.org/cms/asset/6ca2b016-1a4f-4eed-80da-71219777cac1/1.jpg
>
> Am 11.08.20 um 00:42 schrieb Gilles Sadowski:
>> Hello.
>>
>> Le lun. 10 août 2020 à 17:09, Christoph Läubrich
>>  a écrit :
>>>
>>> The userguide [1] mentions that it is currently not directly possible to
>>> contrain parameters directly but suggest one can use the
>>> ParameterValidator, is there any example code for both mentioned
>>> alternatives?
>>>
>>> For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
>>> archive that the mean is within a closed bound e.g from 5 to 6 where my
>>> datapoints ranges from 0..90, how would this be archived?
>>
>> Could you set up a unit test as a practical example of what
>> you need to achieve?
>>
>>> I'm especially interested because the FUNCTION inside
>>> GaussianCurveFitter seems to reject invalid values (e.g. negative
>>> valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
>>> either approach described in the user-docs.
>>
>> What I don't quite get is why you need to force the mean within a
>> certain range; if the data match a Gaussian with a mean within that
>> range, I would assume that the fitter will find the correct value...
>> Sorry if I missed something.  Hopefully the example will clarify.
>>
>> Best,
>> Gilles
>>
>>>
>>>
>>> [1]
>>> https://commons.apache.org/proper/commons-math/userguide/leastsquares.html
>>>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2020-08-11 Thread Christoph Läubrich

Hi Gilles,


Just to make clear I don't suspect any error with GausianCurveFitter, I 
just don't understand how the advice in the user-doc to restrict 
parameter (for general problems) could be applied to a concrete problem 
and thus chosen GausianCurvefitter as an example as it uses 
LeastSquaresBuilder.


I also noticed that Gaussian Fitter has a restriction on parameters 
(norm can't be negative) that is handled in a third way (returning 
Double.POSITIVE_INFINITY instead of Parameter Validator) not mentioned 
in the userdoc at all, so I wonder if this is a general purpose solution 
for restricting parameters (seems the simplest approach).


To take the gausian example for my use case, consider an observed signal 
similar to [1], given I know (from other source as the plain data) for 
example that the result must be found in the range of 2...3 and I wanted 
to restrict valid solutions to this area. The same might apply to the 
norm: I know it must be between a given range and I want to restrict the 
optimizer here even though there might be a solution outside of the 
range that (compared of the R^2) fits better, e.g. a gausian fit well 
inside the -1..1.


I hope it is a little bit clearer.


[1] 
https://ascelibrary.org/cms/asset/6ca2b016-1a4f-4eed-80da-71219777cac1/1.jpg


Am 11.08.20 um 00:42 schrieb Gilles Sadowski:

Hello.

Le lun. 10 août 2020 à 17:09, Christoph Läubrich
 a écrit :


The userguide [1] mentions that it is currently not directly possible to
contrain parameters directly but suggest one can use the
ParameterValidator, is there any example code for both mentioned
alternatives?

For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
archive that the mean is within a closed bound e.g from 5 to 6 where my
datapoints ranges from 0..90, how would this be archived?


Could you set up a unit test as a practical example of what
you need to achieve?


I'm especially interested because the FUNCTION inside
GaussianCurveFitter seems to reject invalid values (e.g. negative
valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
either approach described in the user-docs.


What I don't quite get is why you need to force the mean within a
certain range; if the data match a Gaussian with a mean within that
range, I would assume that the fitter will find the correct value...
Sorry if I missed something.  Hopefully the example will clarify.

Best,
Gilles




[1]
https://commons.apache.org/proper/commons-math/userguide/leastsquares.html



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] example for constrain parameters for Least squares

2020-08-10 Thread Gilles Sadowski
Hello.

Le lun. 10 août 2020 à 17:09, Christoph Läubrich
 a écrit :
>
> The userguide [1] mentions that it is currently not directly possible to
> contrain parameters directly but suggest one can use the
> ParameterValidator, is there any example code for both mentioned
> alternatives?
>
> For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to
> archive that the mean is within a closed bound e.g from 5 to 6 where my
> datapoints ranges from 0..90, how would this be archived?

Could you set up a unit test as a practical example of what
you need to achieve?

> I'm especially interested because the FUNCTION inside
> GaussianCurveFitter seems to reject invalid values (e.g. negative
> valuenorm) by simply return Double.POSITIVE_INFINITY instead of using
> either approach described in the user-docs.

What I don't quite get is why you need to force the mean within a
certain range; if the data match a Gaussian with a mean within that
range, I would assume that the fitter will find the correct value...
Sorry if I missed something.  Hopefully the example will clarify.

Best,
Gilles

>
>
> [1]
> https://commons.apache.org/proper/commons-math/userguide/leastsquares.html
>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] example for constrain parameters for Least squares

2020-08-10 Thread Christoph Läubrich
The userguide [1] mentions that it is currently not directly possible to 
contrain parameters directly but suggest one can use the 
ParameterValidator, is there any example code for both mentioned 
alternatives?


For example GaussianCurveFitter uses LeastSquaresBuilder and I wan't to 
archive that the mean is within a closed bound e.g from 5 to 6 where my 
datapoints ranges from 0..90, how would this be archived?


I'm especially interested because the FUNCTION inside 
GaussianCurveFitter seems to reject invalid values (e.g. negative 
valuenorm) by simply return Double.POSITIVE_INFINITY instead of using 
either approach described in the user-docs.



[1] 
https://commons.apache.org/proper/commons-math/userguide/leastsquares.html


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] Optimization API Question

2020-07-11 Thread Oscar Bastidas
Hello Gilles,

That is a good question.  I don't know.  I read through the webpage Apache
Commons Math has for the optimization APIs and everything there appeared to
be an optimization (minimization or maximization) not for solving to hit a
custom target "y" value.  I will look at the specific documentation for the
specific class you mention and see if there is some way to do what I am
looking for.  Thanks.

Oscar


On Sat, Jul 11, 2020, 2:00 PM Gilles Sadowski  wrote:

> Hi.
>
> Le sam. 11 juil. 2020 à 03:54, Oscar Bastidas
>  a écrit :
> >
> > Would someone please tell me if the Optimization APIs in Apache Commons
> > Math can be used to solve a multi-variate equation (multiple xs, just one
> > y) for a specific value as Microsoft Excel's Solver can and if so, how
> that
> > would be implemented?  In short, I don't want to solve my multi-variate
> > system for zero, but set it equal to any number of my choosing and have
> the
> > program return the values of the coefficients (Y=Ax1+Bx2+Cx3+...nxi) that
> > satisfy the equation.  Thanks.
>
> Isn't the functionality implemented in the
> org.apache.commons.math4.optim.linear
> package[1] what you are looking for?
>
> Regards,
> Gilles
>
> [1]
> http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math4/optim/linear/package-frame.html
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>


Re: [math] Optimization API Question

2020-07-11 Thread Gilles Sadowski
Hi.

Le sam. 11 juil. 2020 à 03:54, Oscar Bastidas
 a écrit :
>
> Would someone please tell me if the Optimization APIs in Apache Commons
> Math can be used to solve a multi-variate equation (multiple xs, just one
> y) for a specific value as Microsoft Excel's Solver can and if so, how that
> would be implemented?  In short, I don't want to solve my multi-variate
> system for zero, but set it equal to any number of my choosing and have the
> program return the values of the coefficients (Y=Ax1+Bx2+Cx3+...nxi) that
> satisfy the equation.  Thanks.

Isn't the functionality implemented in the
org.apache.commons.math4.optim.linear
package[1] what you are looking for?

Regards,
Gilles

[1] 
http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math4/optim/linear/package-frame.html

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] Optimization API Question

2020-07-10 Thread Oscar Bastidas
Would someone please tell me if the Optimization APIs in Apache Commons
Math can be used to solve a multi-variate equation (multiple xs, just one
y) for a specific value as Microsoft Excel's Solver can and if so, how that
would be implemented?  In short, I don't want to solve my multi-variate
system for zero, but set it equal to any number of my choosing and have the
program return the values of the coefficients (Y=Ax1+Bx2+Cx3+...nxi) that
satisfy the equation.  Thanks.

Oscar B.


Re: [math] Calculate distance from (3d) Segment to (3d) Segment and Vector3D

2020-05-28 Thread Patrik Karlström
Thanks for the information Gilles,
I'll take a look att Geometry then.

As soon as I posted posted my question though, I got the idea of comparing
the lengths of the segments with the distance from their beginnings to the
line intersection. If longer, then the intersection is valid for the
segments.
It looks like that works for me, but I'll switch over to Geometry.

/Patrik


Den tors 28 maj 2020 kl 13:17 skrev Gilles Sadowski :

> Hello Patrik.
>
> 2020-05-28 9:39 UTC+02:00, Patrik Karlström :
> > Hi,
> > first time user of math here, in more ways than one it feels. :)
> >
> > I need to get the shortest distance between two segments,
> > not knowing the difference, I started off by using 3d Line but until I
> knew
> > why, the result was disturbing. ;)
> >
> > However, the 3d Segment class is missing all sorts of methods compared to
> > the 3d Line class.
> >
> > Does commons math provide a way around this that allows me to get the
> > distances I need in a simple way?
> >
> > Oh, the intersection, if any, is of interest too.
> >
> > /Patrik
> >
>
> In the upcoming version of Commons Math (v4.0), the package
> "geometry" has been removed: Code has been ported to a new
> library:
> https://commons.apache.org/geometry
>
> Please have a look, and if what you need is still missing, don't
> hesitate to repost (using the "[Geometry]" prefix in the subject).
>
> Best regards,
> Gilles
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>


Re: [math] Calculate distance from (3d) Segment to (3d) Segment and Vector3D

2020-05-28 Thread Gilles Sadowski
Hello Patrik.

2020-05-28 9:39 UTC+02:00, Patrik Karlström :
> Hi,
> first time user of math here, in more ways than one it feels. :)
>
> I need to get the shortest distance between two segments,
> not knowing the difference, I started off by using 3d Line but until I knew
> why, the result was disturbing. ;)
>
> However, the 3d Segment class is missing all sorts of methods compared to
> the 3d Line class.
>
> Does commons math provide a way around this that allows me to get the
> distances I need in a simple way?
>
> Oh, the intersection, if any, is of interest too.
>
> /Patrik
>

In the upcoming version of Commons Math (v4.0), the package
"geometry" has been removed: Code has been ported to a new
library:
https://commons.apache.org/geometry

Please have a look, and if what you need is still missing, don't
hesitate to repost (using the "[Geometry]" prefix in the subject).

Best regards,
Gilles

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] Calculate distance from (3d) Segment to (3d) Segment and Vector3D

2020-05-28 Thread Patrik Karlström
Hi,
first time user of math here, in more ways than one it feels. :)

I need to get the shortest distance between two segments,
not knowing the difference, I started off by using 3d Line but until I knew
why, the result was disturbing. ;)

However, the 3d Segment class is missing all sorts of methods compared to
the 3d Line class.

Does commons math provide a way around this that allows me to get the
distances I need in a simple way?

Oh, the intersection, if any, is of interest too.

/Patrik


Re: [math] Question about GaussianCurveFitter.ParameterGuesser

2020-05-25 Thread Gilles Sadowski
Hello.

Le lun. 25 mai 2020 à 07:27, Christoph Läubrich
 a écrit :
>
> I'm currently looking into some curve-fitting and have examined the
>
> basicGuess(WeightedObservedPoint[])
>
> in GaussianCurveFitter.ParameterGuesser, and there is one thing I don't
> really understand.
>
> in Line 301 [1] the "halfY" is computed by n (what is the maximal y
> value of the observation) + half the sum of n+m (where m is the x value
> of the maximum) applying this to some of my datapoints that fit
> relatively good as a Gaussian later, it seems that this condition never
> works, and the default in the catch clause is used instead.
>
> I also wonder why x is taken into account for computing the half-y value..

Good question indeed.  I don't see why the estimation of the
half-width would change depending on the position of the curve
along the x-axis.
Also it seems that the current code could be made more robust by
shifting the abscissa of the maximum height to 0 before performing
the rest of the computation.

Could you please file a report on the bug-tracking system?[1]

Thanks,
Gilles

[1] https://issues.apache.org/jira/projects/MATH

> [...]

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] Question about GaussianCurveFitter.ParameterGuesser

2020-05-24 Thread Christoph Läubrich

I'm currently looking into some curve-fitting and have examined the

basicGuess(WeightedObservedPoint[])

in GaussianCurveFitter.ParameterGuesser, and there is one thing I don't 
really understand.


in Line 301 [1] the "halfY" is computed by n (what is the maximal y 
value of the observation) + half the sum of n+m (where m is the x value 
of the maximum) applying this to some of my datapoints that fit 
relatively good as a Gaussian later, it seems that this condition never 
works, and the default in the catch clause is used instead.


I also wonder why x is taken into account for computing the half-y value..

thanks in advance.


[1] 
https://github.com/apache/commons-math/blob/master/src/main/java/org/apache/commons/math4/fitting/GaussianCurveFitter.java#L301


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



RE: [jexl] How to use math functions with JEXL

2020-04-20 Thread Greenberg, Gary
I already figured it out.
With this snippet it is working:
private static final JexlEngine ENGINE;
static {
Map fnc = new HashMap<>();
fnc.put("math", Math.class);
ENGINE = new 
JexlBuilder().namespaces(fnc).cache(512).strict(true).silent(false).create();
}

And BTW, You are not importing anything from java.lang. It is already there by 
default.

Gary Greenberg
Staff Software Engineer
Data Product Development, BI-A
E: ggree...@visa.com
M: 650-269-7902




-Original Message-
From: Joakim Knudsen  
Sent: Sunday, April 19, 2020 9:38 PM
To: Commons Users List 
Subject: Re: [jexl] How to use math functions with JEXL

Hi,

Did you import the Math library?

import java.lang.Math;


Joakim

søn. 19. apr. 2020, 07:21 skrev Greenberg, Gary :

> I am trying to evaluate an expression that beside simple arithmetic 
> need to calculate square root.
>
> I tried sqrt(), Math.sqrt() and java.lang.Math.sqrt and nothing works
>
> I am always getting something like @1:1 undefined variable java.lang.Math.
>
> I did use before expr4j and it has all these functions built-in.
>
> Switched to JEXL, because need not only numeric, but also Boolean 
> expressions.
>
> Can you also confirm if this type of expressions will work:
>
> a.equalsIgnoreCase(“XYZ”) && b.startWith(“http”)
>
> where a and b are variables in the JexlContext.
>
>
>
> Gary Greenberg
>
> Staff Software Engineer
>
> Data Product Development, BI-A
>
> E: ggree...@visa.com
>
> M: 650-269-7902
>
>
>
> [image: EmailSig-TaglineVersion]
>
>
>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [jexl] How to use math functions with JEXL

2020-04-19 Thread swapnil vaidya
You will have to register math as name space with JexlContext

https://commons.apache.org/proper/commons-jexl/apidocs/org/apache/commons/jexl3/package-summary.html

Regards,
Swapnil

On Sun, Apr 19, 2020 at 10:51 AM Greenberg, Gary 
wrote:

> I am trying to evaluate an expression that beside simple arithmetic need
> to calculate square root.
>
> I tried sqrt(), Math.sqrt() and java.lang.Math.sqrt and nothing works
>
> I am always getting something like @1:1 undefined variable java.lang.Math.
>
> I did use before expr4j and it has all these functions built-in.
>
> Switched to JEXL, because need not only numeric, but also Boolean
> expressions.
>
> Can you also confirm if this type of expressions will work:
>
> a.equalsIgnoreCase(“XYZ”) && b.startWith(“http”)
>
> where a and b are variables in the JexlContext.
>
>
>
> Gary Greenberg
>
> Staff Software Engineer
>
> Data Product Development, BI-A
>
> E: ggree...@visa.com
>
> M: 650-269-7902
>
>
>
> [image: EmailSig-TaglineVersion]
>
>
>


Re: [jexl] How to use math functions with JEXL

2020-04-19 Thread Joakim Knudsen
Hi,

Did you import the Math library?

import java.lang.Math;


Joakim

søn. 19. apr. 2020, 07:21 skrev Greenberg, Gary :

> I am trying to evaluate an expression that beside simple arithmetic need
> to calculate square root.
>
> I tried sqrt(), Math.sqrt() and java.lang.Math.sqrt and nothing works
>
> I am always getting something like @1:1 undefined variable java.lang.Math.
>
> I did use before expr4j and it has all these functions built-in.
>
> Switched to JEXL, because need not only numeric, but also Boolean
> expressions.
>
> Can you also confirm if this type of expressions will work:
>
> a.equalsIgnoreCase(“XYZ”) && b.startWith(“http”)
>
> where a and b are variables in the JexlContext.
>
>
>
> Gary Greenberg
>
> Staff Software Engineer
>
> Data Product Development, BI-A
>
> E: ggree...@visa.com
>
> M: 650-269-7902
>
>
>
> [image: EmailSig-TaglineVersion]
>
>
>


[jexl] How to use math functions with JEXL

2020-04-18 Thread Greenberg, Gary
I am trying to evaluate an expression that beside simple arithmetic need to 
calculate square root.
I tried sqrt(), Math.sqrt() and java.lang.Math.sqrt and nothing works
I am always getting something like @1:1 undefined variable java.lang.Math.
I did use before expr4j and it has all these functions built-in.
Switched to JEXL, because need not only numeric, but also Boolean expressions.
Can you also confirm if this type of expressions will work:
a.equalsIgnoreCase("XYZ") && b.startWith("http")
where a and b are variables in the JexlContext.

Gary Greenberg
Staff Software Engineer
Data Product Development, BI-A
E: ggree...@visa.com
M: 650-269-7902

[EmailSig-TaglineVersion]



Re: [math] ode event handler

2020-01-15 Thread Bo Johnson

Hi Gilles,

Thanks for your reply. I'm rather new to Java and how user guides and 
docs are organized (they all seem to follow a general format I'm getting 
used to). I found in the docs a specific example of how to treat a 
bouncing ball and it was the solution to my question.


Best,

On 1/15/20 8:35 AM, Gilles Sadowski wrote:

Hi.

I do not personally use this part of the library.
Thus, only suggesting the obvious: Did you read the user guide, and
the examples that are part of the test suite (in order to be sure that
everything is coded correctly)?
If so, the next step would be to try and devise a minimal (simplified)
example, in the form of a Junit tests to be added to the test suite.

Best regards,
Gilles

Le sam. 11 janv. 2020 à 22:15, Bo Johnson  a écrit :

Hi there,

I'm new to Java and working on a project to integrate some ODEs. I'm
having issues knowing how to work with the event handler. My ODE class
looks like:

public class DipoleODEimplements FirstOrderDifferentialEquations {

  public int getDimension() {
  return 6; }

  public void computeDerivatives(double t, double[] y, double[] yDot) {
  double r = y[0]; double r2 = r * r; double r3 = r2 * r; double r4 = 
r3 * r; double theta = y[1]; double phi = y[2]; double sin_phi = Math.sin(phi); 
double cos_phi = Math.cos(phi); double pr = y[3]; double ptheta = y[4]; double 
ptheta2 = ptheta * ptheta; double pphi = y[5]; double cos2 = Math.cos(phi -2 * 
theta); double sin2 = Math.sin(phi -2 * theta); yDot[0] = pr; yDot[1] = ptheta 
/ r2; yDot[2] =10 * pphi; yDot[3] = ptheta2 / r3 - (cos_phi +3 * cos2) / (4 * 
r4); yDot[4] = sin2 / (2 * r3); yDot[5] = -(sin_phi +3 * sin2) / (12 * r3); }

}

When the y[0] value gets below 1.0, I'd like to change the y[3] value
and the continue the integration. Basically I'm looking for a ball to
bounce off another one. The integration gets stuck though and I can't
seem to get things bouncing. Here's my event handler, too:

EventHandler handler =new EventHandler() {
  @Override public void init(double t0, double[] y0, double t) {

  }

  @Override public double g(double t, double[] y) {
  return y[0] -1.0; }

  @Override public ActioneventOccurred(double t, double[] y, boolean 
increasing) {
  return Action.RESET_STATE; }

  @Override public void resetState(double t, double[] y) {
  y[3] *= -1.0; }
};

And adding it to the integrator:

dp853.addEventHandler(handler, 50.0, 1e-6, 100);

Thanks for the help,

--
Bo Johnson
(801) 503-2043


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org


--
Bo Johnson
(801) 503-2043


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] ode event handler

2020-01-15 Thread Gilles Sadowski
Hi.

I do not personally use this part of the library.
Thus, only suggesting the obvious: Did you read the user guide, and
the examples that are part of the test suite (in order to be sure that
everything is coded correctly)?
If so, the next step would be to try and devise a minimal (simplified)
example, in the form of a Junit tests to be added to the test suite.

Best regards,
Gilles

Le sam. 11 janv. 2020 à 22:15, Bo Johnson  a écrit :
>
> Hi there,
>
> I'm new to Java and working on a project to integrate some ODEs. I'm
> having issues knowing how to work with the event handler. My ODE class
> looks like:
>
> public class DipoleODEimplements FirstOrderDifferentialEquations {
>
>  public int getDimension() {
>  return 6; }
>
>  public void computeDerivatives(double t, double[] y, double[] yDot) {
>  double r = y[0]; double r2 = r * r; double r3 = r2 * r; double r4 = 
> r3 * r; double theta = y[1]; double phi = y[2]; double sin_phi = 
> Math.sin(phi); double cos_phi = Math.cos(phi); double pr = y[3]; double 
> ptheta = y[4]; double ptheta2 = ptheta * ptheta; double pphi = y[5]; double 
> cos2 = Math.cos(phi -2 * theta); double sin2 = Math.sin(phi -2 * theta); 
> yDot[0] = pr; yDot[1] = ptheta / r2; yDot[2] =10 * pphi; yDot[3] = ptheta2 / 
> r3 - (cos_phi +3 * cos2) / (4 * r4); yDot[4] = sin2 / (2 * r3); yDot[5] = 
> -(sin_phi +3 * sin2) / (12 * r3); }
>
> }
>
> When the y[0] value gets below 1.0, I'd like to change the y[3] value
> and the continue the integration. Basically I'm looking for a ball to
> bounce off another one. The integration gets stuck though and I can't
> seem to get things bouncing. Here's my event handler, too:
>
> EventHandler handler =new EventHandler() {
>  @Override public void init(double t0, double[] y0, double t) {
>
>  }
>
>  @Override public double g(double t, double[] y) {
>  return y[0] -1.0; }
>
>  @Override public ActioneventOccurred(double t, double[] y, boolean 
> increasing) {
>  return Action.RESET_STATE; }
>
>  @Override public void resetState(double t, double[] y) {
>  y[3] *= -1.0; }
> };
>
> And adding it to the integrator:
>
> dp853.addEventHandler(handler, 50.0, 1e-6, 100);
>
> Thanks for the help,
>
> --
> Bo Johnson
> (801) 503-2043
>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] ode event handler

2020-01-11 Thread Bo Johnson

Hi there,

I'm new to Java and working on a project to integrate some ODEs. I'm 
having issues knowing how to work with the event handler. My ODE class 
looks like:


public class DipoleODEimplements FirstOrderDifferentialEquations {

public int getDimension() {
return 6; }

public void computeDerivatives(double t, double[] y, double[] yDot) {
double r = y[0]; double r2 = r * r; double r3 = r2 * r; double r4 = r3 
* r; double theta = y[1]; double phi = y[2]; double sin_phi = Math.sin(phi); 
double cos_phi = Math.cos(phi); double pr = y[3]; double ptheta = y[4]; double 
ptheta2 = ptheta * ptheta; double pphi = y[5]; double cos2 = Math.cos(phi -2 * 
theta); double sin2 = Math.sin(phi -2 * theta); yDot[0] = pr; yDot[1] = ptheta 
/ r2; yDot[2] =10 * pphi; yDot[3] = ptheta2 / r3 - (cos_phi +3 * cos2) / (4 * 
r4); yDot[4] = sin2 / (2 * r3); yDot[5] = -(sin_phi +3 * sin2) / (12 * r3); }

}

When the y[0] value gets below 1.0, I'd like to change the y[3] value 
and the continue the integration. Basically I'm looking for a ball to 
bounce off another one. The integration gets stuck though and I can't 
seem to get things bouncing. Here's my event handler, too:


EventHandler handler =new EventHandler() {
@Override public void init(double t0, double[] y0, double t) {

}

@Override public double g(double t, double[] y) {
return y[0] -1.0; }

@Override public ActioneventOccurred(double t, double[] y, boolean 
increasing) {
return Action.RESET_STATE; }

@Override public void resetState(double t, double[] y) {
y[3] *= -1.0; }
};

And adding it to the integrator:

dp853.addEventHandler(handler, 50.0, 1e-6, 100);

Thanks for the help,

--
Bo Johnson
(801) 503-2043



Re: Apache Commons Math Linear Regression Question

2020-01-08 Thread Oscar Bastidas
Please disregard my previous question!  I figured out what I was missing.

Oscar

Oscar Bastidas, Ph.D.
Postdoctoral Research Associate
University of Minnesota

On Wed, Jan 8, 2020, 2:12 PM Oscar Bastidas  wrote:

> Hello,
>
> Would someone please tell me how I am supposed to acquire the actual
> numeric coefficients for a linear regression using the
> PolynomialCurveFitter class?
>
> Below is my code (it's supposed to be a simple example) and when I print
> out the variable that stores the coefficients, ("coeff" in the below
> example) what is printed to the command line is a strange code:
> *[D@1610302.*
>
> This happens regardless of the order of the polynomial I request.
>
> Would someone please help me with this?  Thanks.
>
> *** CODE BELOW **
>
> import java.util.*;
> import org.apache.commons.math3.fitting.PolynomialCurveFitter;
> import org.apache.commons.math3.fitting.*;
>
> public class MathTester
> {
> public static void main(String[] args) {
> // Testing linear regression
> final WeightedObservedPoints obs = new WeightedObservedPoints();
>
> // Acquiring data points
> obs.add(-1.00, 2.021170);
> obs.add(-0.99, 2.221135);
> obs.add(-0.98, 2.099852);
>
>// Instantiate 2nd degree polynomial fitting
>final PolynomialCurveFitter fitter =
> PolynomialCurveFitter.create(2);
>
> // Retrieve fitted coefficients of the fitted data
> final double[] coeff = fitter.fit(obs.toList());
>
>// Printing out coefficients
>System.out.println("The coefficients are: " + coeff);
>
>} // END 'main'
> } // END class
>
> 
>
> Oscar
>
> Oscar Bastidas, Ph.D.
> Postdoctoral Research Associate
> University of Minnesota
>


RE: Apache Commons Math Linear Regression Question

2020-01-08 Thread John.E.Gregg
Just wrap with Arrays.toString():

System.out.println("The coefficients are: " + Arrays.toString(coeff));

You'll get this:

The coefficients are: [-1568.1599299988338, -3176.421076494, 
-1606.239988156]



> -Original Message-
> From: Oscar Bastidas 
> Sent: Wednesday, January 08, 2020 2:12 PM
> To: user@commons.apache.org
> Subject: Apache Commons Math Linear Regression Question
> 
> Hello,
> 
> Would someone please tell me how I am supposed to acquire the actual
> numeric coefficients for a linear regression using the PolynomialCurveFitter
> class?
> 
> Below is my code (it's supposed to be a simple example) and when I print out
> the variable that stores the coefficients, ("coeff" in the below
> example) what is printed to the command line is a strange code:
> *[D@1610302.*
> 
> This happens regardless of the order of the polynomial I request.
> 
> Would someone please help me with this?  Thanks.
> 
> *** CODE BELOW
> **
> 
> import java.util.*;
> import org.apache.commons.math3.fitting.PolynomialCurveFitter;
> import org.apache.commons.math3.fitting.*;
> 
> public class MathTester
> {
> public static void main(String[] args) {
> // Testing linear regression
> final WeightedObservedPoints obs = new WeightedObservedPoints();
> 
> // Acquiring data points
> obs.add(-1.00, 2.021170);
> obs.add(-0.99, 2.221135);
> obs.add(-0.98, 2.099852);
> 
>// Instantiate 2nd degree polynomial fitting
>final PolynomialCurveFitter fitter = 
> PolynomialCurveFitter.create(2);
> 
> // Retrieve fitted coefficients of the fitted data
> final double[] coeff = fitter.fit(obs.toList());
> 
>// Printing out coefficients
>System.out.println("The coefficients are: " + coeff);
> 
>} // END 'main'
> } // END class
> 
> **
> **
> 
> Oscar
> 
> Oscar Bastidas, Ph.D.
> Postdoctoral Research Associate
> University of Minnesota

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Apache Commons Math Linear Regression Question

2020-01-08 Thread Oscar Bastidas
Hello,

Would someone please tell me how I am supposed to acquire the actual
numeric coefficients for a linear regression using the
PolynomialCurveFitter class?

Below is my code (it's supposed to be a simple example) and when I print
out the variable that stores the coefficients, ("coeff" in the below
example) what is printed to the command line is a strange code:
*[D@1610302.*

This happens regardless of the order of the polynomial I request.

Would someone please help me with this?  Thanks.

*** CODE BELOW **

import java.util.*;
import org.apache.commons.math3.fitting.PolynomialCurveFitter;
import org.apache.commons.math3.fitting.*;

public class MathTester
{
public static void main(String[] args) {
// Testing linear regression
final WeightedObservedPoints obs = new WeightedObservedPoints();

// Acquiring data points
obs.add(-1.00, 2.021170);
obs.add(-0.99, 2.221135);
obs.add(-0.98, 2.099852);

   // Instantiate 2nd degree polynomial fitting
   final PolynomialCurveFitter fitter =
PolynomialCurveFitter.create(2);

// Retrieve fitted coefficients of the fitted data
final double[] coeff = fitter.fit(obs.toList());

   // Printing out coefficients
   System.out.println("The coefficients are: " + coeff);

   } // END 'main'
} // END class



Oscar

Oscar Bastidas, Ph.D.
Postdoctoral Research Associate
University of Minnesota


Re: [math] Question about constructing a PolyhedronsSet using B-rep (commons-math3 v3.6.1)

2019-09-23 Thread Gilles Sadowski
Hello.

Short answer: The "geometry" package of "Commons Math" will
be deprecated, as we currently work on a new component:
https://gitbox.apache.org/repos/asf?p=commons-geometry.git

There is no official release yet, but you should definitely test it.

Best regards,
Gilles

P.S. We seek help in order to release this component ASAP... ;-)

2019-09-23 9:12 UTC+02:00, Steven Fontaine :
> Hi, I have a (hopefully) simple question regarding constructing a
> PolyhedronsSet using the constructor PolyhedronsSet(List
> vertices, List facets, double tolerance). Currently I have the
> following code to construct a simple tetrahedron:
>
> List verts = Arrays.asList(new Vector3D(0, 0, 0), new Vector3D(0,
> 1, 1), new Vector3D(1, 1, 0), new Vector3D(1, 0, 1));
> List facets = Arrays.asList(new int[] {0, 3, 1}, new int[] {3, 2,
> 1}, new int[] {2, 1, 0}, new int[] {3, 2, 0});
> PolyhedronsSet set = new PolyhedronsSet(verts, facets, 1e-10);
>
> To the best of my knowledge, according to the documentation for this
> constructor, the previous code should be right. However, it obviously
> isn't. I'm getting the following error:
>
> org.apache.commons.math3.exception.MathIllegalArgumentException: facets
> orientation mismatch around edge joining points (0, 0, 0) and (1, 0, 1)
>
> at
> org.apache.commons.math3.geometry.euclidean.threed.PolyhedronsSet.successors(PolyhedronsSet.java:403)
> at
> org.apache.commons.math3.geometry.euclidean.threed.PolyhedronsSet.buildBoundary(PolyhedronsSet.java:274)
> at
> org.apache.commons.math3.geometry.euclidean.threed.PolyhedronsSet.(PolyhedronsSet.java:131)
> at ...
>
>
> So, my question is, what am I doing wrong? If it's something more complex
> than can easily be explained via email, feel free to link me to some
> articles which might help. (Preferably articles which someone with very
> limited experience with BSP trees and such could understand.)
>
> Thanks for your time. -Steven
>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[math] Question about constructing a PolyhedronsSet using B-rep (commons-math3 v3.6.1)

2019-09-23 Thread Steven Fontaine
Hi, I have a (hopefully) simple question regarding constructing a
PolyhedronsSet using the constructor PolyhedronsSet(List
vertices, List facets, double tolerance). Currently I have the
following code to construct a simple tetrahedron:

List verts = Arrays.asList(new Vector3D(0, 0, 0), new Vector3D(0,
1, 1), new Vector3D(1, 1, 0), new Vector3D(1, 0, 1));
List facets = Arrays.asList(new int[] {0, 3, 1}, new int[] {3, 2,
1}, new int[] {2, 1, 0}, new int[] {3, 2, 0});
PolyhedronsSet set = new PolyhedronsSet(verts, facets, 1e-10);

To the best of my knowledge, according to the documentation for this
constructor, the previous code should be right. However, it obviously
isn't. I'm getting the following error:

org.apache.commons.math3.exception.MathIllegalArgumentException: facets
orientation mismatch around edge joining points (0, 0, 0) and (1, 0, 1)

at
org.apache.commons.math3.geometry.euclidean.threed.PolyhedronsSet.successors(PolyhedronsSet.java:403)
at
org.apache.commons.math3.geometry.euclidean.threed.PolyhedronsSet.buildBoundary(PolyhedronsSet.java:274)
at
org.apache.commons.math3.geometry.euclidean.threed.PolyhedronsSet.(PolyhedronsSet.java:131)
at ...


So, my question is, what am I doing wrong? If it's something more complex
than can easily be explained via email, feel free to link me to some
articles which might help. (Preferably articles which someone with very
limited experience with BSP trees and such could understand.)

Thanks for your time. -Steven


Re: [MATH]Performance issue with SVD calculation for large matrices

2019-09-05 Thread Gilles Sadowski
Hi.

2019-09-05 12:04 UTC+02:00, Sudheer Kumar Gattu :
> Hi All,
>
>
> We use SingularValueDecomposition(RealMatrix realMatrix) , getSolver() in
> our project.
>
> For large matrices of size 925*161 , when these API's are used iteratively.
> It is taking so much time, Refer attached snapshot.

Attachment was probably stripped.
Anyways, I guess that it's the same as on the JIRA page.[1]
If so, it's not very telling.

>
> I have tried this with 3.3 and 3.6.1, both versions perform similarly.

Good to know.
Did you also check the development version?

>
> Is there any way to improve the performance of these API's.
>

Hard to say without a minimal working example.
Best would be to set up unit tests that replicate your usage of the
class, and provide answers to the following questions:
 * What kind of performance do you expect?  Did you compare
with other libraries?
 * Did you investigate how the performance varies with matrix size?
 * Do you observe the same slow-down with other decomposition
classes?
 * Is the behaviour similar with square matrices?
 * Which matrix implementation do you use?

Regards,
Gilles

[1] https://issues.apache.org/jira/browse/MATH-1497

> Regards
> Sudheer Gattu
>

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] Apache Commons Math Median performance

2019-05-29 Thread Marco Neumann
Hi Gilles,

On Wed, May 29, 2019 at 11:18 PM Gilles Sadowski 
wrote:

> Hello.
>
> Le mer. 29 mai 2019 à 12:24, Marco Neumann  a
> écrit :
> >
> > I am evaluating the use of Apache Math Commons Median for the querying of
> > large data sets in another Apache project called Apache Jena.
> >
> > In my preliminary performance tests I was surprised to find that a simple
> > implementation of a median function with Arrays.sort() and a programmatic
> > selection of the median value yields much faster results
> > than Median().evaluate() or DescriptiveStatistics.getPercentile(50).
>
> :-(
>

no worries, I still consider Apache Commons Math still a very valuable
effort.


>
> > Since we only use this function for  Arrays of confirmed numbers
>
> What is a "confirmed number"?
>

should probably read more like programmatically confirmed "numbers" rather
than "confirmed number". I am not dealing with NaN and infinite values in
the sort at the moment.


> > is there a
> > particular benefit in using Apache Commons Math for this task or are we
> > better advised to use our own implementation here?
>
> There is ongoing work to refactor the "o.a.c.m.stat.descriptive" package
> of "Commons Math".  The new code will be in "Commons Statistics".[1]
> Your observation is an interesting data point for this task; could you
> please
> file a report in JIRA[2] and/or mention on the "dev" ML?
>

I can certainly file a report and will do so tomorrow. I am looking forward
to the results of the work on the new stats package!

Best,
Marco

Thanks,
> Gilles
>
> [1] http://commons.apache.org/proper/commons-statistics/
> [2]
> https://issues.apache.org/jira/projects/STATISTICS/issues/STATISTICS-15?filter=allopenissues
>
> >
> > Thank You
>
> -
> To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
> For additional commands, e-mail: user-h...@commons.apache.org
>
>

-- 


---
Marco Neumann
KONA


Re: [math] Apache Commons Math Median performance

2019-05-29 Thread Marco Neumann
Thank you for the feedback and confirmation Eric. I am looking forward to
the new statistics libraries. I am glad that the work continuous on
these libraries and that they will be available to the community to improve
and enhance our projects.



On Wed, May 29, 2019 at 10:56 PM Eric Barnhill 
wrote:

> Hi Marco,
>
> Thanks a lot for this feedback. I am one of the contribs building out the
> new commons-numbers release which will replace much of commons-math
> including the statistics libraries.
>
> I took a look at the commons-math code for Median. Based on my reading of
> it I am not surprised by what you report. Median just invokes Percentile.
> Percentile does seem to have some overhead, for example lots of range and
> null checking. As as one off Median is probably not as efficient as a
> simple sort. However it can store data and recalculate percentiles, and
> there it might be efficient to use, as well as having flexibility in how it
> is implemented.
>
> I quite agree that most users simply want to call median() on their array
> and expect at least as efficient an algorithm as they could hand code
> themselves. For medians as we all learned in CS 101 class, for a guaranteed
> result one cannot improve on O(n log n) time, just sorting like you
> mentioned, however a method can deliver O(log n) time on average, but with
> a potential worst case of O(n^2), and the user could be given this choice
> of implementation.
>
> The fact that the commons-math contributors did not seem aware of this
> finding shows some of the occasional weaknesses I am finding as we design a
> new, fleeter library in commons-numbers. We are redesigning the statistics
> libraries over this summer with support from Google Summer of Code, so I
> will see what I can do. Without feedback like yours we would not find these
> points of improvement, so thanks.
>
> On Wed, May 29, 2019 at 3:24 AM Marco Neumann 
> wrote:
>
> > I am evaluating the use of Apache Math Commons Median for the querying of
> > large data sets in another Apache project called Apache Jena.
> >
> > In my preliminary performance tests I was surprised to find that a simple
> > implementation of a median function with Arrays.sort() and a programmatic
> > selection of the median value yields much faster results
> > than Median().evaluate() or DescriptiveStatistics.getPercentile(50).
> >
> > Since we only use this function for  Arrays of confirmed numbers is
> there a
> > particular benefit in using Apache Commons Math for this task or are we
> > better advised to use our own implementation here?
> >
> > Thank You
> >
>


-- 


---
Marco Neumann
KONA


Re: [math] Apache Commons Math Median performance

2019-05-29 Thread Gilles Sadowski
Hello.

Le mer. 29 mai 2019 à 12:24, Marco Neumann  a écrit :
>
> I am evaluating the use of Apache Math Commons Median for the querying of
> large data sets in another Apache project called Apache Jena.
>
> In my preliminary performance tests I was surprised to find that a simple
> implementation of a median function with Arrays.sort() and a programmatic
> selection of the median value yields much faster results
> than Median().evaluate() or DescriptiveStatistics.getPercentile(50).

:-(

> Since we only use this function for  Arrays of confirmed numbers

What is a "confirmed number"?

> is there a
> particular benefit in using Apache Commons Math for this task or are we
> better advised to use our own implementation here?

There is ongoing work to refactor the "o.a.c.m.stat.descriptive" package
of "Commons Math".  The new code will be in "Commons Statistics".[1]
Your observation is an interesting data point for this task; could you please
file a report in JIRA[2] and/or mention on the "dev" ML?

Thanks,
Gilles

[1] http://commons.apache.org/proper/commons-statistics/
[2] 
https://issues.apache.org/jira/projects/STATISTICS/issues/STATISTICS-15?filter=allopenissues

>
> Thank You

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] Apache Commons Math Median performance

2019-05-29 Thread Eric Barnhill
Hi Marco,

Thanks a lot for this feedback. I am one of the contribs building out the
new commons-numbers release which will replace much of commons-math
including the statistics libraries.

I took a look at the commons-math code for Median. Based on my reading of
it I am not surprised by what you report. Median just invokes Percentile.
Percentile does seem to have some overhead, for example lots of range and
null checking. As as one off Median is probably not as efficient as a
simple sort. However it can store data and recalculate percentiles, and
there it might be efficient to use, as well as having flexibility in how it
is implemented.

I quite agree that most users simply want to call median() on their array
and expect at least as efficient an algorithm as they could hand code
themselves. For medians as we all learned in CS 101 class, for a guaranteed
result one cannot improve on O(n log n) time, just sorting like you
mentioned, however a method can deliver O(log n) time on average, but with
a potential worst case of O(n^2), and the user could be given this choice
of implementation.

The fact that the commons-math contributors did not seem aware of this
finding shows some of the occasional weaknesses I am finding as we design a
new, fleeter library in commons-numbers. We are redesigning the statistics
libraries over this summer with support from Google Summer of Code, so I
will see what I can do. Without feedback like yours we would not find these
points of improvement, so thanks.

On Wed, May 29, 2019 at 3:24 AM Marco Neumann 
wrote:

> I am evaluating the use of Apache Math Commons Median for the querying of
> large data sets in another Apache project called Apache Jena.
>
> In my preliminary performance tests I was surprised to find that a simple
> implementation of a median function with Arrays.sort() and a programmatic
> selection of the median value yields much faster results
> than Median().evaluate() or DescriptiveStatistics.getPercentile(50).
>
> Since we only use this function for  Arrays of confirmed numbers is there a
> particular benefit in using Apache Commons Math for this task or are we
> better advised to use our own implementation here?
>
> Thank You
>


[math] Apache Commons Math Median performance

2019-05-29 Thread Marco Neumann
I am evaluating the use of Apache Math Commons Median for the querying of
large data sets in another Apache project called Apache Jena.

In my preliminary performance tests I was surprised to find that a simple
implementation of a median function with Arrays.sort() and a programmatic
selection of the median value yields much faster results
than Median().evaluate() or DescriptiveStatistics.getPercentile(50).

Since we only use this function for  Arrays of confirmed numbers is there a
particular benefit in using Apache Commons Math for this task or are we
better advised to use our own implementation here?

Thank You


Re: [math] Vector math question

2019-05-28 Thread Gilles Sadowski
Hi.

Le mar. 28 mai 2019 à 10:31, LE TELLIER Romain 211391
 a écrit :
>
> Hello,
>
> Yes, Apache Commons Maths has what you need. Start by having a look at the 
> org.apache.commons.math3.geometry.euclidean.threed package and the Vector3D 
> class
> https://commons.apache.org/proper/commons-math/userguide/geometry.html

This Javadoc page may be more to the point:

https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/geometry/euclidean/threed/Vector3D.html

> By the way, I have understand that this geometry package will be supplanted 
> by the apache commons geometry 
> (https://commons.apache.org/proper/commons-geometry/)

Indeed.  The new class, equivalent to the above is:

https://gitbox.apache.org/repos/asf?p=commons-geometry.git;a=blob;f=commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java

>  but there is no release yet.

True but the refactoring work is ongoing (see posts on the "dev" ML),
and reviewers are most welcome.

> Does anybody knows what is the associated schedule?

ASAP. ;-)
[The more people express an interest, the greater the motivation...]

And we are looking for actual use-cases (for integration testing and
in order to populate a "Get Started" userguide).

Also, the new "Commons Geometry" component will depend on the
new "Commons Numbers" component (that is as yet unreleased too).
Reviewers/contributors for this "core" dependency are also most
wanted in order to iron out the pending issues:

https://issues.apache.org/jira/projects/NUMBERS/issues/NUMBERS-74?filter=allopenissues

Please chime in on the "dev" ML if you'd like to help.

Thanks,
Gilles

>
> Best regards,
> Romain
>
> -Message d'origine-
> De : Oscar Bastidas [mailto:obast...@umn.edu]
> Envoyé : mardi 28 mai 2019 09:38
> À : user@commons.apache.org
> Objet : [math] Vector math question
>
> Hello,
>
> I have some calculations that specifically involve:
>
> 1) calculating vectors from 3-dimensional x, y, z points in Euclidean space
>
> 2) performing dot products with the aforementioned vectors
>
> 3) finding vector length
>
> Would someone please tell me if Apache Commons Math has tools to calculate 
> these quantities, and if so, what is the complete import statements to summon 
> these classes and their methods?  Thanks.
>
> Oscar
>
> Oscar Bastidas, Ph.D.
> Postdoctoral Research Associate
> University of Minnesota

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] Vector math question

2019-05-28 Thread sebb
On Tue, 28 May 2019 at 09:31, LE TELLIER Romain 211391
 wrote:
>
> Hello,
>
> Yes, Apache Commons Maths has what you need. Start by having a look at the 
> org.apache.commons.math3.geometry.euclidean.threed package and the Vector3D 
> class
> https://commons.apache.org/proper/commons-math/userguide/geometry.html
>
> By the way, I have understand that this geometry package will be supplanted 
> by the apache commons geometry 
> (https://commons.apache.org/proper/commons-geometry/)  but there is no 
> release yet.
> Does anybody knows what is the associated schedule?

Please start a new thread for a new question.

> Best regards,
> Romain
>
> -Message d'origine-
> De : Oscar Bastidas [mailto:obast...@umn.edu]
> Envoyé : mardi 28 mai 2019 09:38
> À : user@commons.apache.org
> Objet : [math] Vector math question
>
> Hello,
>
> I have some calculations that specifically involve:
>
> 1) calculating vectors from 3-dimensional x, y, z points in Euclidean space
>
> 2) performing dot products with the aforementioned vectors
>
> 3) finding vector length
>
> Would someone please tell me if Apache Commons Math has tools to calculate 
> these quantities, and if so, what is the complete import statements to summon 
> these classes and their methods?  Thanks.
>
> Oscar
>
> Oscar Bastidas, Ph.D.
> Postdoctoral Research Associate
> University of Minnesota

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



RE: [math] Vector math question

2019-05-28 Thread LE TELLIER Romain 211391
Hello,

Yes, Apache Commons Maths has what you need. Start by having a look at the 
org.apache.commons.math3.geometry.euclidean.threed package and the Vector3D 
class
https://commons.apache.org/proper/commons-math/userguide/geometry.html 

By the way, I have understand that this geometry package will be supplanted by 
the apache commons geometry 
(https://commons.apache.org/proper/commons-geometry/)  but there is no release 
yet.
Does anybody knows what is the associated schedule?

Best regards,
Romain

-Message d'origine-
De : Oscar Bastidas [mailto:obast...@umn.edu] 
Envoyé : mardi 28 mai 2019 09:38
À : user@commons.apache.org
Objet : [math] Vector math question

Hello,

I have some calculations that specifically involve:

1) calculating vectors from 3-dimensional x, y, z points in Euclidean space

2) performing dot products with the aforementioned vectors

3) finding vector length

Would someone please tell me if Apache Commons Math has tools to calculate 
these quantities, and if so, what is the complete import statements to summon 
these classes and their methods?  Thanks.

Oscar

Oscar Bastidas, Ph.D.
Postdoctoral Research Associate
University of Minnesota


[math] Vector math question

2019-05-28 Thread Oscar Bastidas
Hello,

I have some calculations that specifically involve:

1) calculating vectors from 3-dimensional x, y, z points in Euclidean space

2) performing dot products with the aforementioned vectors

3) finding vector length

Would someone please tell me if Apache Commons Math has tools to calculate
these quantities, and if so, what is the complete import statements to
summon these classes and their methods?  Thanks.

Oscar

Oscar Bastidas, Ph.D.
Postdoctoral Research Associate
University of Minnesota


Re: [math] - Math on Android?

2019-05-21 Thread Gilles Sadowski
Hello.

Le mar. 21 mai 2019 à 12:42, Oscar Bastidas  a écrit :
>
> Hello,
>
> Can someone please tell me if the Math library will work on Android Java,
> or is this just restricted to "regular" Java?  Thanks.

"Commons Math" has been partly superseded by new components:
 * "Commons RNG"
 * "Commons Numbers"
 * "Commons Geometry"
 * "Commons Statistics"

What functionality are you looking for?

We are certainly interested to know whether there is anything that
prevents using those components for developing applications on
some OS.

Regards,
Gilles

>
> Oscar
>
> Oscar Bastidas, Ph.D.
> Postdoctoral Research Associate
> University of Minnesota

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [math] - Math on Android?

2019-05-21 Thread Axel
 Hi

Search for example for tag commons-math

   - https://github.com/mkulesh/microMathematics
   - https://github.com/topics/commons-math

Similar like the commons-math library the Hipparchus fork
https://github.com/Hipparchus-Math/hipparchus is also usable under Android.

See the symbolic math projects which focus on Android  and use Hipparchus:

   - For Android Java 7:
   https://github.com/tranleduy2000/symja_android_library
   - forked from Java 8 Symja project:
   https://github.com/axkr/symja_android_library


On Tue, May 21, 2019 at 12:42 PM Oscar Bastidas  wrote:

> Hello,
>
> Can someone please tell me if the Math library will work on Android Java,
> or is this just restricted to "regular" Java?  Thanks.
>
> Oscar
>
> Oscar Bastidas, Ph.D.
> Postdoctoral Research Associate
> University of Minnesota
>


-- 
Axel Kramer


[math] - Math on Android?

2019-05-21 Thread Oscar Bastidas
Hello,

Can someone please tell me if the Math library will work on Android Java,
or is this just restricted to "regular" Java?  Thanks.

Oscar

Oscar Bastidas, Ph.D.
Postdoctoral Research Associate
University of Minnesota


  1   2   3   4   5   6   7   8   9   10   >