semvec/pypi-packages huggingface dataset:
CRPS 2.0.4
A package to compute the Continuous Ranked Probability Score (CRPS), the Fair-CRPS, and the Adjusted-CRPS. Read the documentation at https://github.com/gouthamnaveen/CRPS
License: Apache License 2.0
Keywords: crps,continuous ranked probability score,fair crps,adjusted crps,proper score,probability score,ensemble forecast,python

# Documentation  

A package to compute the continuous ranked probability score (crps) (Matheson and Winkler, 1976; Hersbach, 2000), the fair-crps (fcrps) (Ferro et al., 2008), and the adjusted-crps (acrps) (Ferro et al., 2008) given an ensemble prediction and an observation.
    
The CRPS is a negatively oriented score that is used to compare the empirical distribution of an ensemble prediction to a scalar observation. 

Read documentation at [https://github.com/gouthamnaveen/CRPS](https://github.com/gouthamnaveen/CRPS)

_References_:

[1] Matheson, J. E. & Winkler, R. L. Scoring Rules for Continuous Probability Distributions. Management Science 22, 1087–1096 (1976).

[2] Hersbach, H. Decomposition of the Continuous Ranked Probability Score for Ensemble Prediction Systems. Wea. Forecasting 15, 559–570 (2000).

[3] Ferro, C. A. T., Richardson, D. S. & Weigel, A. P. On the effect of ensemble size on the discrete and continuous ranked probability scores. Meteorological Applications 15, 19–24 (2008).

## _Installation:_

```sh
pip install CRPS
```

## _Parameters:_

**ensemble_members**: numpy.ndarray

The predicted ensemble members. They will be sorted in ascending order automatically.

Ex: np.array([2.1,3.5,4.7,1.2,1.3,5.2,5.3,4.2,3.1,1.7])

**observation**: float

The observed scalar.

Ex: 5.4
    
**adjusted_ensemble_size**: int, optional

The size the ensemble needs to be adjusted to before computing the Adjusted Continuous Ranked Probability Score. The default is 200. 

_Note_: The crps becomes equal to acrps when adjusted_ensemble_size equals the length of the ensemble_members.

## _Method(s):_

**compute()**:

Computes the continuous ranked probability score (crps), the fair-crps (fcrps), and the adjusted-crps (acrps).

_Returns_:

crps,fcrps,acrps

## _Attributes:_
    
**crps**: Continuous Ranked Probability Score

It is the integral of the squared difference between the CDF of the forecast ensemble and the observation.

![crps](crps.jpg)

**fcrps**: Fair-Continuous Ranked Probability Score

It is the crps computed assuming an infinite ensemble size.

![fcrps](fcrps.jpg)

where m is the current ensemble size (i.e., len(ensemble_members))

**acrps**: Adjusted-Continuous Ranked Probability Score

It is the crps computed assuming an ensemble size of M.

![acrps](acrps.jpg)

where M is the adjusted_ensemble_size

## _Demonstration:_

```sh
import numpy as np
import CRPS.CRPS as pscore
```

Example - 1:
```sh
In [1]: pscore(np.arange(1,5),3.5).compute()
Out[1]: (0.625, 0.4166666666666667, 0.42083333333333334)
```

Example - 2:
```sh
In [2]: crps,fcrps,acrps = pscore(np.arange(1,11),8.3,50).compute()
In [3]: crps
Out[3]: 1.6300000000000003
In [4]: fcrps
Out[4]: 1.446666666666667
In [5]: acrps
Out[5]: 1.4833333333333336
```
mva 0.0.2
A package to correct the bias of forecasts/hindcasts. Read the documentation at https://github.com/gouthamnaveen/mva
License: Apache License 2.0
Keywords: mva,mean,variance,bias correction,mean and variance adjustment,bias adjustment,calibration,python

# Documentation  

A python package to adjust the bias of probabilistic forecasts/hindcasts using "Mean and Variance Adjustment" method.

Read documentation at [https://github.com/gouthamnaveen/mva](https://github.com/gouthamnaveen/mva)

_References_:

[1] Torralba, V., Doblas-Reyes, F. J., MacLeod, D., Christel, I. & Davis, M. Seasonal Climate Prediction: A New Source of Information for the Management of Wind Energy Resources. Journal of Applied Meteorology and Climatology 56, 1231–1247 (2017).

[2] Manzanas, R. et al. Bias adjustment and ensemble recalibration methods for seasonal forecasting: a comprehensive intercomparison using the C3S dataset. Clim Dyn 53, 1287–1305 (2019).

## _Installation:_

```sh
pip install mva
```

## _Parameters:_

**hindcast**: numpy.ndarray

The hindcast (or training) data. Kindly maintain the shape of the array as (years/samples,time,ensemble-members,grid-points).

**observation**: numpy.ndarray

The truth or observations corresponding to the hindcast. Kindly maintain the shape of the array as (years/samples,time,grid-points).
    
**forecast**: numpy.ndarray, optional

The forecast (or test) data. Kindly maintain the shape of the array as (time,ensemble-members,grid-points).

_Note_: Kindly respect the array shapes even if the computation is done for one time/grid point/ensemble member.

## _Methods:_

**adjust_hindcast()**:

This method corrects the bias of the hindcast using hindcast of the remaining years in the set (i.e., leave-one-out approach) and the corresponding observations.

_Returns_:

bias_adjusted_hindcast (Note: It has the same shape as the hindcast)

**adjust_forecast()**:

This method corrects the bias of the forecast using hindcast and the corresponding observations. This method works only when the forecast parameter is given.

_Returns_:

bias_adjusted_forecast (Note: It has the same shape as the forecast)

## _Demonstration:_

```sh
import numpy as np
import mva.mva as mva
```
Let's imagine that we have loaded the data of hindcast, forecast, and observation.

Example - 1
```sh
In [1]: hcast.shape
Out[1]: (20,46,10,6)
In [2]: fcast.shape
Out[2]: (46,50,6)
In [3]: obs.shape
Out[3]: (20,46,6)
In [4]: bc = mva(hcast,obs,fcast)
In [5]: ad_hcast = bc.adjust_hindcast()
In [6]: ad_hcast.shape
Out[6]: (20,46,10,6)
In [7]: ad_fcast = bc.adjust_forecast()
In [8]: ad_fcast.shape
Out[8]: (46,50,6)
```

Example - 2
```sh
In [1]: hcast.shape
Out[1]: (20,46,10,6)
In [2]: fcast.shape
Out[2]: (48,50,6)
In [3]: obs.shape
Out[3]: (20,46,6)
In [4]: ad_hcast = mva(hcast,obs,fcast).adjust_hindcast()
In [5]: ad_hcast.shape
Out[5]: (20,46,10,6)
In [6]: ad_fcast = mva(hcast,obs,fcast).adjust_forecast()
Out[6]: Please respect the array shapes and try again!
```