# Switch point and piecewise function

**URL:** <https://discourse.pymc.io/t/switch-point-and-piecewise-function/4919>\
**Category:** Questions\
**Created:** [April 23, 2020, 1:29am UTC](https://discourse.pymc.io/t/switch-point-and-piecewise-function/4919 "2020-04-23T01:29:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rizman18](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rizman18/32/2978_2.png) [@rizman18](https://discourse.pymc.io/u/rizman18)\
**Post date:** [April 23, 2020, 1:29am UTC](https://discourse.pymc.io/t/switch-point-and-piecewise-function/4919/1 "2020-04-23T01:29:40Z")

</div>

Hi, I want to fit my data, here is my data

 ![warp](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/b/b6c2442f5c1670c84c1d5c6e64d57014e4582743.png)

The function is

![equation2](https://canada1.discourse-cdn.com/flex036/uploads/pymc3/original/2X/7/78221045f8e1dd3b8338d919e3a3d0718adbee8d.png)

when R \< R1, psi = 0, psi starts to deviate at R1 \< R \< R2, and psi equals psi maximum at R = R2, with psi\_maximum is set at a certain value.

I want to fit the data with these equation and need to know the best value of R1, R2, and alpha.

Can you give me advice or some references to study.

Thanks
