Skip to content

add support for individual probabilities in choice #211

@gdementen

Description

@gdementen
  current:
      test2:
          - threshold1: age / 200
          - threshold2: threshold1 + 0.1 + 0.3 * work
          - u: uniform()
          - event: if(u < threshold1, 1,
                       if(u < threshold2, 2,
                          3))
          - show(groupby(age, work, event))

  desired:
      test2:
          - prob1: age / 200
          - prob2: 0.1 + 0.3 * work
          # list of arrays
          - event: choice([1, 2, 3], [prob1, prob2, 1 - prob1 - prob2])
          # using a 2d array would make it easier in many cases (num_persons * num_choices)
          # e.g.
          # ARRAY is a 4d array, so the result is a 2d array  (num_persons * num_choices)
          - agegroup_idx: trunc(agegroup / 5)
          - event: choice([1, 2, 3], ARRAY[gender * 1, workstate, agegroup_idx])
          - show(groupby(age, work, event))

#117, would make this even nicer.

  desired:
      test2:
          # using .points API as if we had LArray under the hood.
          - event: choice([1, 2, 3], ARRAY.points[gender, workstate, agegroup])

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions