2
$\begingroup$

I have been trying to adapt some of the previous suggestions on other questions similar to my problem for over two weeks now but I have not been able to solve my problem so far. So, I would like to kindly ask for some help.

I have a curve with several peaks which are overlapped and I would like to deconvolute the peaks and obtain the fitting parameters of each peak with a specific fit function. However I would also be totally happy if I could just obtain the individual peaks deconvoluted with this fit function. It has some constant parameters and some fit parameters that are characteristic for the peak shape.

For instance, e0 is the onset for the a reaction occuring and corresponds roughly to the peak middle, allthough it could be a little bit displaced from the exact middle.

k0 is the kinetic factor of the reaction and influences the steepness of the sides of the peak. ne should be 1 (in some cases it could also be 2 or 3 but most likely it should be 1) for each individual peak when deconvoluted. alphaa influences the symmetry of the peak, so that the more alphaa is away from 0.5 the more asymmetric the shape is.

The curve follows this specific theory:

(* constants *)
param = { fc -> 96485, r -> 8.314, temp -> 373, 
   dox -> 1 10^-9, dr -> 6 10^-9, deltae -> - 0.015, 
   dtau -> 100 10^-3};

(* fit parameters and some educated guesses, whereas e0 would be the \
peak abscissa *)
{{k0, 2.5 10^-6}, {ne, 1}, {0.1<alphaa<0.99}, {e0, -1.69}, {offset , -0.77}, {1<coxb<250}}

(* general definitions *)
fn = (r temp)/fc;
theta = Exp[ne (e - e0)/fn];
thetap = Exp[ne (e + deltae - e0)/fn];
xi = (dox/dr)^(1/2);
(* Apparent concentrations that are established by the long potential \
plateau at the potential E *)
coxapp = coxb  (xi theta)/(1 + xi theta);
crapp = coxb xi/(1 + xi theta);
(* Current density for quasi-reversible kinetics *)
ka = k0 Exp[alphaa (e - e0 + deltae)/fn];
kc = k0 Exp[-(1 - alphaa) (e - e0 + deltae)/fn];
h = ka/dr^(1/2) + kc/dox^(1/2);
djqrev = offset + 
   fc (crapp ka - coxapp kc) Exp[h^2 dtau] Erfc[h dtau^(1/2)];
(* the prior equations define the parameters in the last equation*)

I would like deconvolve the peaks and fit the data with the above function being used as a fit function.The dataplot looks like this:

plot

This is my data:

data = {{-0.24902916`, -0.116489963636364`}, {-0.254053`, \
-0.118188531818182`}, {-0.25896996`, -0.120844322727273`}, \
{-0.26399001`, -0.123882804545455`}, {-0.2689757`, \
-0.130175668181818`}, {-0.27396521`, -0.131609363636364`}, \
{-0.27899289`, -0.133914927272727`}, {-0.28396711`, \
-0.140349140909091`}, {-0.28902149`, -0.140364927272727`}, \
{-0.29397282`, -0.144093372727273`}, {-0.29896614`, \
-0.148964209090909`}, {-0.30397475`, -0.148543227272727`}, \
{-0.30899096`, -0.154163468181818`}, {-0.31398046`, \
-0.153284027272727`}, {-0.31901196`, -0.158619490909091`}, \
{-0.32398236`, -0.158292477272727`}, {-0.32901767`, \
-0.163892595454545`}, {-0.33398044`, -0.169912531818182`}, \
{-0.33901194`, -0.172811531818182`}, {-0.34398234`, \
-0.171957527272727`}, {-0.34902912`, -0.173780627272727`}, \
{-0.35398424`, -0.177857572727273`}, {-0.35899284`, \
-0.180506477272727`}, {-0.36393273`, -0.180764631818182`}, \
{-0.36899096`, -0.184383522727273`}, {-0.37399572`, -0.18686975`}, \
{-0.3789852`, -0.189532777272727`}, {-0.38397852`, \
-0.194073654545455`}, {-0.38898328`, -0.210438836363636`}, \
{-0.39399952`, -0.203793504545455`}, {-0.39894322`, \
-0.208759677272727`}, {-0.40395179`, -0.213626731818182`}, \
{-0.40899092`, -0.226932827272727`}, {-0.41393843`, -0.23321895`}, \
{-0.41898522`, -0.241579704545455`}, {-0.42401668`, \
-0.252242845454545`}, {-0.42903674`, -0.263732713636364`}, \
{-0.43394226`, -0.278795913636364`}, {-0.43899664`, \
-0.293537445454545`}, {-0.44395179`, -0.307908772727273`}, \
{-0.4489871`, -0.3267925`}, {-0.45394224`, -0.344317631818182`}, \
{-0.45901573`, -0.358947277272727`}, {-0.46401668`, \
-0.375651359090909`}, {-0.46899474`, -0.39290385`}, {-0.47397658`, \
-0.411728640909091`}, {-0.47894701`, -0.426500409090909`}, \
{-0.48397467`, -0.447423545454545`}, {-0.48897946`, \
-0.461542818181818`}, {-0.49403003`, -0.476978681818182`}, \
{-0.49900809`, -0.493757954545455`}, {-0.50397849`, \
-0.504503909090909`}, {-0.50897944`, -0.525941772727273`}, \
{-0.51393461`, -0.534741772727273`}, {-0.51896989`, \
-0.552285863636364`}, {-0.52396703`, -0.561579954545455`}, \
{-0.52899474`, -0.569712590909091`}, {-0.53398424`, \
-0.586043818181818`}, {-0.53899664`, -0.590953227272727`}, \
{-0.54396707`, -0.596510636363636`}, {-0.54894125`, \
-0.600766090909091`}, {-0.55399567`, -0.603586181818182`}, \
{-0.55896991`, -0.61378`}, {-0.56398612`, -0.613307454545454`}, \
{-0.56894124`, -0.618513136363636`}, {-0.57391548`, \
-0.622427590909091`}, {-0.5789355`, -0.626758818181818`}, \
{-0.58395559`, -0.637311909090909`}, {-0.58893365`, \
-0.637650590909091`}, {-0.59393841`, -0.641875954545455`}, \
{-0.59893167`, -0.648925909090909`}, {-0.60397083`, \
-0.652370636363636`}, {-0.60891449`, -0.663243545454545`}, \
{-0.61395365`, -0.664525772727273`}, {-0.61894315`, \
-0.681224909090909`}, {-0.62392503`, -0.685943136363636`}, \
{-0.62892979`, -0.690561909090909`}, {-0.63395745`, \
-0.699867909090909`}, {-0.63896602`, -0.704615636363636`}, \
{-0.64391357`, -0.712767409090909`}, {-0.64891833`, \
-0.721418863636364`}, {-0.65393454`, -0.731469`}, {-0.65890872`, \
-0.739805909090909`}, {-0.66395932`, -0.750915772727273`}, \
{-0.66897935`, -0.763327`}, {-0.67405671`, -0.778686181818182`}, \
{-0.6789279`, -0.795764727272727`}, {-0.68403953`, \
-0.812751590909091`}, {-0.68877703`, -0.824562`}, {-0.69396126`, \
-0.839565181818182`}, {-0.69900036`, -0.857889090909091`}, \
{-0.70399368`, -0.879056909090909`}, {-0.70885724`, \
-0.897055954545455`}, {-0.71393448`, -0.911267727272727`}, \
{-0.71893549`, -0.936037318181818`}, {-0.72399366`, \
-0.958282818181818`}, {-0.72889543`, -0.975778409090909`}, \
{-0.73399174`, -0.997875636363636`}, {-0.73894691`, \
-1.01476009090909`}, {-0.74390972`, -1.03448563636364`}, \
{-0.74889541`, -1.05330018181818`}, {-0.75395358`, \
-1.07036963636364`}, {-0.75892782`, -1.09199627272727`}, \
{-0.76394409`, -1.10347168181818`}, {-0.76891446`, \
-1.12262163636364`}, {-0.77387726`, -1.14246645454545`}, \
{-0.77891254`, -1.15767304545455`}, {-0.78387153`, \
-1.17486268181818`}, {-0.78891444`, -1.18720122727273`}, \
{-0.79387724`, -1.20482809090909`}, {-0.79880559`, \
-1.21749513636364`}, {-0.80383331`, -1.23556854545455`}, \
{-0.80886483`, -1.24848168181818`}, {-0.81389248`, \
-1.25822940909091`}, {-0.81885147`, -1.26997463636364`}, \
{-0.82389826`, -1.27934718181818`}, {-0.82888389`, \
-1.28336127272727`}, {-0.83391535`, -1.29481168181818`}, \
{-0.8388896`, -1.29330281818182`}, {-0.84390968`, \
-1.29796463636364`}, {-0.84890682`, -1.29739481818182`}, \
{-0.85386962`, -1.292397`}, {-0.85885143`, -1.29768286363636`}, \
{-0.86395931`, -1.28996563636364`}, {-0.86889154`, \
-1.28198372727273`}, {-0.87388098`, -1.27657536363636`}, \
{-0.87877893`, -1.26664804545455`}, {-0.88386387`, \
-1.25979077272727`}, {-0.88891059`, -1.24635209090909`}, \
{-0.89377791`, -1.23478568181818`}, {-0.89884764`, \
-1.21913554545455`}, {-0.90387148`, -1.20729672727273`}, \
{-0.90888005`, -1.19201436363636`}, {-0.91387337`, \
-1.17341813636364`}, {-0.9188056`, -1.15896459090909`}, \
{-0.92383713`, -1.14078981818182`}, {-0.92896783`, \
-1.11686290909091`}, {-0.93381613`, -1.10085754545455`}, \
{-0.93887812`, -1.07886295454545`}, {-0.94390583`, \
-1.06189286363636`}, {-0.94890296`, -1.03606327272727`}, \
{-0.95388865`, -1.01029545454545`}, {-0.95893544`, \
-0.989876818181818`}, {-0.96389055`, -0.960395227272727`}, \
{-0.96889532`, -0.9405`}, {-0.97392684`, -0.912435727272727`}, \
{-0.97888958`, -0.886833`}, {-0.98381799`, -0.873802454545454`}, \
{-0.98892581`, -0.841413772727273`}, {-0.9938848`, \
-0.818491681818182`}, {-0.99891251`, -0.794612090909091`}, \
{-1.0039134`, -0.774721681818182`}, {-1.0088724`, \
-0.745901818181818`}, {-1.0139039`, -0.722557545454545`}, \
{-1.0188361`, -0.701104727272727`}, {-1.0238752`, \
-0.718227909090909`}, {-1.028819`, -0.655420954545455`}, \
{-1.0338352`, -0.644065363636364`}, {-1.0389011`, \
-0.608782090909091`}, {-1.04386`, -0.583405909090909`}, {-1.0488304`, \
-0.566847`}, {-1.0538657`, -0.540978818181818`}, {-1.0588628`, \
-0.524991863636364`}, {-1.0638218`, -0.504694590909091`}, \
{-1.0688571`, -0.485746090909091`}, {-1.0738428`, \
-0.471614363636364`}, {-1.0788323`, -0.455865818181818`}, \
{-1.0837951`, -0.444153136363636`}, {-1.0888265`, -0.4239935`}, \
{-1.0938351`, -0.412895940909091`}, {-1.098882`, \
-0.402166322727273`}, {-1.1038409`, -0.390455768181818`}, \
{-1.1088419`, -0.383323322727273`}, {-1.113881`, \
-0.370489209090909`}, {-1.1188055`, -0.361408059090909`}, \
{-1.1238486`, -0.355918363636364`}, {-1.1288341`, \
-0.348151381818182`}, {-1.1338314`, -0.3412864`}, {-1.1388781`, \
-0.333349077272727`}, {-1.1438447`, -0.32915965`}, {-1.148819`, \
-0.328975913636364`}, {-1.1538084`, -0.322203504545455`}, \
{-1.1588017`, -0.319736568181818`}, {-1.1638561`, \
-0.313311859090909`}, {-1.1690327`, -0.308450895454545`}, \
{-1.1740375`, -0.305472159090909`}, {-1.1790613`, \
-0.303294486363636`}, {-1.1839974`, -0.301544190909091`}, \
{-1.1890327`, -0.300761590909091`}, {-1.1939839`, \
-0.298219095454545`}, {-1.1990231`, -0.295788286363636`}, \
{-1.2040929`, -0.29560815`}, {-1.2090212`, -0.295939790909091`}, \
{-1.2140145`, -0.294063763636364`}, {-1.2190499`, -0.29812635`}, \
{-1.2240355`, -0.299125672727273`}, {-1.2290212`, \
-0.301207259090909`}, {-1.2339993`, -0.311047618181818`}, \
{-1.2390078`, -0.31470585`}, {-1.2440737`, -0.320439922727273`}, \
{-1.2490517`, -0.330270681818182`}, {-1.2540183`, \
-0.330920631818182`}, {-1.2590231`, -0.345781781818182`}, \
{-1.2640011`, -0.357039040909091`}, {-1.2690518`, \
-0.371979972727273`}, {-1.2739878`, -0.386435768181818`}, \
{-1.2790459`, -0.404203413636364`}, {-1.2840087`, \
-0.422656709090909`}, {-1.2890021`, -0.437375590909091`}, \
{-1.2940106`, -0.457951090909091`}, {-1.2990001`, \
-0.477205454545455`}, {-1.3040317`, -0.497706727272727`}, \
{-1.3090326`, -0.531209`}, {-1.3140488`, -0.551618272727273`}, \
{-1.3190384`, -0.575072181818182`}, {-1.3239896`, \
-0.597799863636364`}, {-1.3289829`, -0.626465636363636`}, \
{-1.3339915`, -0.655456954545455`}, {-1.3390689`, \
-0.675875772727273`}, {-1.344005`, -0.702425409090909`}, \
{-1.3490517`, -0.722292545454545`}, {-1.3539916`, -0.7451035`}, \
{-1.3589963`, -0.763057272727273`}, {-1.3640507`, \
-0.770329318181818`}, {-1.3690058`, -0.792760136363636`}, \
{-1.3740031`, -0.797851454545454`}, {-1.3790536`, \
-0.802110863636364`}, {-1.3840126`, -0.816395227272727`}, \
{-1.3890059`, -0.817093590909091`}, {-1.3939724`, \
-0.818922545454545`}, {-1.399004`, -0.817004909090909`}, \
{-1.4040011`, -0.815035727272727`}, {-1.4090172`, \
-0.817225909090909`}, {-1.4139725`, -0.809934454545455`}, \
{-1.4189277`, -0.812360090909091`}, {-1.4239552`, \
-0.809391636363636`}, {-1.4289525`, -0.8024085`}, {-1.4339648`, \
-0.803710227272727`}, {-1.4389849`, -0.799732136363636`}, \
{-1.4439515`, -0.799548409090909`}, {-1.4488989`, \
-0.795976045454545`}, {-1.4539685`, -0.796420681818182`}, \
{-1.4589657`, -0.799048272727273`}, {-1.4639515`, \
-0.797971727272727`}, {-1.4689829`, -0.802937090909091`}, \
{-1.4739763`, -0.804834954545455`}, {-1.4789352`, \
-0.805716409090909`}, {-1.4839782`, -0.815699409090909`}, \
{-1.4888761`, -0.824754818181818`}, {-1.4939342`, \
-0.835211818181818`}, {-1.4989276`, -0.844408727272727`}, {-1.50394`, \
-0.855250636363636`}, {-1.5089066`, -0.8729405`}, {-1.513919`, \
-0.8759125`}, {-1.5189199`, -0.893127863636364`}, {-1.5239209`, \
-0.904294363636364`}, {-1.5289371`, -0.916707909090909`}, \
{-1.533919`, -0.93034`}, {-1.5389352`, -0.940869772727273`}, \
{-1.5439399`, -0.953262227272727`}, {-1.5489218`, \
-0.962587181818182`}, {-1.5539267`, -0.976840181818182`}, \
{-1.5589314`, -0.999014318181818`}, {-1.5639132`, \
-1.00657531818182`}, {-1.5689791`, -1.02002740909091`}, {-1.573938`, \
-1.03280672727273`}, {-1.5789887`, -1.04887877272727`}, {-1.5839285`, \
-1.07078918181818`}, {-1.5888951`, -1.08365586363636`}, {-1.5939076`, \
-1.10424172727273`}, {-1.5989124`, -1.12610322727273`}, {-1.603959`, \
-1.14881186363636`}, {-1.6089219`, -1.17899840909091`}, {-1.6139381`, \
-1.20938481818182`}, {-1.6189314`, -1.25139772727273`}, {-1.6239743`, \
-1.29666095454545`}, {-1.6289027`, -1.35297395454545`}, {-1.6338999`, \
-1.41474872727273`}, {-1.6389085`, -1.47755672727273`}, {-1.6439896`, \
-1.53987781818182`}, {-1.6488798`, -1.59860213636364`}, {-1.6539571`, \
-1.65129540909091`}, {-1.6589733`, -1.69423936363636`}, {-1.6639171`, \
-1.73151813636364`}, {-1.6689104`, -1.75733218181818`}, {-1.6739075`, \
-1.78680781818182`}, {-1.6789237`, -1.80646204545455`}, {-1.6839552`, \
-1.82383781818182`}, {-1.6889104`, -1.83418327272727`}, {-1.6939113`, \
-1.84334304545455`}, {-1.6988856`, -1.84152709090909`}, {-1.7038865`, \
-1.8420705`}, {-1.7089218`, -1.83828563636364`}, {-1.7138808`, \
-1.82870881818182`}, {-1.7189391`, -1.81809286363636`}, {-1.7238522`, \
-1.80612477272727`}, {-1.7288836`, -1.78938031818182`}, {-1.7338616`, \
-1.77739109090909`}, {-1.7389466`, -1.75711631818182`}, {-1.7439017`, \
-1.73670718181818`}, {-1.7488645`, -1.71744886363636`}, {-1.7538617`, \
-1.69412927272727`}, {-1.7588091`, -1.67019254545455`}, {-1.7638597`, \
-1.64396718181818`}, {-1.7688988`, -1.61663090909091`}, {-1.7738464`, \
-1.58994763636364`}, {-1.7789046`, -1.55943436363636`}, {-1.783875`, \
-1.52849872727273`}, {-1.7889371`, -1.49600963636364`}, {-1.7938999`, \
-1.46553595454545`}, {-1.7987977`, -1.42784154545455`}, {-1.8038216`, \
-1.40088463636364`}, {-1.8088683`, -1.36957359090909`}, {-1.8138502`, \
-1.33650318181818`}, {-1.8188435`, -1.30385172727273`}, {-1.8238597`, \
-1.27241318181818`}, {-1.8288339`, -1.24176018181818`}, {-1.833812`, \
-1.22262754545455`}, {-1.8388245`, -1.18691990909091`}, {-1.8439245`, \
-1.1600815`}, {-1.8489102`, -1.13101240909091`}, {-1.8538998`, \
-1.104232`}, {-1.8588473`, -1.08508163636364`}, {-1.8638788`, \
-1.06239518181818`}, {-1.8687919`, -1.04241086363636`}, {-1.8738463`, \
-1.02368`}, {-1.8788244`, -1.00284072727273`}, {-1.8838102`, \
-0.985716045454545`}, {-1.8888491`, -0.969347090909091`}, \
{-1.8938121`, -0.958455090909091`}, {-1.8988473`, \
-0.943627363636364`}, {-1.9038177`, -0.933253045454546`}, \
{-1.9087881`, -0.924548045454546`}, {-1.9138197`, \
-0.911984863636364`}, {-1.9187938`, -0.9024745`}, {-1.9238214`, \
-0.8959525`}, {-1.9288149`, -0.886804318181818`}, {-1.933789`, \
-0.881280909090909`}, {-1.9388092`, -0.874923727272727`}, \
{-1.9438062`, -0.8704625`}, {-1.9488111`, -0.864221227272727`}, \
{-1.9538006`, -0.859368909090909`}, {-1.9587634`, \
-0.862443818181818`}, {-1.9638025`, -0.860629181818182`}, \
{-1.9688072`, -0.856934272727273`}, {-1.9738272`, \
-0.854877454545455`}, {-1.9788282`, -0.852412909090909`}, \
{-1.9838101`, -0.858418363636364`}, {-1.9888188`, \
-0.868301636363636`}, {-1.9937891`, -0.867770272727273`}, \
{-1.9987824`, -0.872703727272727`}, {-2.003726`, \
-0.878067727272727`}, {-2.0088263`, -0.885928318181818`}, \
{-2.0137813`, -0.8862675`}, {-2.018748`, -0.894809454545455`}, \
{-2.0237565`, -0.904451454545455`}, {-2.0287652`, \
-0.910572136363636`}, {-2.0337927`, -0.920389772727273`}, \
{-2.0387366`, -0.926516954545454`}, {-2.0437374`, \
-0.941214636363636`}, {-2.0488033`, -0.944396454545455`}, \
{-2.0537698`, -0.954697181818182`}, {-2.0587556`, \
-0.966086636363636`}, {-2.0637071`, -0.987048409090909`}, \
{-2.0687919`, -0.997908772727273`}, {-2.0737395`, \
-1.00506368181818`}, {-2.0789428`, -1.00458440909091`}, {-2.083894`, \
-1.00987563636364`}, {-2.0889714`, -1.02118468181818`}, {-2.0938921`, \
-1.03582063636364`}, {-2.0989313`, -1.04687786363636`}, {-2.1039245`, \
-1.05876072727273`}, {-2.1088834`, -1.07310390909091`}, {-2.113873`, \
-1.08079345454545`}, {-2.1189005`, -1.09479177272727`}, {-2.1238902`, \
-1.11140695454545`}, {-2.1288719`, -1.12606386363636`}, {-2.133873`, \
-1.143032`}, {-2.1388893`, -1.16268036363636`}, {-2.1439016`, \
-1.18471345454545`}, {-2.148849`, -1.20351322727273`}, {-2.1539149`, \
-1.22491481818182`}, {-2.1588433`, -1.25932372727273`}, {-2.163871`, \
-1.28250972727273`}, {-2.1689332`, -1.31089654545455`}, {-2.1738043`, \
-1.34993181818182`}, {-2.1788626`, -1.38551990909091`}, {-2.1838748`, \
-1.42962804545455`}, {-2.1892707`, -1.47110954545455`}, {-2.1942563`, \
-1.51488736363636`}, {-2.1992993`, -1.56109740909091`}, {-2.2042735`, \
-1.61375113636364`}, {-2.2092705`, -1.67193168181818`}, {-2.2142754`, \
-1.72328827272727`}, {-2.2192955`, -1.77906486363636`}, {-2.2242849`, \
-1.83685772727273`}, {-2.2292898`, -1.89634168181818`}, {-2.2342715`, \
-1.95203086363636`}, {-2.2392764`, -2.00378`}, {-2.2442849`, \
-2.05186390909091`}, {-2.2492783`, -2.09937477272727`}, {-2.2542562`, \
-2.13557154545455`}, {-2.2592878`, -2.17236968181818`}, {-2.2642429`, \
-2.20240868181818`}, {-2.2692592`, -2.22177836363636`}, {-2.2742982`, \
-2.23274318181818`}, {-2.2792611`, -2.2399065`}, {-2.2843115`, \
-2.24546813636364`}, {-2.2892935`, -2.22447377272727`}, {-2.294302`, \
-2.21133940909091`}, {-2.2993031`, -2.18990463636364`}, {-2.3042123`, \
-2.16545727272727`}, {-2.3093202`, -2.144143`}, {-2.3142829`, \
-2.1120975`}, {-2.3192573`, -2.07651068181818`}, {-2.3242047`, \
-2.03513163636364`}, {-2.3292973`, -1.99376104545455`}, {-2.3342676`, \
-1.96023577272727`}, {-2.3392763`, -1.91877936363636`}, {-2.3443`, \
-1.870679`}, {-2.3493202`, -1.8307325`}, {-2.3542905`, \
-1.78428390909091`}, {-2.3593335`, -1.744722`}, {-2.3642619`, \
-1.69300236363636`}, {-2.3693011`, -1.64315204545455`}, {-2.3742523`, \
-1.59002945454545`}, {-2.3792877`, -1.53509072727273`}, {-2.3843193`, \
-1.48430718181818`}, {-2.3892248`, -1.42821536363636`}, {-2.3942409`, \
-1.37484413636364`}, {-2.3992953`, -1.31607836363636`}, {-2.4042735`, \
-1.2639775`}, {-2.4092934`, -1.19989281818182`}, {-2.4142678`, \
-1.15026918181818`}, {-2.4192495`, -1.09889327272727`}, {-2.424243`, \
-1.04269363636364`}, {-2.4293048`, -1.00180745454545`}, {-2.4342525`, \
-0.960038`}, {-2.439261`, -0.918702545454545`}, {-2.4442544`, \
-0.888600363636364`}, {-2.4493392`, -0.855204772727273`}, \
{-2.4542563`, -0.831974045454545`}, {-2.4592953`, \
-0.803941272727273`}, {-2.464323`, -0.792412681818182`}, \
{-2.4693048`, -0.776303636363636`}, {-2.4742944`, \
-0.763056863636364`}, {-2.4793143`, -0.756135863636364`}, \
{-2.4842582`, -0.756263818181818`}, {-2.489362`, \
-0.748920181818182`}, {-2.4942715`, -0.759709545454546`}, {-2.49928`, \
-0.757067181818182`}, {-2.5042696`, -0.752320045454546`}};

I would be very thankfull if someone could help me. Best wishes

$\endgroup$
3
$\begingroup$

It looks like this question can be answered following the answers in this discussion: "Multi-peak fitting for peak position".

I was too lazy to figure out a basis with the functions you want to fit. (You have listed many parameters.) So, I used the Gaussian function in this answer:

gaussian[amp_, pos_, fwhm_, x_] := 2^(-((4 (-pos + x)^2)/fwhm^2)) amp

Here are the obtained fits:

enter image description here

If you can come up with a reasonable basis using code similar to this one:

aBFuncs = 
  Association[
   Flatten@Table[
     pos -> gaussian[amp, pos, fwhm, x], {amp, {1}}, {pos, Min[data[[All, 1]]], Max[data[[All, 1]]], 0.05}, {fwhm, {0.3, 0.1}}]];

then you should be able to get the fits you want.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much for your help! The data is going from top to bottom, so the peaks are not upwards but going from the top downwards. $\endgroup$ – Fred Weker May 11 at 22:30
  • $\begingroup$ @FredWeker "The data is going from top to bottom, so the peaks are not upwards but going from the top downwards." -- It should not matter if the function basis is chosen right. $\endgroup$ – Anton Antonov May 12 at 12:22
0
$\begingroup$

I would like to follow this approach. I have been trying to adapt it to my fit function for the last couple of days but I can not obtain a fit. This here is the fit function I would like to use:

djqrev = offset + 
   fc (crapp ka - coxapp kc) Exp[h^2 dtau] Erfc[h dtau^(1/2)]/.param;

With the individual expressions defined as above

using the constant parameters being (I added ne as 1 and took it out of the fit parameters):

param = { ne -> 1, fc -> 96485, r -> 8.314, temp -> 373, 
   dox -> 1 10^-9, dr -> 6 10^-9, deltae -> - 0.015, 
   dtau -> 100 10^-3};

The fitparameters are:

{{1.0 10^-7<k0<9.9 10^-6}, {0.1<alphaa<0.99}, {-2.49<e0<-0.30}, {0.05<offset<-0.001}, {1<coxb<250}}

So this gives me this code:

Clear[model, modelvalue, peakfunc]
peakfunc[k0_, coxb_, e0_, alphaa_, offset_, e_] := 
  offset + fc (crapp ka - coxapp kc) Exp[h^2 dtau] Erfc[
      h dtau^(1/2)] /. param;
model[data_, n_] := 
 Module[{dataconfig, modelfunc, objfunc, fitvar, fitres}, 
  dataconfig = {k0[#], coxb[#], e0[#], alphaa[#], offset[#]} & /@ 
    Range[n];
  modelfunc = (peakfunc[##, fitvar] & @@@ dataconfig // Total);
  objfunc = 
   Total[((Sqrt[kdata[[All, 2]]])/
       kdata[[All, 
         1]]) (kdata[[All, 2]] - (modelfunc /. fitvar -> # &) /@ 
         kdata[[All, 1]])^2];
  FindMinimum[objfunc, Join[{}, Flatten@dataconfig], 
   MaxIterations -> 177500]]
modelvalue[kdata_, n_] /; NumericQ[n] := 
 If[n >= 1, model[data, n][[1]], 0]
fitres = ReleaseHold[
   Hold[{Round[n], model[data1, Round[n]]}] /. 
    FindMinimum[modelvalue[kdata, Round[n]], {n, 8}, 
      Method -> "PrincipalAxis"][[2]]] // Quiet

With[{n = 8}, 
 resfunc = 
  peakfunc[k0[#], coxb[#], e0[#], alphaa[#], offset[#], e] & /@ 
    Range[n] /. model[kdata, n][[2]]]

Show@{Plot[Evaluate[resfunc], {e, -2.5, -0.24903}, 
   PlotStyle -> ({Directive[Dashed, Thick, 
         ColorData["Rainbow"][#]]} & /@ 
      Rescale[Range[Length[resfunc]]]), PlotRange -> All, 
   Frame -> True, Axes -> False], 
  Plot[Evaluate[Total@resfunc], {e, -2.5, -0.24903}, 
   PlotStyle -> Directive[Thick, Red], PlotRange -> All, 
   Frame -> True, Axes -> False], 
  Graphics[{PointSize[.003], Black, Point@kdata}]}

But I get these error messages:

ReplaceAll::reps: {n,8} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.

With this error message mathematica seems to not be able to fit the data giving out more error messages of the likes of:

FindMinimum::nrnum: The function value <<99>>+<<402>> is not a real number at {k0[1],coxb[1],e0[1],alphaa[1],offset[1],k0[2],coxb[2],e0[2],alphaa[2],offset[2],k0[3],coxb[3],e0[3],alphaa[3],offset[3],k0[4],coxb[4],e0[4],alphaa[4],offset[4],k0[5],coxb[5],e0[5],alphaa[5],offset[5],k0[6],coxb[6],e0[6],alphaa[6],offset[6],k0[7],coxb[7],e0[7],alphaa[7],offset[7],k0[8],coxb[8],e0[8],alphaa[8],offset[8]} = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}.

So my question is what exactly the problem is? If I use the fit function used in the link of the question, I can get a fit (allthough I would need to the fit). But it would be very important to use my own fit function, since otherwise I lose all the information that is contained in the curve form. I suppose mathematica does not recognize the parameters k0,coxb, alphaa, e0, offset as fit parameters or there might be some problems with the syntax of the functions.

| improve this answer | |
$\endgroup$
  • $\begingroup$ If this is a new question, it should be asked separately. If an edit, then the original question should be edited. $\endgroup$ – JimB May 11 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.