Skip to content

Overhead for autoregressive evaluation #147

@ArnoStrouwen

Description

@ArnoStrouwen

I am using the trees for representing autoregressive models.
This means that the evaluation of the tree cannot be vectorized easily, since the input at an iteration depends on the output of the previous iteration.

The overhead for this seems to be quite high:

function autoregressive_sym()
    n = 1000 
    res = zeros(n)
    res[1] = 1.0
    for i in 2:n
        res[i] = sym_mul([res[i-1],1.01])
    end
    return res
end
@btime autoregressive_sym() # 109.630 μs

function autoregressive_sym2(sym_mul)
    n = 1000 
    res = zeros(n)
    res[1] = 1.0
    for i in 2:n
        res[i] = sym_mul([res[i-1],1.01])
    end
    return res
end
@btime autoregressive_sym2(sym_mul) # 97.618 μs

function autoregressive()
    n = 1000 
    res = zeros(n)
    res[1] = 1.0
    for i in 2:n
        res[i] = res[i-1]*1.01
    end
    return res
end
@btime autoregressive() # 896.484 ns

Any advice on how to speed this up, or what kind of alternative datastructure would be appropriate for my case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions