statistics

Scaling the fitted PDF of a log-normal distribution to the histrogram in python

筅森魡賤 提交于 2019-12-12 10:01:58
问题 I have a log-normal distributed set a samples and want to perform a fit to it. Then I want to plot both the histogram of the samples and the fitted PDF into one plot, and I'd like to use the original scaling for the histogram. My question: How to directly scale the PDF such that it is visible in the histogram plot? Here is the code: import numpy as np import scipy.stats # generate log-normal distributed set of samples samples = np.random.lognormal( mean=1., sigma=.4, size=10000 ) # make a fit

scipy.stats.ttest_ind without array (python)

心不动则不痛 提交于 2019-12-12 09:46:30
问题 I have done a number of calculations to estimate μ, σ and N for my two samples. Due to a number of approximations I don't have the arrays that are expected as input to scipy.stats.ttest_ind. Unless I am mistaken I only need μ, σ and N to do a welch's t test. Is there a way to do this in python? 回答1: As an update The function is now available in scipy.stats , since version 0.16.0 http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.stats.ttest_ind_from_stats.html scipy.stats.ttest

Covariance matrix from np.polyfit() has negative diagonal?

社会主义新天地 提交于 2019-12-12 09:27:23
问题 Problem: the cov=True option of np.polyfit() produces a diagonal with non-sensical negative values. UPDATE: after playing with this some more, I am really starting to suspect a bug in numpy ? Is that possible? Deleting any pair of 13 values from the dataset will fix the problem. I am using np.polyfit() to calculate the slope and intercept coefficients of a dataset. A plot of the values produces a very linear (but not perfectly) linear graph. I am attempting to get the standard deviation on

Weibull cumulative distribution function starting from “fitdistr” command

对着背影说爱祢 提交于 2019-12-12 09:14:43
问题 I've used fitdistr function from R MASS package to adjust a Weibull 2 parameters probability density function (pdf). This is my code: require(MASS) h = c(31.194, 31.424, 31.253, 25.349, 24.535, 25.562, 29.486, 25.680, 26.079, 30.556, 30.552, 30.412, 29.344, 26.072, 28.777, 30.204, 29.677, 29.853, 29.718, 27.860, 28.919, 30.226, 25.937, 30.594, 30.614, 29.106, 15.208, 30.993, 32.075, 31.097, 32.073, 29.600, 29.031, 31.033, 30.412, 30.839, 31.121, 24.802, 29.181, 30.136, 25.464, 28.302, 26.018,

Generating Random Variables with given correlations between pairs of them:

天涯浪子 提交于 2019-12-12 08:54:45
问题 I want to generate 2 continuous random variables Q1 , Q2 (quantitative traits, each are normal) and 2 binary random variables Z1 , Z2 (binary traits) with given pairwise correlations between all possible pairs of them. Say (Q1,Q2):0.23 (Q1,Z1):0.55 (Q1,Z2):0.45 (Q2,Z1):0.4 (Q2,Z2):0.5 (Z1,Z2):0.47 Please help me generate such data in R. 回答1: This is crude but might get you started in the right direction. library(copula) options(digits=3) probs <- c(0.5,0.5) corrs <- c(0.23,0.55,0.45,0.4,0.5,0

Calculating the derivative of cumulative density function in Python

拜拜、爱过 提交于 2019-12-12 08:29:49
问题 Is it the case that the exact derivative of a cumulative density function is the probability density function (PDF)? I am calculating the derivative using the numpy.diff() , is this correct? See below code below: import scipy.stats as s import matplotlib.pyplot as plt import numpy as np wei = s.weibull_min(2, 0, 2) # shape, loc, scale - creates weibull object sample = wei.rvs(1000) shape, loc, scale = s.weibull_min.fit(sample, floc=0) x = np.linspace(np.min(sample), np.max(sample)) plt.hist

Uniform distribution from a fractal Perlin noise function in C#

孤街醉人 提交于 2019-12-12 07:48:09
问题 My Perlin noise function (which adds up 6 octaves of 3D simplex at 0.75 persistence) generates a 2D array array of double s. These numbers each come out normalized to [-1, 1], with mean at 0. I clamp them to avoid exceptions, which I think are due to floating-point accuracy issues, but I am fairly sure my scaling factor is good enough for restricting the noise output to exactly this neighborhood in the ideal case. Anyway, that's all details. The point is, here is a 256-by-256 array of noise:

Java statistical packages [closed]

旧街凉风 提交于 2019-12-12 07:40:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am searching for java modules which i can include in my program to run various statiscal tests. So far I have found http://commons.apache.org/math/userguide/stat.html - Are there any other java sites which also supports statistical packages. I need to incorporate the package in my program and call the

Plot logistic regression curve in R

此生再无相见时 提交于 2019-12-12 07:31:53
问题 I want to plot a logistic regression curve of my data, but whenever I try to my plot produces multiple curves. Here's a picture of my last attempt: last attempt Here's the relevant code I am using: fit = glm(output ~ maxhr, data=heart, family=binomial) predicted = predict(fit, newdata=heart, type="response") plot(output~maxhr, data=heart, col="red4") lines(heart$maxhr, predicted, col="green4", lwd=2) My professor uses the following code, but when I try to run it I get an error on the last

Calculate poisson probability percentage

给你一囗甜甜゛ 提交于 2019-12-12 07:30:42
问题 When you use the POISSON function in Excel (or in OpenOffice Calc), it takes two arguments: an integer an 'average' number and returns a float. In Python (I tried RandomArray and NumPy) it returns an array of random poisson numbers. What I really want is the percentage that this event will occur (it is a constant number and the array has every time different numbers - so is it an average?). for example: print poisson(2.6,6) returns [1 3 3 0 1 3] (and every time I run it, it's different). The