weibull

Use the cumulative distribution function of Weibull in R

扶醉桌前 提交于 2019-12-02 00:17:14
问题 I have to simulate a system's fail times, to do so I have to use the Weibull distribution with a "decreasing hazard rate" and a shape of "0.7-0.8". I have to generate a file with 100 results for the function that uses random numbers from 0 to 1. So I've been searching a bit and I found this R function: pweibull(q, shape, scale = 1, lower.tail = T, log.p = F) There are some other (rweibull,qweibull...) but I think this is the one that I have to use, since is the cumulative distribution one, as

Determine Weibull parameters from data

為{幸葍}努か 提交于 2019-12-01 19:28:15
I would like to identify the Weibull parameters (i.e. the shape and scale) of my data. 0.022988506 0.114942529 0.218390805 0.114942529 0.149425287 0.114942529 0.068965517 0.068965517 0.034482759 0.022988506 0.022988506 0.022988506 0.022988506 I've already tried what this answer proposed, and I'm using Python 3.4. import scipy.stats as s import numpy as np from scipy import stats def weib(x,n,a): return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a) data = np.loadtxt("data1.csv") print(data) (loc, scale) = s.exponweib.fit_loc_scale(data, 1, 1) print('loc is: ',loc, '\n scale is: ', scale)

Is the build-in probability density functions of `scipy.stat.distributions` slower than a user provided one?

依然范特西╮ 提交于 2019-11-30 17:45:58
问题 Suppose I have an array: adata=array([0.5, 1.,2.,3.,6.,10.]) and I want to calculate log likelihood of Weibull distribution of this array, given the parameters [5.,1.5] and [5.1,1.6] . I have never thought I need to write my own Weibull probability density functions for this task, as it is already provided in scipy.stat.distributions . So, this ought to do it: from scipy import stats from numpy import * adata=array([0.5, 1.,2.,3.,6.,10.]) def wb2LL(p, x): #log-likelihood of 2 parameter

Fitting a 3 parameter Weibull distribution

百般思念 提交于 2019-11-30 14:01:56
问题 I have been doing some data analysis in R and I am trying to figure out how to fit my data to a 3 parameter Weibull distribution. I found how to do it with a 2 parameter Weibull but have come up short in finding how to do it with a 3 parameter. Here is how I fit the data using the fitdistr function from the MASS package: y <- fitdistr(x[[6]], 'weibull') x[[6]] is a subset of my data and y is where I am storing the result of the fitting. 回答1: First, you might want to look at FAdist package.

Fitting a 3 parameter Weibull distribution

試著忘記壹切 提交于 2019-11-30 09:31:21
I have been doing some data analysis in R and I am trying to figure out how to fit my data to a 3 parameter Weibull distribution. I found how to do it with a 2 parameter Weibull but have come up short in finding how to do it with a 3 parameter. Here is how I fit the data using the fitdistr function from the MASS package: y <- fitdistr(x[[6]], 'weibull') x[[6]] is a subset of my data and y is where I am storing the result of the fitting. First, you might want to look at FAdist package . However, that is not so hard to go from rweibull3 to rweibull : > rweibull3 function (n, shape, scale = 1,

Fitting a Weibull distribution using Scipy

China☆狼群 提交于 2019-11-27 18:09:05
I am trying to recreate maximum likelihood distribution fitting, I can already do this in Matlab and R, but now I want to use scipy. In particular, I would like to estimate the Weibull distribution parameters for my data set. I have tried this: import scipy.stats as s import numpy as np import matplotlib.pyplot as plt def weib(x,n,a): return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a) data = np.loadtxt("stack_data.csv") (loc, scale) = s.exponweib.fit_loc_scale(data, 1, 1) print loc, scale x = np.linspace(data.min(), data.max(), 1000) plt.plot(x, weib(x, loc, scale)) plt.hist(data, data

How to plot the survival curve generated by survreg (package survival of R)?

早过忘川 提交于 2019-11-27 11:29:14
I’m trying to fit and plot a Weibull model to a survival data. The data has just one covariate, cohort, which runs from 2006 to 2010. So, any ideas on what to add to the two lines of code that follows to plot the survival curve of the cohort of 2010? library(survival) s <- Surv(subSetCdm$dur,subSetCdm$event) sWei <- survreg(s ~ cohort,dist='weibull',data=subSetCdm) Accomplishing the same with the Cox PH model is rather straightforward, with the following lines. The problem is that survfit() doesn’t accept objects of type survreg. sCox <- coxph(s ~ cohort,data=subSetCdm) cohort <- factor(c(2010

Fitting a Weibull distribution using Scipy

本小妞迷上赌 提交于 2019-11-27 04:14:36
问题 I am trying to recreate maximum likelihood distribution fitting, I can already do this in Matlab and R, but now I want to use scipy. In particular, I would like to estimate the Weibull distribution parameters for my data set. I have tried this: import scipy.stats as s import numpy as np import matplotlib.pyplot as plt def weib(x,n,a): return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a) data = np.loadtxt("stack_data.csv") (loc, scale) = s.exponweib.fit_loc_scale(data, 1, 1) print loc,

How to plot the survival curve generated by survreg (package survival of R)?

五迷三道 提交于 2019-11-26 22:20:31
问题 I’m trying to fit and plot a Weibull model to a survival data. The data has just one covariate, cohort, which runs from 2006 to 2010. So, any ideas on what to add to the two lines of code that follows to plot the survival curve of the cohort of 2010? library(survival) s <- Surv(subSetCdm$dur,subSetCdm$event) sWei <- survreg(s ~ cohort,dist='weibull',data=subSetCdm) Accomplishing the same with the Cox PH model is rather straightforward, with the following lines. The problem is that survfit()