# Model fitting

This folder contain the python code used to fit the models, please view the stanfiles folders for the implemeation of the models.

## dependency and setup

please ensure python is installed on the computer and libraries under requement.txt are successfuly installed
please also makesure stan si aviliable on the device, it can be installed in python using the function `cmdstanpy.install_cmdstan()`, like following:

```sh
>python
>>> import cmdstanpy
>>> cmdstanpy.install_cmdstan()
```

## Fitting

both files takes in three arguments, in following order:

*modelPath*: the path to the stan model (should end with `.stan`)

*dataPath* = the data used to fit the model (end with `.npy` for 4-arms task and `.csv` for 2 -arms task)

*savePath* = the path where the parameters of the fitted model is stored in, please ensure the path end with `.csv`, it will also generate a folder for the fitted stan model with the same name, and a txt file that records the cross validation data

### example usage

```sh
python runStan4arm.py ../stanfiles/4arms/beta_phi.stan ../data/4armsdata/UCB.npy UCB_beta_phi.csv
```
