Difference between revisions of "Team:Manchester/Model/PDF"

Line 90: Line 90:
 
<div class="team">
 
<div class="team">
  
<p> Contents </p>
 
<p>
 
<a href="#heading1"What is a PDF?</a> </br>
 
<a href="#heading2"Why do we need PDFs?</a> </br>
 
<a href="#heading3">What are the options?</a> </br>
 
<a href="#heading5">How its done - Find your PDF</a> </br>
 
<a href="#heading6">How its done - Implementation</a> </br>
 
<a href="#heading7">Noticed fail cases & assessment of methods</a> </br>
 
<a href="#heading8">Suggested procedure</a> </br>
 
<a href="#heading9">Density Bins</a> </br>
 
</p>
 
  
<p id="heading1" class="title2" style="font-size:25px;">What is a PDF?</p>
+
 
 
<p style="font-size:17px;">
 
<p style="font-size:17px;">
First a piece of jargon, a pdf or probability density function. Is something that describes a distribution e.g the well known bell curve for a normal distribution. If you were to select a range of values as possible e.g x between 2 and 3 the area under the curve between 2 and 3 divided by the total area of the distribution is equal to the probability the value would be in this range.
+
We now have a collection of literature values for all parameters and their associated uncertainty. Now we want to sample plausible values for use in our ensemble models. Of course, values could be randomly picked from the found literature data, but what about the ‘gaps’ between the data points? These intermediate values could be perfectly plausible parameter values too.
 +
</br></br>
 +
The probability density functions (PDF) describe our beliefs about the plausibility of different possible parameter values in a systematic way, and can be used for sampling continuously from the entire range of plausible values.
 
</p>
 
</p>
  
</br>
 
<a href="#TopTitle">Return to top of page</a>
 
</br>
 
  
<p id="heading2" class="title2" style="font-size:25px;">Why we need PDFs</p>
 
 
 
<p style="font-size:17px;">
 
We now have a data set for the parameters and we want to pick them in a smart way for running in the model. This is done by turning the data into a pdf.
 
<br /><br />
 
Values could be randomly picked from the found parameters, but what about the ‘gaps’ between the points? These could be perfectly valid potential values too.
 
<br /><br />
 
Converting a discrete dataset into a continuous one allows for better precision and makes sure your not missing any interesting parameter range, this continuous one is our pdf.
 
</p>
 
 
</br>
 
<a href="#TopTitle">Return to top of page</a>
 
</br>
 
  
 
<p id = "heading3" class="title2" style="font-size:25px;">What are the options?</p>
 
<p id = "heading3" class="title2" style="font-size:25px;">What are the options?</p>
Line 130: Line 104:
  
 
<p style="font-size:17px;">
 
<p style="font-size:17px;">
here are multiple ways to create a pdf from a data set. They can be split into two categories; parametric and non-parametric . Parametric meaning the data is used to find parameters for a known distribution that fits the data the best. We tried two Parametric methods fitting to a log normal distribution and fitting to a normal distribution.
+
There are multiple ways to estimate a probability density function from a data set. They can be split into two categories; parametric and non-parametric. In parametric approaches, the data are used to find parameters for a known distribution that fits the data the best. We tried two parametric methods: fitting to a log-normal distribution and fitting to a normal distribution.
 
<br /><br />
 
<br /><br />
Non parametric methods don’t use knowledge of a known distribution, we tried one such method “kernels” this works by giving each data point an associated wave the superposition of which gives your PDF.
+
Non-parametric methods don’t use knowledge of a specific distribution; we tried one such method, kernel density estimation. This works by giving each data point an associated wave, the superposition of which gives our PDF.
 
<br /><br />
 
<br /><br />
All these methods have advantages and drawbacks which will be discussed Below.
+
All these methods have advantages and drawbacks which will be discussed below.
 
</p>
 
</p>
 
  </br>
 
  </br>
Line 140: Line 114:
 
</br>
 
</br>
  
<p id="heading4" class="title2" style="font-size:25px;">Graphs to aid understanding</p>
+
<p id="heading4" class="title2" style="font-size:25px;">Example of a pdf we used.</p>
  
  
Line 175: Line 149:
  
 
<br /><br />
 
<br /><br />
Firstly the distribution function must be calculated. For the parametric methods the standard deviation and the mean are calculated from the data set, these are then put into the relevant equation. For the kernel method, the epanechnikov kernel was used for the waves associated with each point.
+
Firstly the distribution function must be calculated. For the parametric methods the distribution parameters are calculated for our data set, these are then put into the relevant equation. For the kernel method, the Epanechnikov kernel was used for the waves associated with each point.
 +
</br></br>
 +
For example to find the log-normal distribution you must evaluate the mean of the log of your parameter values (denoted U) and the standard deviation of the log of your paramaters (denoted O). The PDF can then be found from PLACEHOLDER equation/
 
</p>
 
</p>
 
  </br>
 
  </br>
Line 183: Line 159:
 
<h1 class="title11">Practical considerations</h1>
 
<h1 class="title11">Practical considerations</h1>
  
<p id = "heading6" class="title3" style="font-size:25px;">How it’s done - implementation </p>
+
<p id = "heading6" class="title3" style="font-size:25px;">How we sampled from our distributions </p>
  
  
 
<p style="font-size:17px;">
 
<p style="font-size:17px;">
Bins are created (The more the better as long as you have data to fill them while having good statistics.) The function is evaluated at the start position of each of these bins and the cumulative integral of the function is found. With this cumulative function returning the value of the integral at each bin start point in a array. These values are then all normalised so that the final value is equal to 1. As such the difference between two sequential values is equal to the probability that a value lies in that range.
+
The PDF was split up into bins. The PDF is evaluated at the start position of each of these bins and the cumulative integral (total area under the PDF from parameter = 0) Was found at the end of each bin. These values are then all normalised so that the final value is equal to 1. As such the difference between two sequential bins cumulative integral is equal to the probability that a randomly picked parameter will be in the bin defined by the two start points.
 
<br /><br />
 
<br /><br />
A random number between 0 and 1 is now generated , this is used to select which bin to sample from using the knowledge from the previous paragraph.  
+
A random number between 0 and 1 is now generated, This is compared to the cumulative integral to decide which bin to sample from.(see below figure).
<br /><br />
+
<br /><br />
Finally a newly generated separate random number between 0 and 1 is used to decide where in the bin the value will be, to illustrate if a bins start point was 3 and had a width of 2 if you get a random number 0.5 your value would be 4.  
+
Finally we know what bin to sample from but we dont yet know where in the bin too sample. Its assumed that the pdf is constant over the bin such that a newly generated separate random number between 0 and 1 is used to decide where in the bin the value will, assuming all values are equally likely. sampled value = value at start of bin + bin width x random number(0-1).  
  
  
Line 200: Line 176:
 
</br>
 
</br>
  
<p id = "heading7"class="title3" style="font-size:25px;">Noticed fail cases & assessment of methods</p>
+
<p  id = "heading9"  class="title3" style="font-size:25px;">Final Note</p>
 
+
<p style="font-size:17px;">
+
 
+
<br /><br />
+
As was mentioned briefly in the theory section each method has some drawbacks. In the following it is important to note that enzyme rate constants are distributed log-normally, what is really meant by this is the rate constant has one true value for our experiment but variation in experiments is log normal . Also that we tested these methods by using a self iterating code that updated guessed constants by fitting to data (an explanation of this code won’t be given in text but the code "emporer is given in our github.), in this the data was manufactured to have come from some specific parameters. But the code didn’t know about those. Note we had to take into account sloppy parameters etc, see parameter analysis section. This code as such should have evolved to have the manufactured parameters.
+
<br /><br />
+
The gaussian method was generally very good in that it would always evolve towards the manufactured constants initially, however when close it would never make it reaching equilibrium a good distance away. Also it overshoots if coming from below zero with a high deviation in the tried initial parameter guesses.
+
<br /><br />
+
Log normal method generally gets very close (within a couple %) to the actual parameters but can often overshoot.
+
Kernel method provides even better fits but can go completely crazy if the data set is too spread, but does take into account multi peaked distributions better, especially with a large h (look into kernel theory to find out what that means) .
+
 
+
We also experimented with trying modified PDF generators that used e.g an increased variance, some of these had success.
+
<br /><br />
+
With this knowledge you can choose a good PDF generator or perhaps mix of PDF's for any system of equations.
+
</p>
+
 
+
</br>
+
<a href="#TopTitle">Return to top of page</a>
+
</br>
+
 
+
<p id = "heading8" class="title3" style="font-size:25px;">Suggested procedure</p>
+
 
+
 
+
<p style="font-size:17px;">
+
The validity of these generators will depend on what sort of curves your constants generate, therefore in general, to test you must use a code like “Emporer” (name in github). And find these validity conditions out for yourself.
+
</p>
+
 
+
</br>
+
<a href="#TopTitle">Return to top of page</a>
+
</br>
+
 
+
<p  id = "heading9"  class="title3" style="font-size:25px;">Density bins</p>
+
  
 
</br></br>
 
</br></br>
 
<pstyle="font-size:17px;">
 
<pstyle="font-size:17px;">
 
</br></br>
 
</br></br>
A simpler alternative that requires a large and high density data set to be valid is to use only the data points you have, making each sequential gap between data points a bin. Next pick bins for sampling proportional to the density of data points so a constant divided by width of bin. This can then be normalised and finished like explained in how it's done-implementation above.   
+
A simpler alternative that requires a large and high density data set to be valid is to use only the data points you have, making each sequential gap between data points a bin. Next pick bins for sampling proportional to the density of data points so a constant divided by width of bin. This can then be normalised and finished like explained in how we sampled our distributions.   
 
</p>
 
</p>
 
  </br>
 
  </br>

Revision as of 16:52, 19 October 2016

Manchester iGEM 2016

PDF (Probability Density Function)

We now have a collection of literature values for all parameters and their associated uncertainty. Now we want to sample plausible values for use in our ensemble models. Of course, values could be randomly picked from the found literature data, but what about the ‘gaps’ between the data points? These intermediate values could be perfectly plausible parameter values too.

The probability density functions (PDF) describe our beliefs about the plausibility of different possible parameter values in a systematic way, and can be used for sampling continuously from the entire range of plausible values.

What are the options?

There are multiple ways to estimate a probability density function from a data set. They can be split into two categories; parametric and non-parametric. In parametric approaches, the data are used to find parameters for a known distribution that fits the data the best. We tried two parametric methods: fitting to a log-normal distribution and fitting to a normal distribution.

Non-parametric methods don’t use knowledge of a specific distribution; we tried one such method, kernel density estimation. This works by giving each data point an associated wave, the superposition of which gives our PDF.

All these methods have advantages and drawbacks which will be discussed below.


Return to top of page

Example of a pdf we used.

These graphs show the difference between the raw data and data sampled from a created PDF.

The graphs are displaying samples from a pdf used the lognormal method. As you can see from the histograms it has given much more information about the densely populated 0-100 Km value range, however it has unfairly reduced the amount of Km = ~ 500 and ~ 700 values. This is a potential downside of parametric methods and can be remedied by the kernel method. However looking at the ascending order values these Km values are still present in the sample of 500.

graph 1
graph 2
graph 3
graph 4

Return to top of page

How it’s done - Finding PDF



Firstly the distribution function must be calculated. For the parametric methods the distribution parameters are calculated for our data set, these are then put into the relevant equation. For the kernel method, the Epanechnikov kernel was used for the waves associated with each point.

For example to find the log-normal distribution you must evaluate the mean of the log of your parameter values (denoted U) and the standard deviation of the log of your paramaters (denoted O). The PDF can then be found from PLACEHOLDER equation/


Return to top of page

Practical considerations

How we sampled from our distributions

The PDF was split up into bins. The PDF is evaluated at the start position of each of these bins and the cumulative integral (total area under the PDF from parameter = 0) Was found at the end of each bin. These values are then all normalised so that the final value is equal to 1. As such the difference between two sequential bins cumulative integral is equal to the probability that a randomly picked parameter will be in the bin defined by the two start points.

A random number between 0 and 1 is now generated, This is compared to the cumulative integral to decide which bin to sample from.(see below figure).

Finally we know what bin to sample from but we dont yet know where in the bin too sample. Its assumed that the pdf is constant over the bin such that a newly generated separate random number between 0 and 1 is used to decide where in the bin the value will, assuming all values are equally likely. sampled value = value at start of bin + bin width x random number(0-1).


Return to top of page

Final Note





A simpler alternative that requires a large and high density data set to be valid is to use only the data points you have, making each sequential gap between data points a bin. Next pick bins for sampling proportional to the density of data points so a constant divided by width of bin. This can then be normalised and finished like explained in how we sampled our distributions.


Return to top of page

Return to overview