chromium/third_party/abseil-cpp/absl/random/internal/distribution_test_util.cc

// Copyright 2017 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "absl/random/internal/distribution_test_util.h"

#include <cassert>
#include <cmath>
#include <string>
#include <vector>

#include "absl/base/internal/raw_logging.h"
#include "absl/base/macros.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"

namespace absl {
ABSL_NAMESPACE_BEGIN
namespace random_internal {
namespace {

#if defined(__EMSCRIPTEN__)
// Workaround __EMSCRIPTEN__ error: llvm_fma_f64 not found.
inline double fma(double x, double y, double z) { return (x * y) + z; }
#endif

}  // namespace

DistributionMoments ComputeDistributionMoments(
    absl::Span<const double> data_points) {}

std::ostream& operator<<(std::ostream& os, const DistributionMoments& moments) {}

double InverseNormalSurvival(double x) {}

bool Near(absl::string_view msg, double actual, double expected, double bound) {}

// TODO(absl-team): Replace with an "ABSL_HAVE_SPECIAL_MATH" and try
// to use std::beta().  As of this writing P0226R1 is not implemented
// in libc++: http://libcxx.llvm.org/cxx1z_status.html
double beta(double p, double q) {}

// Approximation to inverse of the Error Function in double precision.
// (http://people.maths.ox.ac.uk/gilesm/files/gems_erfinv.pdf)
double erfinv(double x) {}

namespace {

// Direct implementation of AS63, BETAIN()
// https://www.jstor.org/stable/2346797?seq=3#page_scan_tab_contents.
//
// BETAIN(x, p, q, beta)
//  x:     the value of the upper limit x.
//  p:     the value of the parameter p.
//  q:     the value of the parameter q.
//  beta:  the value of ln B(p, q)
//
double BetaIncompleteImpl(const double x, const double p, const double q,
                          const double beta) {}

// Direct implementation of AS109, XINBTA(p, q, beta, alpha)
// https://www.jstor.org/stable/2346798?read-now=1&seq=4#page_scan_tab_contents
// https://www.jstor.org/stable/2346887?seq=1#page_scan_tab_contents
//
// XINBTA(p, q, beta, alpha)
//  p:     the value of the parameter p.
//  q:     the value of the parameter q.
//  beta:  the value of ln B(p, q)
//  alpha: the value of the lower tail area.
//
double BetaIncompleteInvImpl(const double p, const double q, const double beta,
                             const double alpha) {}

}  // namespace

double BetaIncomplete(const double x, const double p, const double q) {}

double BetaIncompleteInv(const double p, const double q, const double alpha) {}

// Given `num_trials` trials each with probability `p` of success, the
// probability of no failures is `p^k`. To ensure the probability of a failure
// is no more than `p_fail`, it must be that `p^k == 1 - p_fail`. This function
// computes `p` from that equation.
double RequiredSuccessProbability(const double p_fail, const int num_trials) {}

double ZScore(double expected_mean, const DistributionMoments& moments) {}

double MaxErrorTolerance(double acceptance_probability) {}

}  // namespace random_internal
ABSL_NAMESPACE_END
}  // namespace absl