Author Topic: A mathematical curve to fit data - skewed Gaussian?  (Read 2041 times)

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
A mathematical curve to fit data - skewed Gaussian?
« on: 14 July, 2016, 02:50:07 pm »
If you have a set of data showing alcohol concentration in blood over time and plot it, you get a steep upward curve and then a gradual fall off. The height, time to peak, and rate of decline vary depending on drink (vodka, beer, or wine).

Is there a mathematical function to describe this shape of curve?

It's my daughter's maths project and I'm unable to offer advice.

Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #1 on: 14 July, 2016, 03:25:16 pm »
The rate of decline like any drug is a half life or exponential function I believe.

I suspect that the absorption is a complicated exponential as well.  it will depend on whether there is active or passive absorption and what is the rate limiting step.

If I take a glass of alcohol then I will start to absorb it from the stomach and there will be a defined rate of absorption. 

might be worth googling pharmacokinetics which is the science of drug absorption and removal.

Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #2 on: 14 July, 2016, 03:36:43 pm »
Skew normal.  That's the product of the PDF and CDF of the Gaussian function, with a scalar (alpha) to control how much of the CDF is factored in.  Look it up on Wikipedia.
It might not be quite what you want, though.  Sounds like you want some piecewise type function.  A cubic spline, maybe?

hellymedic

  • Just do it!
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #3 on: 14 July, 2016, 04:36:58 pm »
As I understand it (and medical school pharmacology was a LONG time ago) some drugs are cleared at a fixed rate. I think ethanol is an example; about one unit is cleared per hour and this is independent of the quantity taken.
Other drugs are cleared at a rate dependent on initial concentration.
These might be called first and second order kinetics but I'll have to do some reading...

ETA Wiki on pharmacokinetics https://en.wikipedia.org/wiki/Pharmacokinetics

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #4 on: 14 July, 2016, 04:52:58 pm »
Her idea of finding a mathematical curve might be pushing her ability, I think - having read up on CDF and PDF and skewed this, that, and the other. She's lower sixth but I've no idea what's in her syllabus.

I'll keep reading - thanks for the links.

Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #5 on: 14 July, 2016, 05:51:25 pm »
Hi Pancho,

I've often found that log transforming the raw data is a good initial approach when a normal distribution won't fit. Having log transformed the data one often finds that a normal distribution will do an adequate job, at least for much environmental data. The log-normal distribution can be described by the same parameters, mean and standard deviation, as a normal distribution, but they are based on the log normal values.

However, I think that you are actually after a decay type equation as already noted, and I would probably model something like this as a first order reaction (see: https://en.wikipedia.org/wiki/Rate_equation). I'm pretty sure that this uses a log transformation (log transformed y-axis data should give a straight line I think, may or may not require log transformation of x-axis).

You can see if that will work in excel easily by simply plotting the data and log transforming the axes until you end up with something close(ish) to a straight line - then fit with linear regression.

Cheers,

Dod

caerau

  • SR x 3 - PBP fail but 1090 km - hey - not too bad
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #6 on: 14 July, 2016, 06:30:05 pm »
Without a sound knowledge of whether the model you are fitting to bears any resemblance to what is happening physically then there is little point to fitting it.


You can fit many equations to many things but that doesn't make it a meaningful thing to do.
It's a reverse Elvis thing.

caerau

  • SR x 3 - PBP fail but 1090 km - hey - not too bad
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #7 on: 14 July, 2016, 06:32:14 pm »
Ah it's a maths project - that probably doesn't take into account whether the 1st order rate law is actually being followed in reality or not.


What Dod said probably will work in that case.
It's a reverse Elvis thing.

caerau

  • SR x 3 - PBP fail but 1090 km - hey - not too bad
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #8 on: 14 July, 2016, 06:37:56 pm »
Sorry, I should read the first post more carefully  ::-) :facepalm:


This is actually quite complicated, the steep initial rise is due to absorption of alcohol into the bloodstream  - that's going to be one rate law.


The decline is its gradual clearance  - which is another rate law altogether.


What you've got is the sum of two different rate laws. 


It seems overly difficult to me for an A level question.  They must be after something rather simpler.
It's a reverse Elvis thing.

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #9 on: 14 July, 2016, 06:48:34 pm »
I'll look into that rate laws thing (she's got hacked off and been on the beach all day).

It's some foreign exam rather than A levels and all her foreign pals her maths geniuses. She's gone from A* top of the class in the UK to barely keeping her head above water with Chinese and German competition.

Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #10 on: 14 July, 2016, 07:21:45 pm »
When I was at school it was about learning rather than being a competition, I'm sure nothing's changed.

That said, I think you could probably fit both the uptake and depuration as first order reactions.

caerau

  • SR x 3 - PBP fail but 1090 km - hey - not too bad
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #11 on: 14 July, 2016, 08:39:00 pm »
Well you probably can't in reality, but I think that would do for this yes.


Just an addition of an initial exponential rise and and exponential decay would be a reasonable first approximation. With different rate constants otherwise they'll cancel out of course.


http://chemwiki.ucdavis.edu/Core/Physical_Chemistry/Kinetics/Reaction_Rates/First-Order_Reactions


One with a positive rate to model the absorbtion of alcohol (i.e. rising at first) and one with a negative rate to model it's decay as it is broken down.


That would fit the 'skewed gaussian' looking curve she's been given.  It's not gaussian but I know what you mean.
It's a reverse Elvis thing.

Pancho

  • لَا أَعْبُدُ مَا تَعْبُدُونَ
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #12 on: 14 July, 2016, 09:20:06 pm »
When I was at school it was about learning rather than being a competition, I'm sure nothing's changed.

I think that's how schools and teachers think about it even today - in the UK at least. I don't think the pupils are so chilled.

Quote
That said, I think you could probably fit both the uptake and depuration as first order reactions.

On to google now - thanks.

She's ahead of me on maths, which is a pain. I've got sixth form maths and engineering degree maths but I've never developed that weird maths brain that you need for real maths.

Bluebottle

  • Everybody's gotta be somewhere
Re: A mathematical curve to fit data - skewed Gaussian?
« Reply #13 on: 14 July, 2016, 10:35:57 pm »
Ah, the joys of pharmacokinetic data.

This very much depends on what is in the syllabus. Without seeing the text of the question/problem the exact rate equations *may* not be required. (but they might be so...)

In case they are not, and the ultimate goal is to find the area under the curve, the trapezoidal method might be enough.  There is some good stuff in

https://www.youtube.com/watch?v=HJkInJV29t8

but not much sound...

Dieu, je vous soupçonne d'être un intellectuel de gauche.

FGG #5465