1 Jul 2008 06:49

### gsl_stats_sd_m ???

```Dear bug-gsl

Hope you are all fine.

This is Mehdi Stegamatian. I am student of "Artificial Intelligence" in
Shiraz University. It is about 6 mounts that I am using GSL. I found
something which appeared to me as a bug. GSL calculates standard deviation
of single number equal to nan! Which sounds a bit vired to me. I am not a
statistician but according to my knowledge the value is zero.

I included the sample code? Could you tell me what is going on?

Best Wishes,
Mehdi

///////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <gsl/gsl_statistics.h>
#include <gsl/gsl_randist.h>

int main()
{
double darr[1][20];
for (int i = 0; i < 20; i++)
{
for (int j = 0; j < 1; j++)
{
darr[j][i] = i+j;
}
}
```

1 Jul 2008 13:42

### Re: gsl_stats_sd_m ???

```At Tue, 1 Jul 2008 09:19:33 +0430 (IRDT),
Mehdi Esteghamatian wrote:
> This is Mehdi Stegamatian. I am student of "Artificial Intelligence" in
> Shiraz University. It is about 6 mounts that I am using GSL. I found
> something which appeared to me as a bug. GSL calculates standard deviation
> of single number equal to nan! Which sounds a bit vired to me. I am not a
> statistician but according to my knowledge the value is zero.
> I included the sample code? Could you tell me what is going on?

Hello,

We calculate the variance with a factor of 1/(N-1) to give an
unbiased estimate of the variance.

See the "Statistics" chapter of the GSL Reference manual for the
complete definitions of the different functions.  If you want to
compute it with 1/N there are functions which do that.

--

--
Brian Gough

GNU Scientific Library -
http://www.gnu.org/software/gsl/
```
18 Jul 2008 13:14

### Re: [Help-gsl] Underflow in gsl_sf_bessel_Jn_array

```>> Please can somebody advise on using gsl_sf_bessel_Jn_array for
>> small z?
>>
>> I need to generate Bessel functions up to some n_max (of order 50)
>> for
>> arbitrary z. I run into problems for small z because the function
>> uses
>> a downward recurrence to populate the array, and suffers underflow
>> for
>> large n.
>
> Could you send a small example program showing the problem to
> bug-gsl <at> gnu.org for reference.  Thanks.

The following is sufficient to demonstrate the issue.
double besselArray[51];
double rho = 1e-6;
gsl_sf_bessel_Jn_array(0, 50, rho, besselArray);

The problem is that the array is populated by downward recurrence, but
J_51 and J_50 are way smaller than DBL_MIN, resulting in an error
within the GSL library:
gsl: gamma.c:1454: ERROR: underflow
Default GSL error handler invoked.

Because of the downward recurrence, it is _not_ sufficient just to
ignore the error in my own code: as written at the moment, _none_ of
the array entries will be correctly populated if this error condition
occurs.

```

18 Jul 2008 19:50

### cross-compiling bug

```I am trying to install the library in cygwin for cross compiling. however after I configure it I get errors
trying to make it.

I configure with:

./configure CC=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu-gcc
CPP=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu-cpp
--exec-prefx=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu/ --disable-shared
--build-=i686-pc-cygwin --host=arm-unknown-linux-gnu

and here is the output:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets \$(MAKE)... yes
checking for arm-unknown-linux-gnu-strip... no
checking for strip... strip
configure: WARNING: In the future, Autoconf will not detect cross-tools
whose name does not start with the host triplet.  If you think this
configuration is useful to you, please write to autoconf <at> gnu.org.
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make sets \$(MAKE)... (cached) yes
checking build system type... i686-pc-cygwin
checking host system type... arm-unknown-linux-gnu
checking for arm-unknown-linux-gnu-gcc... /opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
```

23 Jul 2008 08:50

### Re: cross-compiling bug

```At Fri, 18 Jul 2008 13:50:33 -0400,
Tim Rambo wrote:
>
> I am trying to install the library in cygwin for cross compiling. however after I configure it I get errors
trying to make it.
>
> I configure with:
>
> ./configure CC=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu-gcc
CPP=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu-cpp
--exec-prefx=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu/ --disable-shared
--build-=i686-pc-cygwin --host=arm-unknown-linux-gnu
>  .....
>
> Is this a bug or am I just doing this wrong?

Thanks for the bug report.  The configure script says

checking for strdup... no

This causes a replacement for strdup to be included, and it is the
compilation of that file which gives errors.

I imagine your system does have strdup() -- if you can figure out why
it is not being detected, and fix that problem, it will avoid any
attempt to compile the extra strdup.c file. (Perhaps it's a macro?)

Otherwise you'll need to edit the utils/Makefile to remove the
reference to strdup.c

```

23 Jul 2008 09:08

### Re: [Help-gsl] Underflow in gsl_sf_bessel_Jn_array

```At Fri, 18 Jul 2008 12:14:10 +0100,
Jonny Taylor wrote:
> The following is sufficient to demonstrate the issue.
> 	double besselArray[51];
> 	double rho = 1e-6;
> 	gsl_sf_bessel_Jn_array(0, 50, rho, besselArray);
>
> The problem is that the array is populated by downward recurrence, but
> J_51 and J_50 are way smaller than DBL_MIN, resulting in an error
> within the GSL library:
> gsl: gamma.c:1454: ERROR: underflow
> Default GSL error handler invoked.

I looked at the code and there's no easy way to add support for
scaling the results in GSL itself at the moment.  I would recommend
that you make an estimate of n_max using the asymptotic formula for Jn.

--

--
Brian Gough

GNU Scientific Library -
http://www.gnu.org/software/gsl/
```
23 Jul 2008 13:57

### Re: cross-compiling bug

```Thanks! I actually got the code to compile by removing the -O2 compile flag  with the configuration option
CPPFLAGS="-g". Also, there is an error when making libgslsiman. This is fixed by editing the compile
flags in the siman makefile to include a -lm for the math library.

>>> Brian Gough <bjg <at> gnu.org> 7/23/2008 2:50 AM >>>
At Fri, 18 Jul 2008 13:50:33 -0400,
Tim Rambo wrote:
>
> I am trying to install the library in cygwin for cross compiling. however after I configure it I get errors
trying to make it.
>
> I configure with:
>
> ./configure CC=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu-gcc
CPP=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu-cpp
--exec-prefx=/opt/crosstool/gcc-3.3.4-glibc-2.3.2/arm-unknown-linux-gnu/ --disable-shared
--build-=i686-pc-cygwin --host=arm-unknown-linux-gnu
>  .....
>
> Is this a bug or am I just doing this wrong?

Thanks for the bug report.  The configure script says

checking for strdup... no

This causes a replacement for strdup to be included, and it is the
compilation of that file which gives errors.

I imagine your system does have strdup() -- if you can figure out why
it is not being detected, and fix that problem, it will avoid any
```

23 Jul 2008 17:39

### Re: cross-compiling bug

```At Wed, 23 Jul 2008 07:57:56 -0400,
Tim Rambo wrote:
>
> Thanks! I actually got the code to compile by removing the -O2
> compile flag with the configuration option CPPFLAGS="-g". Also,
> there is an error when making libgslsiman. This is fixed by editing
> the compile flags in the siman makefile to include a -lm for the
> math library.

That's been reported a couple of times but I've never been able to
figure out why it happens for siman/ -- the other directories use math
library functions as well but they don't seem to give any problems.
If you can find out why please let me know.

--

--
Brian Gough

GNU Scientific Library -
http://www.gnu.org/software/gsl/
```
28 Jul 2008 16:24

### offline for a while

```I'm moving office later this week so I won't be able to answer any
emails for a while.
```

Gmane