/* Fig (1) Age distribution of a steady-state population: oldest cells appear with half frequency of youngest cells (exponential relationship) Red line (median) divides population into two equal areas. Fig (2) Cumulative plot, integration of (1) assuming population size=1, shows relation of rank vs age. Rank is here a relative number between 0 and 1. The equation allow to convert age into rank. Example: when sorting, the median cell has rank = 0.5. This corresponds to age = 0.415 Fig (3) This is the same as Fig 2 with x and y swapped. But also the equation solved for age. Here, we can convert rank into age. */ nPoints = 100; ageX = 0.414; close("*_"); xValues = newArray(nPoints); yValues1 = newArray(nPoints); yValues2 = newArray(nPoints); yValues3 = newArray(nPoints); for (p = 0; p < nPoints; p++) { age = p/nPoints; xValues[p] = age; freq = pow(2, -age); yValues1[p] = freq; yValues2[p] = 2-2* pow(2, -age); if(age < ageX){ yValues3[p] = freq; last = p; } //age = log(1-0.5*rank)/log(0.5); } yValues3 = Array.trim(yValues3, last+1); Plot.create("(1) Age distribution_", "Age", "(1) Frequency = 2^^-Age^^"); Plot.setFrameSize(400, 250 ); Plot.setColor( "#ddddff"); Plot.setLineWidth(3); Plot.setColor("blue", "#eeeeff"); Plot.add("filled", xValues, yValues1); Plot.setColor("blue", "#ddddff"); Plot.add("filled", xValues, yValues3); Plot.setLineWidth(2); Plot.setColor( "red"); Plot.drawLine(ageX, 0.75, ageX, 0); Plot.drawGrid; Plot.setLimits(0, 1, 0, 1); Plot.setAxisLabelSize(18.0, "plain"); Plot.setFontSize(12.0); Plot.show; Plot.create("(2) Cumulative Plot_", "Age", "(2) Rank = 2-2*2^^-Age^^"); Plot.setFrameSize(400, 250 ); Plot.setColor( "#ddddff"); Plot.setLineWidth(3); Plot.setColor("blue", "#eeeeff"); Plot.add("line", xValues, yValues2); Plot.setLineWidth(2); Plot.setColor( "red"); Plot.drawLine(ageX, 0.5, ageX, 0); Plot.drawLine(0, 0.5, ageX, 0.5); Plot.drawGrid; Plot.setLimits(0, 1, 0, 1); Plot.setAxisLabelSize(18.0, "plain"); Plot.setFontSize(12.0); Plot.show; Plot.create("(3) Cumulative Plot swapped_", "Rank", "(3) Age=log(1-0.5*rank)/log(0.5)"); Plot.setFrameSize(400, 250 ); Plot.setColor( "#ddddff"); Plot.setLineWidth(3); Plot.setColor("blue", "#eeeeff"); Plot.add("line", yValues2, xValues); Plot.setLineWidth(2); Plot.setColor( "green"); Plot.drawLine(0, ageX, 0.5, ageX); Plot.drawLine(0.5, 0, 0.5, ageX); Plot.drawGrid; Plot.setLimits(0, 1, 0, 1); Plot.setAxisLabelSize(18.0, "plain"); Plot.setFontSize(12.0); Plot.show;