diff options
| author | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
|---|---|---|
| committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
| commit | 6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch) | |
| tree | ed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/cs3460/rands/distributions.hpp | |
| download | misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.tar.gz misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.zip | |
Diffstat (limited to 'Homework/cs3460/rands/distributions.hpp')
| -rw-r--r-- | Homework/cs3460/rands/distributions.hpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Homework/cs3460/rands/distributions.hpp b/Homework/cs3460/rands/distributions.hpp new file mode 100644 index 0000000..18e982d --- /dev/null +++ b/Homework/cs3460/rands/distributions.hpp @@ -0,0 +1,65 @@ +#include <algorithm> +#include <cmath> +#include <cstdint> +#include <iomanip> +#include <iostream> +#include <random> +#include <string> + +#ifndef DISTRIBUTIONS_HPP + +class DistributionPair +{ + public: + DistributionPair(std::uint32_t minValue, std::uint32_t maxValue) : + minValue(minValue), maxValue(maxValue), count(0) + { + } + + std::uint32_t minValue; + std::uint32_t maxValue; + std::uint32_t count; +}; +/* + @param title: std::string, the title to display of the plot + @param distribution: const std::vector<DistributionPair>&, reference to bins + @param maxPlotLineSize: const std::uint8_t, max length of a line of the plot + @return void: plot to stdout +*/ +void plotDistribution(std::string title, + const std::vector<DistributionPair>& distribution, + const std::uint8_t maxPlotLineSize); +/* + @param howMany: uint32_t, the length of the random sequence + @param min: uint32_t, the minimum element possible + @param max: uint32_t, the maximum element possible + @param numberBins: uint8_t, the number of bins to categorize ranges of + elements + @return std::vector<DistributionPair>: a vector of bins +*/ +std::vector<DistributionPair> +generateUniformDistribution(std::uint32_t howMany, std::uint32_t min, + std::uint32_t max, std::uint8_t numberBins); +/* + @param howMany: uint32_t, the length of the random sequence + @param mean: float, the center of the normal distribution + @param stdev: float, the standard deviation of the normal distribution + @param numberBins: uint8_t, the number of bins to categorize ranges of + elements + @return std::vector<DistributionPair>, a vector of bins +*/ +std::vector<DistributionPair> +generateNormalDistribution(std::uint32_t howMany, float mean, float stdev, + std::uint8_t numberBins); +/* + @param howMany: uint32_t, the length of the random sequence + @param howOften: uint8_t, the mean of the Poisson distribution + @param numberBins: uint8_t, the number of bins to categorize ranges of + elements + @return std::vector<DistributionPair>, a vector of bins +*/ +std::vector<DistributionPair> +generatePoissonDistribution(std::uint32_t howMany, std::uint8_t howOften, + std::uint8_t numberBins); + +#endif // DISTRIBUTIONS_HPP
\ No newline at end of file |
