id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type
1396969695,I_kwDOAMm_X85TRBDf,7128,`rolling().sum()` is numerically unstable,19997801,closed,0,,,4,2022-10-04T23:39:31Z,2022-11-30T01:43:26Z,2022-11-30T01:43:26Z,NONE,,,,"### What happened?

On an input array like
```mydata.values[0,0,:]
array([0.        , 0.        , 0.        , 0.57392103, 0.57392103,
       0.57392103, 0.57392103, 0.57392103, 0.57392103, 0.57392103,
       0.57392103, 0.57392103, 0.        , 0.57392103, 0.57392103,
       0.57392103, 0.57392103, 0.57392103, 0.57392103, 2.29551022,
       2.29551022, 2.29551022, 2.29551022, 2.29551022, 2.29551022,
       2.29551022, 2.29551022, 2.29551022, 2.29551022, 2.29551022,
       2.29551022, 2.29551022, 2.29551022, 0.57383408, 0.57383408,
       0.57383408, 0.57383408, 0.57383408, 0.57383408, 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ,
       0.        , 0.        , 0.        , 0.        , 0.        ])
```

that has all positive values, and then zeros, computing the rolling sum (or mean) leads to negative values
```
mydata.rolling(t=3, min_periods=1).sum().values[0,0,:]
array([-3.33066907e-14, -3.33066907e-14, -3.33066907e-14,  5.73921029e-01,                                                                                                                                                                                                                     
        2.14784206e+00,  1.72176309e+00,  1.72176309e+00,  1.72176309e+00,                                                                                                                                                                                                                     
        1.72176309e+00,  1.72176309e+00,  1.72176309e+00,  1.72176309e+00,                                                                                                                                                                                                                     
        1.14784206e+00,  1.14784206e+00,  1.14784206e+00,  1.72176309e+00,                                                                                                                                                                                                                     
        1.72176309e+00,  1.72176309e+00,  1.72176309e+00,  3.44335228e+00,
        5.16494146e+00,  6.88653065e+00,  6.88653065e+00,  6.88653065e+00,
        6.88653065e+00,  6.88653065e+00,  6.88653065e+00,  6.88653065e+00,
        6.88653065e+00,  6.88653065e+00,  6.88653065e+00,  6.88653065e+00,
        6.88653065e+00,  5.16485452e+00,  3.44317838e+00,  1.72150224e+00,
        1.72150224e+00,  1.72150224e+00,  1.72150224e+00,  1.14766816e+00,
        5.73834081e-01, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14,
       -3.35287353e-14, -3.35287353e-14, -3.35287353e-14, -3.35287353e-14])
```

Both arrays have dtype = float64.

The issue aggravates as the rolling window increases.

### What did you expect to happen?

the rolling calculation could be more numerically precise by keeping track for instance of the Kahan compensation term.
https://en.wikipedia.org/wiki/Kahan_summation_algorithm




### MVCE confirmation

- [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [X] Complete example — the example is self-contained, including all data and the text of any traceback.
- [X] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [X ] New issue — a search of GitHub Issues suggests this is not a duplicate.

### Environment

this is reproducible across xarray versions, but mine is 2022.09.0.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7128/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue