I am trying to create a continuous probability distribution and then trying to draw a random sample of size 5. Need help in creating one.

myK[alpha0_,beta0_,c_,w] := 
dist[alpha1_,beta1_c1_] = ProbabilityDistribution[myK[alpha1,beta1,c1,x],{x,0,∞}];
E^-w (2+w)
(* E^-w (2+w) *)

(* ProbabilityDistribution[myK[alpha1,beta1,c1,\[FormalX]],{\[FormalX],0,∞}][1,1,2] *)
(* RandomVariate[ProbabilityDistribution[myK[alpha1,beta1,c1,\[FormalX]],{\[FormalX],0,∞}][1,1,2],5] *)
  • 2
    $\begingroup$ Your definition of myK uses w instead of w_. Your definition of dist has strange arguments. Finally, RandomVariate can only produce real numbers as output, so your parameters need to be numbers when it is called. $\endgroup$ – Carl Woll Sep 23 '17 at 20:40
  • $\begingroup$ As pointed out by Carl Woll you have a number of syntax errors. Correcting and normalizing: myK[alpha0_, beta0_, c_, w_] := (beta0/ alpha0 ((c + w)/alpha0) Exp[-((c + w)/alpha0)^beta0])/ Exp[-(c/alpha0)^beta0]; dist[alpha1_, beta1_, c1_] := ProbabilityDistribution[ myK[alpha1, beta1, c1, x], {x, 0, \[Infinity]} , Method -> "Normalize"]; Plot[PDF[dist[1, 1, 2], x] // Evaluate, {x, 0, 10}] Plot[CDF[dist[1, 1, 2], x] // Evaluate, {x, 0, 10}, PlotRange -> {0, 1}] RandomVariate[dist[1, 1, 2], 5] should work $\endgroup$ – ubpdqn Sep 24 '17 at 10:05
  • $\begingroup$ Thanks ubpdqn . As you can see I am trying to define a conditional distribution of Weibull with condition (x>c). $\endgroup$ – nutan Sep 25 '17 at 16:31
  • $\begingroup$ I hit the post button mistakenly. ... I am still not able to use my defined function as a distribution . And the RandomVariate is not working. Thanks for your patience. $\endgroup$ – nutan Sep 25 '17 at 16:33
  • $\begingroup$ Thanks all, I also looked at the answers to the other questions posted and realized that i neded to to add Assumptions -> , varying the ranges of the parameters. $\endgroup$ – nutan Sep 28 '17 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.