Skip to content

Commit

Permalink
Update stereology_analysis.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoalopez committed May 14, 2024
1 parent 9cdb208 commit 0282f55
Showing 1 changed file with 55 additions and 20 deletions.
75 changes: 55 additions & 20 deletions grain_size_tools/stereology_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@
"id": "458148cc-b7c4-431b-8006-27a11d0a544a",
"metadata": {},
"source": [
"## Using the two-step method\n",
"\n",
"TODO"
"## Using the two-step method"
]
},
{
Expand Down Expand Up @@ -406,43 +404,80 @@
"id": "473f283f",
"metadata": {},
"source": [
"### Estimate volume fractions from a lognormal distribution"
"### Estimate volume fractions from a lognormal distribution\n",
"\n",
"#### Generate a lognormal distribution using the calculated optimal values"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "effea92e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"volume fraction = 70.6 %\n"
]
}
],
"outputs": [],
"source": [
"# import lognorm\n",
"# import lognorm from Scipy\n",
"from scipy.stats import lognorm\n",
"\n",
"# set calculated variables\n",
"geo_mean = 36.05\n",
"sigma = np.log(1.63)\n",
"\n",
"# Calculate the lognormal distribution\n",
"dist = lognorm(s=sigma, scale=geo_mean)\n",
"\n",
"# Calculate the volume fraction between sizes 75 and 25\n",
"volume_fraction = dist.cdf(75) - dist.cdf(25)\n",
"\n",
"print(f'volume fraction = {volume_fraction * 100:.1f} %')"
"dist = lognorm(s=sigma, scale=geo_mean)"
]
},
{
"cell_type": "markdown",
"id": "5dba15b3",
"metadata": {},
"source": [
"#### Examples of volume fractions representing a particular range of grain sizes using the cumulative distribution function (CDF) of the lognormal distribution"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "c6f5648c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Volume fraction of grains below 50 microns: 74.8 %\n"
]
}
],
"source": [
"# Calculate the CDF value at 50 microns in percentage\n",
"volume_fraction_below_50 = dist.cdf(50)\n",
"print(f\"Volume fraction of grains below 50 microns: {100 * volume_fraction_below_50:.1f} %\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "bdf1a171",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Volume fraction of grains between 15 and 35 microns: 0.44\n"
]
}
],
"source": [
"# Calculate the volume fraction between 15 and 35 microns \n",
"volume_fraction_15_to_35 = dist.cdf(35) - dist.cdf(15)\n",
"print(f\"Volume fraction of grains between 15 and 35 microns: {volume_fraction_15_to_35:.2f}\")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "38f0bf26",
"metadata": {},
"outputs": [
Expand Down

0 comments on commit 0282f55

Please sign in to comment.