/* Statistical Dsitributions using Tendency */ // create a tendency object giving fixed upper and lower bounds a = Tendency.new(1.0, 0.0); // Linear Distributions: // uniform z = 500.collect({arg i; a.at(i)}) z.plot(discrete: true) // lowpass z = 500.collect({arg i; a.at(i, \lpRand)}) z.plot(discrete: true) // highpass z = 500.collect({arg i; a.at(i, \hpRand)}) z.plot(discrete: true) // mean (bandpass) z = 500.collect({arg i; a.at(i, \meanRand)}) z.plot(discrete: true) // Non-linear distributions // exponential // we need to redefine the range to avoid 0.0 a = Tendency.new(1.0, 0.0001); z = 500.collect({arg i; a.at(i, \expRand)}) z.plot(discrete: true) // exponential with 'high' parameter control on density a = Tendency.new(0.5); z = 500.collect({arg i; a.at(i, \exponential)}) z.plot(discrete: true, minval: 0, maxval: 5) a = Tendency.new(1); z = 500.collect({arg i; a.at(i, \exponential)}) z.plot(discrete: true, minval: 0, maxval: 5) a = Tendency.new(2); z = 500.collect({arg i; a.at(i, \exponential)}) z.plot(discrete: true, minval: 0, maxval: 5) // gamma // 'high' value controls mode or peak a = Tendency.new(2.0); z = 500.collect({arg i; a.at(i, \gamma)}) z.plot(discrete: true, minval: 0, maxval: 12) a = Tendency.new(4.0); z = 500.collect({arg i; a.at(i, \gamma)}) z.plot(discrete: true, minval: 0, maxval: 12) a = Tendency.new(8.0); z = 500.collect({arg i; a.at(i, \gamma)}) z.plot(discrete: true, minval: 0, maxval: 12) // laplace // 'high' value controls dispersion a = Tendency.new(0.01); z = 500.collect({arg i; a.at(i, \laplace)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(0.1, 0); z = 500.collect({arg i; a.at(i, \laplace)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(1.0, 0); z = 500.collect({arg i; a.at(i, \laplace)}) z.plot(discrete: true, minval: -3, maxval: 3) // alaplace (anti-laplace) // special case of laplace, creates a gap in the center // 'high' value controls dispersion a = Tendency.new(0.01); z = 500.collect({arg i; a.at(i, \alaplace)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(0.1); z = 500.collect({arg i; a.at(i, \alaplace)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(1.0, 0); z = 500.collect({arg i; a.at(i, \alaplace)}) z.plot(discrete: true, minval: -3, maxval: 3) // hcos // hyperbolic cosine distribution // 'high' value controls dispersion a = Tendency.new(0.01); z = 500.collect({arg i; a.at(i, \hcos)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(0.1); z = 500.collect({arg i; a.at(i, \hcos)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(1.0); z = 500.collect({arg i; a.at(i, \hcos)}) z.plot(discrete: true, minval: -3, maxval: 3) // logistic distribution // 'high' value controls dispersion a = Tendency.new(0.01); z = 500.collect({arg i; a.at(i, \logistic)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(0.1); z = 500.collect({arg i; a.at(i, \logistic)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(1.0); z = 500.collect({arg i; a.at(i, \logistic)}) z.plot(discrete: true, minval: -3, maxval: 3) // poisson // 'high' value is the mean of the distribution // this distribution has a discrete histogram (not continuous) // it returns always integer values a = Tendency.new(4) z = 500.collect({arg i; a.at(i, \poisson)}) z.plot(discrete: true) z.histo.plot(discrete: true) a = Tendency.new(6) z = 500.collect({arg i; a.at(i, \poisson)}) z.plot(discrete: true) z.histo.plot(discrete: true) // arcsin // arcsin distribution // 'high' value controls dispersion (spread) // output range is between 0 and this value // histogram shape is similar to beta with parA=parB=0.5 a = Tendency.new(0.01); z = 500.collect({arg i; a.at(i, \arcsin)}) z.maxItem; z.plot(discrete: true, minval: 0, maxval: 10) z.histo.plot(discrete: true) a = Tendency.new(0.1); z = 500.collect({arg i; a.at(i, \arcsin)}) z.maxItem; z.plot(discrete: true, minval: 0, maxval: 1) a = Tendency.new(1.0); z = 500.collect({arg i; a.at(i, \arcsin)}) z.maxItem; z.plot(discrete: true, minval: 0, maxval: 1) // Symmetrical non-linear distributions // beta // this distribution takes two extra parameters parA and parB // to describe where the likelihood that a random value will occur // near high (parA) or low (parB) // parA = parB = 0.5 // histogram has symmetrical shape a = Tendency.new(1.0, 0.0, 0.5, 0.5); z = 500.collect({arg i; a.at(i, \betaRand)}) z.plot(discrete: true) z.histo.plot(discrete: true) // parA = 0.5, parB = 0.25 // histogram lopsided towards high end a = Tendency.new(1.0, 0.0, 0.5, 0.25); z = 500.collect({arg i; a.at(i, \betaRand)}) z.plot(discrete: true) z.histo.plot(discrete: true) // parA = 0.25, parB = 0.5 // histogram lopsided towards low end a = Tendency.new(1.0, 0.0, 0.25, 0.5); z = 500.collect({arg i; a.at(i, \betaRand)}) z.plot(discrete: true) z.histo.plot(discrete: true) // cauchy // this distribution has a symmetrical histogram around 0 // for this implementation 'high' controls its dispersion // if parA = 1, only positive values are returned // small dispersion around 0.0 a = Tendency.new(0.01) z = 500.collect({arg i; a.at(i, \cauchy)}) z.plot(discrete: true, minval: -3, maxval: 3) // larger dispersion around 0.0 a = Tendency.new(0.1) z = 500.collect({arg i; a.at(i, \cauchy)}) z.plot(discrete: true, minval: -3, maxval: 3) // even larger dispersion around 0.0, return only positive half a = Tendency.new(1.0, parA: 1) z = 500.collect({arg i; a.at(i, \cauchy)}) z.plot(discrete: true, minval: -3, maxval: 3) // gaussian // this distribution has a bell-shaped symmetrical histogram // 'high' is the deviation or width of the bell // small deviation a = Tendency.new(0.01) z = 500.collect({arg i; a.at(i, \gauss)}) z.plot(discrete: true, minval: -3, maxval: 3) // larger deviation a = Tendency.new(0.1) z = 500.collect({arg i; a.at(i, \gauss)}) z.plot(discrete: true, minval: -3, maxval: 3) // even larger deviation a = Tendency.new(1.0) z = 500.collect({arg i; a.at(i, \gauss)}) z.plot(discrete: true, minval: -3, maxval: 3) // Using them with envelopes and time: a = Tendency.new(Env([0.01, 1.0], [1]), 1.0); // Tendency at takes a time for the Envs z = 500.collect({arg i; a.at(i / 500, \gauss)}) z.plot(discrete: true, minval: -3, maxval: 3) a = Tendency.new(Env([0.01, 1.0], [1])); z = 500.collect({arg i; a.at(i / 500, \arcsin)}) z.plot(discrete: true, minval: 0, maxval: 1)