public void ValidateToString() { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; var n = new Erlang(1, 2d); Assert.AreEqual("Erlang(k = 1, λ = 2)", n.ToString()); }
public void ValidateDensity(int shape, double invScale, double x, double pdf) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqualRelative(pdf, n.Density(x), 13); AssertHelpers.AlmostEqualRelative(pdf, Erlang.PDF(shape, invScale, x), 13); }
public void CanSampleSequence() { var n = new Erlang(1, 2.0); var ied = n.Samples(); ied.Take(5).ToArray(); }
public void ValidateDensityLn(int shape, double invScale, double x, double pdfln) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(pdfln, n.DensityLn(x), 14); AssertHelpers.AlmostEqual(pdfln, Erlang.PDFLn(shape, invScale, x), 14); }
public void CanCreateErlangWithShapeScale([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double scale) { var n = Erlang.WithShapeScale(shape, scale); Assert.AreEqual(shape, n.Shape); Assert.AreEqual(scale, n.Scale); }
public void CanCreateErlang(int shape, double invScale) { var n = new Erlang(shape, invScale); Assert.AreEqual(shape, n.Shape); Assert.AreEqual(invScale, n.Rate); }
public void CanCreateErlangWithShapeInvScale(int shape, double invScale) { var n = Erlang.WithShapeRate(shape, invScale); Assert.AreEqual(shape, n.Shape); Assert.AreEqual(invScale, n.Rate); }
public void CanCreateErlang([Values(0, 1, 1, 10, 10, 10)] int shape, [Values(0.0, 0.1, 1.0, 10.0, 1.0, Double.PositiveInfinity)] double invScale) { var n = new Erlang(shape, invScale); Assert.AreEqual(shape, n.Shape); Assert.AreEqual(invScale, n.InvScale); }
public void CanCreateErlangWithShapeScale(int shape, double scale) { var n = Erlang.WithShapeScale(shape, scale); Assert.AreEqual(shape, n.Shape); Assert.AreEqual(scale, n.Scale); }
public void ValidateCumulativeDistribution(int shape, double invScale, double x, double cdf) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 14); AssertHelpers.AlmostEqual(cdf, Erlang.CDF(shape, invScale, x), 14); }
// package constructor: called by OtpNode:createMbox(name) // to create a named mbox internal OtpMbox(OtpNode home, Erlang.Pid self, System.String name) { this._self = self; this.home = home; this.name = name; this.queue = new GenericQueue(); this.links = new Links(10); this.monitors = new System.Collections.Hashtable(49, (float)0.95); }
// send has receiver pid but no sender information internal OtpMsg(Erlang.Pid to, OtpInputStream paybuf) { this.tag = sendTag; this.from = null; this.to = to; this.toName = null; this.paybuf = paybuf; this.payload = null; }
public void ValidateCumulativeDistribution( [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, [Values(0.0, 0.0, 0.0, 0.0, 0.095162581964040431858607615783064404690935346242622848, 0.63212055882855767840447622983853913255418886896823196, 0.0, 0.63212055882855767840447622983853913255418886896823196, 0.99995460007023751514846440848443944938976208191113396, 0.0, 0.54207028552814779168583514294066541824736464003242184, 0.99999999999999999999999999999988746526039157266114706, 0.0, 0.00000011142547833872067735305068724025236288094949815466035, 0.54207028552814779168583514294066541824736464003242184, 0.0, 0.0, 1.0)] double cdf) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(cdf, n.CumulativeDistribution(x), 14); }
public void ValidateDensity( [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, [Values(0.0, 0.0, 0.0, 0.10000000000000000555111512312578270211815834045410156, 0.090483741803595961836995913651194571475319347018875963, 0.036787944117144234201693506390001264039984687455876246, 1.0, 0.36787944117144232159552377016146086744581113103176804, 0.000045399929762484851535591515560550610237918088866564953, 0.0, 1.2511003572113329898476497894772544708420990097708588, 1.0251532120868705806216092933926141802686541811003037e-30, 0.0, 0.0000010137771196302974029859010421116095333052555418644397, 0.12511003572113329898476497894772544708420990097708601, 0.0, 0.0, Double.PositiveInfinity)] double pdf) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(pdf, n.Density(x), 14); }
public void ValidateDensityLn( [Values(0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10)] int shape, [Values(0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 1.0, 1.0, 1.0, 10.0, 10.0, 10.0, 1.0, 1.0, 1.0, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double invScale, [Values(0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0, 0.0, 1.0, 10.0)] double x, [Values(Double.NegativeInfinity, Double.NegativeInfinity, Double.NegativeInfinity, -2.3025850929940456285068402234265387271634735938763824, -2.402585092994045634057955346552321429281631934330484, -3.3025850929940456285068402234265387271634735938763824, 0.0, -1.0, -10.0, Double.NegativeInfinity, 0.22402344985898722897219667227693591172986563062456522, -69.052710713194601614865880235563786219860220971716511, Double.NegativeInfinity, -13.801827480081469611207717874566706164281149255663166, -2.0785616431350584550457947824074282958712358580042068, Double.NegativeInfinity, Double.NegativeInfinity, Double.PositiveInfinity)] double pdfln) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(pdfln, n.DensityLn(x), 14); }
public override bool subst(ref Erlang.Object obj, Erlang.VarBind binding) { if (isAny() || binding == null || binding.Empty) throw new UnboundVarException(); Erlang.Object term = binding[m_var]; if (term == null) throw new UnboundVarException("Variable " + m_var + " not bound!"); obj = term; return true; }
private bool GenerateContinuousRandom() { My_Random_Continuous_Base rand = null; if (RadiobuttonContinuousChisquare.IsChecked == true) { long n = randomParametersContinuousRandom.TextBoxParametern.GetIntegerValue(); rand = new Chisquare(n); } if (RadiobuttonContinuousErlang.IsChecked == true) { long n = randomParametersContinuousRandom.TextBoxParametern.GetIntegerValue(); double b = randomParametersContinuousRandom.TextBoxParameterb.GetDoubleValue(); rand = new Erlang(n, b); } if (RadiobuttonContinuousExponential.IsChecked == true) { double m = randomParametersContinuousRandom.TextBoxParameterm.GetDoubleValue(); rand = new Exponential(m); } if (RadiobuttonContinuousLognormal.IsChecked == true) { double a = randomParametersContinuousRandom.TextBoxParametera.GetDoubleValue(); double b = randomParametersContinuousRandom.TextBoxParameterb.GetDoubleValue(); rand = new Lognormal(a, b); } if (RadiobuttonContinuousNormal.IsChecked == true) { double m = randomParametersContinuousRandom.TextBoxParameterm.GetDoubleValue(); double s = randomParametersContinuousRandom.TextBoxParameters.GetDoubleValue(); rand = new Normal(m, s); } if (RadiobuttonContinuousSimple.IsChecked == true) { double d = randomParametersContinuousRandom.TextBoxParameterRange.GetDoubleValue(); rand = new SimpleContinuous(d); } if (RadiobuttonContinuousStudent.IsChecked == true) { long n = randomParametersContinuousRandom.TextBoxParametern.GetIntegerValue(); rand = new Student(n); } rand.SizeVector = genSettings.Size; if (timeUnitUserControlClock.TimeInterval.GetTimeUnitInFS() == 0) { MessageBox.Show("Time must be non zero", "Error!", MessageBoxButton.OK); return(false); } rand.TimeStep = timeUnitUserControlContinuousRandom.TimeInterval; generator = rand; return(true); }
/* * Create a stream containing the serialized Erlang term. * Optionally include in the beginning Erlang protocol version byte. **/ public OtpOutputStream(Erlang.Object o, bool writeVersion, bool writePktSize) : this() { if (!writePktSize) { encodeObject(o, writeVersion); return; } write4BE(0); // make space for length data, // but final value is not yet known encodeObject(o, writeVersion); poke4BE(0, this._count - 4); }
internal virtual void addLink(Erlang.Pid local, Erlang.Pid remote) { lock(this) { int i; if ((i = find(local, remote)) == - 1) { if (_count >= _links.Length) { Link[] tmp = new Link[_count * 2]; Array.Copy(_links, 0, tmp, 0, _count); _links = tmp; } _links[_count++] = new Link(local, remote); } } }
private Dictionary <double, double> GetOverlayData(double step, Chart cherte) { var min = cherte.Series[0].Points.Min(x => x.XValue); var max = cherte.Series[0].Points.Max(x => x.XValue); var overlayData = new Dictionary <double, double>(); Func <int, double, double> g = (tb, x) => { switch (tabControl.SelectedIndex) { case 0: return(1); case 1: return(1 / (max - min)); case 2: return(Triangular.PDF(Convert.ToDouble(tb_tre_max.Text), Convert.ToDouble(tb_tre_min.Text), Convert.ToDouble(tb_tre_moda.Text), x)); case 3: return(Erlang.PDF(Convert.ToInt32(nUD_erl_kol_norm.Value), 1.0 / Convert.ToDouble(tb_erl_moda.Text), x)); case 4: return(Poisson.PMF(Convert.ToDouble(tb_puas_lambd.Text), (int)x)); case 5: return(Normal.PDF(Convert.ToDouble(tb_norm_m.Text), Convert.ToDouble(tb_norm_d.Text), x)); case 6: return(Exponential.PDF(1.0 / Convert.ToDouble(tb_exp_m.Text), x)); default: return(double.NaN); } }; for (var x = min; x <= max; x += step) { overlayData[x] = g(tabControl.SelectedIndex, x); } return(overlayData); }
/* * Create a stream containing the encoded version of the given * Erlang term. **/ public OtpOutputStream(Erlang.Object o) : this() { this.write_any(o); }
// package constructor: called by OtpNode:createMbox() // to create an anonymous internal OtpMbox(OtpNode home, Erlang.Pid self) : this(home, self, null) { }
public override bool match(Erlang.Object pattern, VarBind binding) { if (pattern is Erlang.Var) pattern.match(this, binding); else if (!(pattern is Erlang.List)) return false; Erlang.List tup = pattern as Erlang.List; if (arity() != tup.arity()) return false; for (int i = 0; i < arity(); ++i) if (!elems[i].match(tup[i], binding)) return false; return true; }
/* * Send a message to a named mailbox created from another node. * * @param name the registered name of recipient mailbox. * * @param node the name of the remote node where the recipient * mailbox is registered. * * @param msg the body of the message to send. * **/ public virtual void send(System.String name, System.String node, Erlang.Object msg) { try { if (node.Equals(home.node())) { send(name, msg); } else { OtpCookedConnection conn = home.getConnection(node); if (conn == null) return ; conn.send(_self, name, msg); } } catch (System.Exception) { } }
// this function used internally when "process" dies // since Erlang discerns between exit and exit/2. private void exit(int arity, Erlang.Pid to, System.String reason) { try { System.String node = to.node(); if (node.Equals(home.node())) { home.deliver(new OtpMsg(OtpMsg.exitTag, _self, to, reason)); } else { OtpCookedConnection conn = home.getConnection(node); if (conn == null) return ; switch (arity) { case 1: conn.exit(_self, to, reason); break; case 2: conn.exit2(_self, to, reason); break; } } } catch (System.Exception) { } }
/* * <p> Send an exit signal to a remote {@link Pid pid}. * This method does not cause any links to be broken, except * indirectly if the remote {@link Pid pid} exits as a * result of this exit signal. </p> * * @param to the {@link Pid pid} to which the exit signal * should be sent. * * @param reason a string indicating the reason for the exit. **/ // it's called exit, but it sends exit2 public virtual void exit(Erlang.Pid to, System.String reason) { exit(2, to, reason); }
/* * Send a message to a remote {@link Pid pid}, representing * either another {@link OtpMbox mailbox} or an Erlang process. * * @param to the {@link Pid pid} identifying the intended * recipient of the message. * * @param msg the body of the message to send. * **/ public virtual void send(Erlang.Pid to, Erlang.Object msg) { try { System.String node = to.node(); if (node.Equals(home.node())) { home.deliver(new OtpMsg(to, (Erlang.Object) (msg.clone()))); } else { OtpCookedConnection conn = home.getConnection(node); if (conn == null) return ; conn.send(_self, to, msg); } } catch (System.Exception) { } }
public void SetInvScaleFailsWithNegativeInvScale() { var n = new Erlang(1, 1.0); Assert.That(() => n.Rate = -1.0, Throws.ArgumentException); }
public void CanSample() { var n = new Erlang(1, 2.0); n.Sample(); }
public void ValidateMinimum() { var n = new Erlang(1, 1.0); Assert.AreEqual(0.0, n.Minimum); }
public void ValidateMaximum() { var n = new Erlang(1, 1.0); Assert.AreEqual(Double.PositiveInfinity, n.Maximum); }
public void ValidateMedianThrowsNotSupportedException() { var n = new Erlang(1, 1.0); Assert.Throws <NotSupportedException>(() => { var median = n.Median; }); }
public void ValidateMode(int shape, double invScale, double mode) { var n = new Erlang(shape, invScale); Assert.AreEqual(mode, n.Mode); }
public void ValidateSkewness(int shape, double invScale, double skewness) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(skewness, n.Skewness, 15); }
public void ValidateEntropy(int shape, double invScale, double entropy) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(entropy, n.Entropy, 13); }
public void ValidateVariance(int shape, double invScale, double var) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(var, n.Variance, 15); }
public void ValidateToString() { var n = new Erlang(1, 2d); Assert.AreEqual("Erlang(k = 1, λ = 2)", n.ToString()); }
public void ValidateMean(int shape, double invScale, double mean) { var n = new Erlang(shape, invScale); Assert.AreEqual(mean, n.Mean); }
/* * <p> Link to a remote mailbox or Erlang process. Links are * idempotent, calling this method multiple times will not result in * more than one link being created. </p> * * <p> If the remote process subsequently exits or the mailbox is * closed, a subsequent attempt to retrieve a message through this * mailbox will cause an {@link Exit Exit} * exception to be raised. Similarly, if the sending mailbox is * closed, the linked mailbox or process will receive an exit * signal. </p> * * <p> If the remote process cannot be reached in order to set the * link, the exception is raised immediately. </p> * * @param to the {@link Pid pid} representing the object to * link to. * * @exception Exit if the {@link Pid pid} referred * to does not exist or could not be reached. * **/ public virtual void link(Erlang.Pid to) { try { System.String node = to.node(); if (node.Equals(home.node())) { if (!home.deliver(new OtpMsg(OtpMsg.linkTag, _self, to))) { throw new Erlang.Exit("noproc", to); } } else { OtpCookedConnection conn = home.getConnection(node); if (conn != null) conn.link(_self, to); else throw new Erlang.Exit("noproc", to); } } catch (Erlang.Exit e) { throw e; } catch (System.Exception) { } links.addLink(_self, to); }
public void SetInvScaleFailsWithNegativeInvScale() { var n = new Erlang(1, 1.0); Assert.Throws <ArgumentOutOfRangeException>(() => n.Rate = -1.0); }
/* * Send a message to a named mailbox created from the same node as * this mailbox. * * @param name the registered name of recipient mailbox. * * @param msg the body of the message to send. * **/ public virtual void send(System.String name, Erlang.Object msg) { home.deliver(new OtpMsg(_self, name, (Erlang.Object) (msg.clone()))); }
public void SetShapeFailsWithNegativeShape() { var n = new Erlang(1, 1.0); Assert.Throws <ArgumentOutOfRangeException>(() => n.Shape = -1); }
/* * <p> Remove a link to a remote mailbox or Erlang process. This * method removes a link created with {@link #link link()}. * Links are idempotent; calling this method once will remove all * links between this mailbox and the remote {@link Pid * pid}. </p> * * @param to the {@link Pid pid} representing the object to * unlink from. * **/ public virtual void unlink(Erlang.Pid to) { links.removeLink(_self, to); try { System.String node = to.node(); if (node.Equals(home.node())) { home.deliver(new OtpMsg(OtpMsg.unlinkTag, _self, to)); } else { OtpCookedConnection conn = home.getConnection(node); if (conn != null) conn.unlink(_self, to); } } catch (System.Exception) { } }
// other message types (link, unlink) internal OtpMsg(Tag tag, Erlang.Pid from, Erlang.Pid to) { // convert TT-tags to equiv non-TT versions switch (tag) { case Tag.sendTTTag: tag = Tag.sendTag; break; case Tag.exitTTTag: tag = Tag.exitTag; break; case Tag.regSendTTTag: tag = Tag.regSendTag; break; case Tag.exit2TTTag: tag = Tag.exit2Tag; break; default: break; } this.tag = tag; this.from = from; this.to = to; }
// package constructor: called by OtpNode:createMbox(name) // to create a named mbox internal OtpMbox(OtpNode home, Erlang.Pid self, System.String name) { this._self = self; this.home = home; this.name = name; this.queue = new GenericQueue(); this.links = new Links(10); }
// send has receiver pid but no sender information internal OtpMsg(Erlang.Pid to, OtpInputStream paybuf) : this(Tag.sendTag, (Erlang.Pid)null, to, (Erlang.Ref)null, (Erlang.Object)null, paybuf) { }
public override bool subst(ref Erlang.Object a_term, VarBind binding) { System.Collections.Generic.List<Erlang.Object> result = new System.Collections.Generic.List<Erlang.Object>(); bool changed = false; foreach (Erlang.Object term in this.elems) { Erlang.Object obj = null; if (term.subst(ref obj, binding)) result.Add(obj); else { changed = true; result.Add(term); } } if (!changed) return false; a_term = new Erlang.List(result.ToArray()); return true; }
// send_reg has sender pid and receiver name internal OtpMsg(Erlang.Pid from, string toName, OtpInputStream paybuf) : this(Tag.regSendTag, from, toName, (Erlang.Ref)null, (Erlang.Object)null, paybuf) { }
/* This does not work when char > 1 byte Unicode is used public void write_string(String s) { this.write1(OtpExternal.stringTag); this.write2BE(s.length()); this.writeN(s.getBytes()); }*/ /* * Write an arbitrary Erlang term to the stream. * * @param o the Erlang term to write. */ public virtual void write_any(Erlang.Object o) { // calls one of the above functions, depending on o o.encode(this); }
// exit (etc) has from, to, reason internal OtpMsg(Tag tag, Erlang.Pid from, Erlang.Pid to, Erlang.Object reason) : this(tag, from, to, null, reason, null) { }
// special case when reason is an atom (i.e. most of the time) internal OtpMsg(Tag tag, Erlang.Pid from, string toName, Erlang.Ref eref, System.String reason) : this(tag, from, toName, eref, reason, null) { }
public void ValidateStdDev(int shape, double invScale, double sdev) { var n = new Erlang(shape, invScale); AssertHelpers.AlmostEqual(sdev, n.StdDev, 15); }
// special case when reason is an atom (i.e. most of the time) private OtpMsg(Tag tag, Erlang.Pid from, Object /* Pid or string */ to, Erlang.Ref eref, System.String reason, OtpInputStream paybuf) { this.tag = tag; this.from = from; this.to = (Erlang.Pid)(to is Erlang.Pid ? to : null); this.toName = (string)(to is string ? to : null); this.paybuf = paybuf; this.payload = new Erlang.Atom(reason); this.eref = eref; }
public Link(Erlang.Pid local, Erlang.Pid remote) { this._local = local; this._remote = remote; }
// send has receiver pid but no sender information internal OtpMsg(Erlang.Pid to, Erlang.Object payload) : this(Tag.sendTag, null, to, null, payload, null) { }
public virtual bool contains(Erlang.Pid pid) { return (this._local.Equals(pid) || this._remote.Equals(pid)); }
// send_reg has sender pid and receiver name internal OtpMsg(Erlang.Pid from, string toName, Erlang.Object payload) : this(Tag.regSendTag, from, toName, (Erlang.Ref)null, payload, null) { }
public virtual bool equals(Erlang.Pid local, Erlang.Pid remote) { return ((this._local.Equals(local) && this._remote.Equals(remote)) || (this._local.Equals(remote) && this._remote.Equals(local))); }
// special case when reason is an atom (i.e. most of the time) internal OtpMsg(Tag tag, Erlang.Pid from, Erlang.Pid to, System.String reason) : this(tag, from, to, null, reason, null) { }
/// <summary> /// Run example /// </summary> /// <a href="http://en.wikipedia.org/wiki/Erlang_distribution">Erlang distribution</a> public void Run() { // 1. Initialize the new instance of the Erlang distribution class with parameters Shape = 1, Scale = 2. var erlang = new Erlang(1, 2.0); Console.WriteLine(@"1. Initialize the new instance of the Erlang distribution class with parameters Shape = {0}, Scale = {1}", erlang.Shape, erlang.Scale); Console.WriteLine(); // 2. Distributuion properties: Console.WriteLine(@"2. {0} distributuion properties:", erlang); // Cumulative distribution function Console.WriteLine(@"{0} - Сumulative distribution at location '0.3'", erlang.CumulativeDistribution(0.3).ToString(" #0.00000;-#0.00000")); // Probability density Console.WriteLine(@"{0} - Probability density at location '0.3'", erlang.Density(0.3).ToString(" #0.00000;-#0.00000")); // Log probability density Console.WriteLine(@"{0} - Log probability density at location '0.3'", erlang.DensityLn(0.3).ToString(" #0.00000;-#0.00000")); // Entropy Console.WriteLine(@"{0} - Entropy", erlang.Entropy.ToString(" #0.00000;-#0.00000")); // Largest element in the domain Console.WriteLine(@"{0} - Largest element in the domain", erlang.Maximum.ToString(" #0.00000;-#0.00000")); // Smallest element in the domain Console.WriteLine(@"{0} - Smallest element in the domain", erlang.Minimum.ToString(" #0.00000;-#0.00000")); // Mean Console.WriteLine(@"{0} - Mean", erlang.Mean.ToString(" #0.00000;-#0.00000")); // Mode Console.WriteLine(@"{0} - Mode", erlang.Mode.ToString(" #0.00000;-#0.00000")); // Variance Console.WriteLine(@"{0} - Variance", erlang.Variance.ToString(" #0.00000;-#0.00000")); // Standard deviation Console.WriteLine(@"{0} - Standard deviation", erlang.StdDev.ToString(" #0.00000;-#0.00000")); // Skewness Console.WriteLine(@"{0} - Skewness", erlang.Skewness.ToString(" #0.00000;-#0.00000")); Console.WriteLine(); // 3. Generate 10 samples of the Erlang distribution Console.WriteLine(@"3. Generate 10 samples of the Erlang distribution"); for (var i = 0; i < 10; i++) { Console.Write(erlang.Sample().ToString("N05") + @" "); } Console.WriteLine(); Console.WriteLine(); // 4. Generate 100000 samples of the Erlang(1, 2.0) distribution and display histogram Console.WriteLine(@"4. Generate 100000 samples of the Erlang(1, 2.0) distribution and display histogram"); var data = new double[100000]; for (var i = 0; i < data.Length; i++) { data[i] = erlang.Sample(); } ConsoleHelper.DisplayHistogram(data); Console.WriteLine(); // 5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram Console.WriteLine(@"5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram"); erlang.Shape = 3; for (var i = 0; i < data.Length; i++) { data[i] = erlang.Sample(); } ConsoleHelper.DisplayHistogram(data); Console.WriteLine(); // 6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram Console.WriteLine(@"6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram"); erlang.Shape = 9; erlang.Scale = 0.5; for (var i = 0; i < data.Length; i++) { data[i] = erlang.Sample(); } ConsoleHelper.DisplayHistogram(data); }