internal FiniteDiscreteDistribution(
            DoubleMatrix values,
            DoubleMatrix masses,
            bool fromPublicAPI)
        {
            if (fromPublicAPI)
            {
                FiniteDiscreteDistribution.ValidateValues(values);

                FiniteDiscreteDistribution.ValidateMasses(masses, values);

                this.values = values.Clone().AsReadOnly();

                this.masses = masses.Clone().AsReadOnly();
            }

            this.values = values.AsReadOnly();

            this.masses = masses.AsReadOnly();

            this.InitializeAliasTables();
        }
 /// <summary>
 /// Sets the probabilities of the <see cref="Values"/> of
 /// this instance.
 /// </summary>
 /// <param name="masses">The probabilities assigned to the <see cref="Values"/>
 /// of this instance.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="masses"/> is <b>null</b>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="masses"/> contains at least an entry which
 /// does not belong to the interval <c>[0, 1]</c>.<br/>
 /// -or-<br/>
 /// The sum of the entries in <paramref name="masses"/> is not equal to
 /// <c>1</c>.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// <paramref name="masses"/> has not the same
 /// dimensions of
 /// <see cref="Values"/>.
 /// </exception>
 public void SetMasses(DoubleMatrix masses)
 {
     FiniteDiscreteDistribution.ValidateMasses(masses, this.values.matrix);
     this.masses = masses.Clone().AsReadOnly();
     this.InitializeAliasTables();
 }