distribution

Truncating Poisson distribution on desired support in Matlab

回眸只為那壹抹淺笑 提交于 2020-03-23 07:43:10
问题 I want to construct a 3-dimensional Poisson distribution in Matlab with lambda parameters [0.4, 0.2, 0.6] and I want to truncate it to have support in [0;1;2;3;4;5] . The 3 components are independent. This is what I do clear n=3; %number components of the distribution supp_marginal=0:1:5; suppsize_marginal=size(supp_marginal,2); supp_temp=repmat(supp_marginal.',1,n); supp_temp_cell=num2cell(supp_temp,1); output_temp_cell=cell(1,n); [output_temp_cell{:}] = ndgrid(supp_temp_cell{:}); supp=zeros

Generating a triangular distribution in Matlab

只愿长相守 提交于 2020-03-21 03:51:58
问题 I have attempted to generate a triangular probability distribution in Matlab, but was not successful. I used the formula at http://en.wikipedia.org/wiki/Triangular_distribution. n = 10000000; a = 0.2; b = 0.7; c = 0.5; u = sqrt(rand(n, 1)); x = zeros(n, 1); for i = 1:n U = u(i); if U < (c-a)/(b-a) X = a + sqrt(U*(b-a)*(c-a)); else X = b - sqrt((1-U)*(b-a)*(b-c)); end x(i) = X; end hist(x, 100); The histogram looks like so: Doesn't look like much of a triangle to me. What's the problem? Am I

Generating a triangular distribution in Matlab

怎甘沉沦 提交于 2020-03-21 03:51:41
问题 I have attempted to generate a triangular probability distribution in Matlab, but was not successful. I used the formula at http://en.wikipedia.org/wiki/Triangular_distribution. n = 10000000; a = 0.2; b = 0.7; c = 0.5; u = sqrt(rand(n, 1)); x = zeros(n, 1); for i = 1:n U = u(i); if U < (c-a)/(b-a) X = a + sqrt(U*(b-a)*(c-a)); else X = b - sqrt((1-U)*(b-a)*(b-c)); end x(i) = X; end hist(x, 100); The histogram looks like so: Doesn't look like much of a triangle to me. What's the problem? Am I

Trouble with 'fitdistrplus' package, t-distribution

半城伤御伤魂 提交于 2020-02-24 11:01:06
问题 I am trying to fit t-distributions to my data but am unable to do so. My first try was fitdistr(myData, "t") There are 41 warnings, all saying that NaNs are produced. I don't know how, logarithms seem to be involved. So I adjusted my data somewhat so that all data is >0, but I still have the same problem (9 fewer warnings though...). Same problem with sstdFit(), produces NaNs. So instead I try with fitdist which I've seen on stackoverflow and CrossValidated: fitdist(myData, "t") I then get

Python Earth Mover Distance of 2D arrays

情到浓时终转凉″ 提交于 2020-02-22 15:33:40
问题 I would like to compute the Earth Mover Distance between two 2D arrays (these are not images). Right now I go through two libraries: scipy (https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.wasserstein_distance.html) and pyemd (https://pypi.org/project/pyemd/). #define a sampeling method def sampeling2D(n, mu1, std1, mu2, std2): #sample from N(0, 1) in the 2D hyperspace x = np.random.randn(n, 2) #scale N(0, 1) -> N(mu, std) x[:,0] = (x[:,0]*std1) + mu1 x[:,1] = (x[:,1]*std2) +

Writing conditional distribution in the WinBUGS using R2WinBUGS package in R

怎甘沉沦 提交于 2020-02-07 05:28:16
问题 For the following data, mydata ID Y x z 1 1 5.302956 1 1 2 1 3.358249 2 1 3 1 4.976734 3 1 4 1 4.290459 4 1 5 1 0.000000 5 0 6 2 5.975351 1 1 7 2 6.620773 2 1 8 2 8.045909 3 1 9 2 7.378384 4 1 10 2 6.908755 5 1 11 2 8.672657 6 1 12 2 8.284252 7 1 13 2 8.455531 8 1 14 2 7.415175 9 1 15 2 8.634265 10 1 16 3 7.356993 1 1 17 3 6.607598 2 1 18 3 0.000000 3 0 19 3 0.000000 4 0 20 3 0.000000 5 0 21 3 0.000000 6 0 22 3 0.000000 7 0 23 3 0.000000 8 0 24 3 6.398595 9 1 25 3 6.580639 10 1 26 4 5.525104

Estimating the parameters of a custom distribution using mle()

泪湿孤枕 提交于 2020-02-03 04:15:31
问题 I have the following code that I wish to estimate the parameters of a custom distribution. For more details on the distribution. Then using the estimated parameters I want to see if the estimated PDF resembles the distribution of the given the data (it is supposed to match the distribution of the given data). [EDIT]: 'x' now holds a sample of data and not a PDF The main code is: x = [0.0320000000000000 0.0280000000000000 0.0280000000000000 0.0270000000000000 0.0320000000000000 0

how to generate random numbers with a specified lognormal distribution in R?

我是研究僧i 提交于 2020-01-29 08:01:24
问题 I would like to get 20 randomly generated numbers from a lognormal distribution with the geometric mean of 10 and geometric standard deviation of 2.5. Which R function should I use to accomplish this task? Thank you for your help! 回答1: The rlnorm function: rlnorm(20, log(10), log(2.5)) More generally distributions in R are generally available in d,p,q,r forms with those letters coming first followed by the distribution stem: norm , lnorm , unif , gamma , ... etc. Their help pages will contain

how to generate random numbers with a specified lognormal distribution in R?

可紊 提交于 2020-01-29 08:01:16
问题 I would like to get 20 randomly generated numbers from a lognormal distribution with the geometric mean of 10 and geometric standard deviation of 2.5. Which R function should I use to accomplish this task? Thank you for your help! 回答1: The rlnorm function: rlnorm(20, log(10), log(2.5)) More generally distributions in R are generally available in d,p,q,r forms with those letters coming first followed by the distribution stem: norm , lnorm , unif , gamma , ... etc. Their help pages will contain

how to generate random numbers with a specified lognormal distribution in R?

落爺英雄遲暮 提交于 2020-01-29 08:01:06
问题 I would like to get 20 randomly generated numbers from a lognormal distribution with the geometric mean of 10 and geometric standard deviation of 2.5. Which R function should I use to accomplish this task? Thank you for your help! 回答1: The rlnorm function: rlnorm(20, log(10), log(2.5)) More generally distributions in R are generally available in d,p,q,r forms with those letters coming first followed by the distribution stem: norm , lnorm , unif , gamma , ... etc. Their help pages will contain