Git Product home page Git Product logo

Comments (5)

DominiqueMakowski avatar DominiqueMakowski commented on July 17, 2024

On a user-experience note:
The fact that one needs to pass a data object to the model formatted differently (as a tuple of individual tuples) than the data object expected by the SSM distributions (as a tuple of vectors) makes it feel a bit clunky.

I wonder if it would not be easier to (additionally) allow for an independent specification of choice and rt in the distributions. For instance, add the rt=none keyword arguments to LBA(data; **kwargs), and in case data is a vector (i.e., someone just passed choice alone) & rt != none, we just re-format data = (choice=data, rt=rt) as a first step in the function.

This would give some flexibility and hopefully make the practical usage smoother (also it would remove the need to do extra data transformation to make a vector of tuples).

An alternative version would be to also define

LBA(choice::Vector, rt::Vector; *kwargs)
    LBA((choice=choice, rt=rt), ...)

This would probably be more elegant than having an optional keyword argument

from sequentialsamplingmodels.jl.

DominiqueMakowski avatar DominiqueMakowski commented on July 17, 2024

Wait no actually no this wouldn't work since we need something that can be indexed in the for i in n loop of Turing... Okay nevermind then

EDIT: (and sorry for the spam, I wrote too quickly before giving a good thought) unless we allow data to be a matrix with 2 columns (one for choice and for RT) (in which case it would also return a matrix) . We could then do X[i, :] ~ LBA(...)

from sequentialsamplingmodels.jl.

itsdfish avatar itsdfish commented on July 17, 2024

@DominiqueMakowski, no problem. These things can be a bit tricky. The convention I adopted with NamedTuples follows the same convention used throughout Distributions.jl. For example, rand(Normal()) returns a scalar while rand(Normal(), 1) returns a vector. In this package, we return a NamedTuple of scalars for rand(LBA()) and a NamedTuple of vectors for rand(LBA(), 1).

You are right that the lack of indexing in the case of vectors is inconvenient. I did consider using a 2D array of floats instead, but the potential problem is that the choice indices are actually integers, and are often used for logical indexing (e.g. [rt[choice .==1]). Unfortunately, logical indexing could potentially fail due to float point error. I'm not sure how likely it would be in the scope of these models, but it could potentially create a silent bug which could invalidate someone's analyses. Depending on what you are doing, destructuring the NamedTuple can convenient, e.g., choice,rt = rand(LBA(), n) . As shown the doc strings, this works with broadcasting. Although the system is not perfect, I think some degree of pre-processing of data is almost unavoidable.

By the way, if you want a simpler way to generate a vector of NamedTuples, you can use a list comprehension or map:

n_obs =50
data1 = [rand(LBA(ν=[3.0, 2.0], A=0.8, k=0.2, τ=0.3)) for _ ∈ 1:n_obs]
data2 = [rand(LBA(ν=ν=[1.0, 1.5], A=0.8, k=0.2, τ=0.3)) for _ ∈ 1:n_obs]
data = vcat(data1, data2)

from sequentialsamplingmodels.jl.

DominiqueMakowski avatar DominiqueMakowski commented on July 17, 2024

I think we can close this

from sequentialsamplingmodels.jl.

itsdfish avatar itsdfish commented on July 17, 2024

I think there still might be a bug in Turing or Bijectors. We circumvented the problem by writing better code, but it seemed to be performing an unnecessary transformation. When I have time, I still raise the issue with devs at Turing.

from sequentialsamplingmodels.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.