Skip to content

Statistics.cor throws domain error with specific data #32264

Closed
@manuelVo

Description

@manuelVo

This code causes Statistics.cor to throw a DomainError:
https://gist.github.com/manuelVo/dce2a962bbe6f5cb6181c8f55f3e1dbf

The data itself should be fine since the Error doesn't occur if y is a Vector{Int16}.

The thrown exception is the following:

ERROR: DomainError with -112.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
 [1] sqrt at ./math.jl:492 [inlined]
 [2] sqrt at ./math.jl:518 [inlined]
 [3] corm(::Array{UInt8,1}, ::Float64, ::Array{Int8,1}, ::Float64) at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/Statistics/src/Statistics.jl:592
 [4] cor at /build/julia/src/julia-1.1.1/usr/share/julia/stdlib/v1.1/Statistics/src/Statistics.jl:629 [inlined]
 [5] a() at ./REPL[13]:4
 [6] top-level scope at none:0

The output of versioninfo() is

Julia Version 1.1.1
Commit 55e36cc308 (2019-05-16 04:10 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

Metadata

Metadata

Assignees

No one assigned

    Labels

    statisticsThe Statistics stdlib modulestdlibJulia's standard library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions