<commit_before>#ifndef GEOMETRICRAND_H
#define GEOMETRICRAND_H

#include "DiscreteRand.h"
#include "../continuous/UniformRand.h"
#include "../continuous/ExponentialRand.h"
#include <functional>

/**
 * @brief The GeometricRand class
 */
class RANDLIBSHARED_EXPORT GeometricRand : public DiscreteRand<int>
{
    double p;

    static constexpr unsigned tableSize = 16;
    // TODO: don't storage both variables (including tableSize)
    double table[tableSize];
    ExponentialRand W;

public:
    GeometricRand(double probability);
    virtual std::string name() override;

    void setProbability(double probability);
    inline double getProbability() const { return p; }

    double P(int k) const override;
    double F(double x) const override;
    double variate() const override;

    void sample(QVector<double> &outputData);

private:
    double variateForSmallP() const;
    double variateForLargeP() const;

public:
    double E() const override { return 1.0 / p; }
    double Var() const override { return (1 - p) / (p * p); }

    // TODO: add median and entropy
    static double constexpr Mode() { return 1; }
    inline double Skewness() { return (2 - p) / std::sqrt(1 - p); }
    inline double ExcessiveKurtosis() { return 1.0 / (p * (1 - p)) - 6; }
};

#endif // GEOMETRICRAND_H
<commit_msg>Finished main functions in Geometric Rand<commit_after>#ifndef GEOMETRICRAND_H
#define GEOMETRICRAND_H

#include "DiscreteRand.h"
#include "../continuous/UniformRand.h"
#include "../continuous/ExponentialRand.h"
#include <functional>

/**
 * @brief The GeometricRand class
 */
class RANDLIBSHARED_EXPORT GeometricRand : public DiscreteRand<int>
{
    double p;

    static constexpr unsigned tableSize = 16;
    // TODO: don't storage both variables (including tableSize)
    double table[tableSize];
    ExponentialRand W;

public:
    GeometricRand(double probability);
    virtual std::string name() override;

    void setProbability(double probability);
    inline double getProbability() const { return p; }

    double P(int k) const override;
    double F(double x) const override;
    double variate() const override;

    void sample(QVector<double> &outputData);

private:
    double variateForSmallP() const;
    double variateForLargeP() const;

public:
    double E() const override { return 1.0 / p - 1; }
    double Var() const override { return (1 - p) / (p * p); }

    inline double Median() const { return std::ceil(-M_LN2 / std::log(1 - p)) - 1; }
    static double constexpr Mode() { return 0; }
    inline double Skewness() { return (2 - p) / std::sqrt(1 - p); }
    inline double ExcessiveKurtosis() { return p * p / (1 - p) + 6; }

    inline double Entropy() const {
        double q = 1 - p;
        double a = -q * std::log(q);
        double b = -p * std::log(p);
        return (a + b) / (M_LN2 * p);
    }
};

#endif // GEOMETRICRAND_H

{'fraction_non_alphanumeric': 0.12065368567454798, 'fraction_numerical': 0.009735744089012517, 'mean_word_length': 3.31981981981982, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4209678', 'n_tokens_mistral': 966, 'n_tokens_neox': 895, 'n_words': 283}