Skip to content

FREQUENCY not working as expected #43

Open

Description

@mjp0

FREQUENCY() is giving me weird results. I feed in 5 numbers as data, i.e. [ 4, 5, 5, 7, 10 ] and my bins are [ [ 4, 6 ], [ 6, 8 ], [ 8, 10 ], [ 10, 12 ], [ 12, 14 ] ] and I get back [ 1, 2, 0, 1, 0, 1, 0, 0, 0, 0, 0 ].

So with 5 items and with 5 buckets I get 11 values back. This is not how FREQUENCY works in Excel.

Any ideas?

edit: quick fix with lodash (note that if value is same as upper bin value, it will be moved to the next bin):

var frequencies = []
    _.each(bins, b => {
        var frequency = 0
        _.each(values, v => {
            if(b[0] <= v  && b[1] > v) {
                frequency++
            }
        })
        frequencies.push({bin: b, frequency: frequency})
    })

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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