Skip to content

recursiveMeanVar returns zero #9

@Shar-pei-bear

Description

@Shar-pei-bear

The recursiveMeanVar function in utils.py would return zero if input l is interger. Suggest change the following code

muPlus = l / n * mu + m / n * np.mean(x)
if n > 1:
    sigma2Plus = 1 / (n - 1) * ((l - 1) * sigma2 + (m - 1) * np.var(x) + l * (mu - muPlus) ** 2 + m * (np.mean(x) - muPlus) ** 2) 

to

muPlus = mu * l / n + np.mean(x) * m / n
if n > 1:
    sigma2Plus = ((l - 1.0)*sigma2 + (m - 1.0)*np.var(x) + l*(mu - muPlus)**2 + m*(np.mean(x) - muPlus)**2) / (n -1.0)

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