-
I would like to create a pore distribution manually from experimental data without using Weibull distribution. |
Beta Was this translation helpful? Give feedback.
Answered by
jgostick
Oct 28, 2021
Replies: 1 comment 3 replies
-
So you're saying that you have some like a histogram, and you want to add pores in proportion to height of each bar in your histogram. We do not have a function for this explicitly, but it should be do-able: import numpy as np
import matplotlib.pyplot as plt
N = 1000 # N is the total number of pores diameter you want to generate
bin_centers = [0.5, 2.1, 3.3, 4.0, 5.0] # In what ever units you like
bin_height = [0.05, 0.2, 0.4, 0.3, 0.15] # Normalized to sum to 1.0
r = np.zeros(N)
i = 0
while i < N:
bin = np.random.randint(len(bin_centers))
if np.random.rand() < bin_height[bin]:
r[i] = bin_centers[bin]
i += 1
plt.hist(r) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ma-sadeghi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So you're saying that you have some like a histogram, and you want to add pores in proportion to height of each bar in your histogram. We do not have a function for this explicitly, but it should be do-able: