Gaussian distribution in python [closed] - python

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have two columns (2x10) of data the first column is the data the second is the errors. I want to generate the gaussian distribution value for each value in first column taking it with corresponding errors. So how can I manage that?

Try this
# Your array of data and measurements
measurements = np.ones((10,2))
# 10 values drawn from a Gaussian distribution
measurements[:,1] = np.random.normal(0.0,1.0,size=(10,1))
Where np.random.normal(0.0, 1.0, 1) draws a single value from a Gaussian distribution with a mean of 0 and a standard deviation of 1.0. See the docs for more information.
The third argument in my code above, denoted by size, gives you the shape of the array of samples you require.

Related

Differential equation solving in scipy [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 days ago.
Improve this question
Now I have a differential equation dy/dx = Dx, where D is a matrix with the same number of columns as the number of steps of x to integrate. Different step points x need to be multiplied by the corresponding column in D. How to do this? How to make scipy multiply the different columns in D by the integral of each step in a given interval
I know about this function scipy.integrate.solve_ivp, but I don't know how to define it so that different columns of D correspond to different small integral

Band and bandgap [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am doing an assignment for class and have this question: "Create a target array gap for bandgap - the difference between lumo_zindo and homo_zindo." I do not understand or know what they are asking. In class, we simply learned how to plot multilinear regression so I have no clue what gap or bandgap are.
Wikipedia goes a long way toward explaining your question about lumo_zindo and homo_zindo.
They're referring to electron orbitals. HOMO is the Highest Occupied Molecular Orbital. LUMO is the Lowest Occupied Molecular Orbital. The Band Gap is the Energy delta between the two.
Check out the links for reference:
https://en.wikipedia.org/wiki/HOMO_and_LUMO
https://en.wikipedia.org/wiki/ZINDO
As far as creating the gap Array in python (assuming lumo_zindo and homo_zindo are both lists that contain the same numeric data type), I'd try:
gap = []
for h,l in zip(homo_zindo, lumo_zindo):
gap.append(h - l)

Binned scatterplot Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Is there a simple way or a package for creating binned scatterplots in python?
I have a scatterplot. I am fitting a local polynomial regression to the data using the package "localreg". I get multiple lines as output. I am searching for a 1 line output. In order to get this I want to used a binned scatterplot. Is there no easy way to do this ?
You can first bin your arrays, do your fitting and then create your plot.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binned_statistic.html
There is the hexabin plot in Matplotlib, if this suits your purpose. Here is an example. Here another example using seaborn.

How to transform the uniform() in Python into something similar in R? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have been wanting to know how can I get a line of Python code that uses the uniform() function such as:
X_test = uniform(0, 1, size=(test_size, 20))
where test size is 1000 observations and 20 predictors, into an R code version. Much appreciated thanks!
Assuming you want a function that takes a random sample from a uniform distribution, there is an R function for that:
https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Uniform.html
Specifically, use the runif function to generate n random samples from min to max.
In your case, you could generate a 1000 by 20 matrix of uniform samples using the following code:
matrix(runif(test_size * predictors), ncol=predictors)

How to handle NaNs in binary variables (0 & 1) for Random Forest? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to predict churns using random forest in Python. I got only binary variables (0 & 1), but the majority of the variables contain up to 60% missing values.
Just fill the NaNs with -1. That way the model can treat them specially, as the Random Forest model is based on decision trees it can handle this situation easily.
Replacing with zeros is not an option because you would be mixing the actual 0 values with the missing data (think that if you replace the missing data with zeros the model will no longer have a way to distinguish between which of them were zero and which ones were actually missing data). Replacing with an extreme value is the best, that way the model can use the fact that there is a missing value as extra information.

Categories