5

I have not found a library for pgfplots with "proper" (=normalized, standardized) definitions of distributions so that we don't reinvent the wheel each time we need to call these functions

  1. the density
  2. the inverse
  3. the cumulative
  4. the multivariate representation

Context

Plotting and using probability distributions (Probability_distribution, discrete and continuous) is extremely common on posts (here, here, here, here and so many others). But these 4 links leads already to 4 ways to write it

  1. (gauss, 2 inputs) gauss(\m,\s)=1/(\s*sqrt(2*pi))*exp(-((x-\m)^2)/(2*\s^2));
  2. (gauss, 3 inputs) gauss(\x,\u,\v)=1/(\v*sqrt(2*pi))*exp(-((\x-\u)^2)/(2*\v^2));
  3. (Gauss, 4 inputs) Gauss(\x,\y,\z,\u)=1/(\z*sqrt(2*pi))*exp(-((\x-\y+\u*(\x-\y)*sign(\x-\y))^2)/(2*\z^2));
  4. (gauss, not gauss) gauss(\x,\y)=exp(-\x*\x-\y*\y);

I am surprised there is not already an existing package "normalizing" the use of these probability distributions, so

  1. have I missed something in my (google/texSE) research?
  2. statistics seems to handle only formatting tables in statistics.

NB: Other functions found on different posts

  1. binom(\k,\n,\p)=\n!/(\k!*(\n-\k)!)*\p^\k*(1-\p)^(\n-\k);
  2. Poisson(\x,\L)=(\L^{\x})*exp(-\L)/({\x}!);
  3. gamma(\z)=(2.506628274631*sqrt(1/\z) + 0.20888568*(1/\z)^(1.5) + 0.00870357*(1/\z)^(2.5) - (174.2106599*(1/\z)^(3.5))/25920 - (715.6423511*(1/\z)^(4.5))/1244160)*exp((-ln(1/\z)-1)*\z);
  4. gammapdf(\x,\k,\theta) = \x^(\k-1)*exp(-\x/\theta) / (\theta^\k*gamma(\k));
  5. ...
JeT
  • 3,020
  • "Would it make sense" is too opinion based to really be answerable. I will observe that your g3 is a deformed Gaussian and that g1 and g2 differ only in how x enters into the expression. So there's really only one way to do it. That said, defining a package to put a wrapper around a function seems like it would end up needing a lot of code that people would need to look up how to use the package in order for those people to avoid writing a lot of code that people would need to look up how to use to write their own Gaussian. – Teepeemm May 17 '20 at 12:41
  • (And it would have been more convenient if your four examples had matched the order of the four ways to write it.) – Teepeemm May 17 '20 at 12:42
  • @Teepeemm Ok on the opinion based of the question! i'll edit my question. – JeT May 17 '20 at 12:49
  • @Teepeemm So it seems creating a dedicated package to store all the functions is a waste of time for the community. Fair enough :) After reading https://tex.stackexchange.com/questions/247202/creating-tikz-libraries i'll give it a try for my own culture. – JeT May 17 '20 at 13:34
  • (but it seems far above my level in pgfkeys to achieve it... :) – JeT May 17 '20 at 13:44
  • I'm definitely not the voice of the community, so others may have a different opinion. The difference that I see with the example you pointed out is that one is looking for something like \oval{Flush Drum} to make an appropriate shape with lots of code behind the scenes. The best you can hope for is \gaussian(\m,\s) with a single line of code behind the scenes. I don't know that you'd end up gaining all that much from a package. But again, I'm not an expert in pgf nor TikZ, so maybe it would turn out well. – Teepeemm May 17 '20 at 15:58
  • 2
    I think if you just want to collect such functions, at its most basic level such a library wouldn't have to contain more than \tikzset{declare function={f(\x)=...;g(\x)=...}}. So there's not much need for any in depth knowledge about pgfkeys in that sense. – Torbjørn T. May 23 '20 at 19:42
  • @TorbjørnT.That's actually already what I have, a long \tikzset. I thought there would be a smarter way to integrate these functions but it seems that simple is the answer here :). I should probably post as answer what I already have, maybe the community can kindly add some more on the go (?) – JeT May 23 '20 at 20:13

0 Answers0