SPB Git

Repository Public

gen_tukey.py 4.5 KB 112 lines python

1# =============================================================================2#                  SP BOUCHER | SOFTWARE & RESEARCH3#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project          : ORIX Sheet9# File             : Packages/SheetAnalytics/Tests/StatisticsTests/Generators/gen_tukey.py10# Description      : Reference values for the studentized range distribution11#                    and Tukey's HSD (scipy.stats).12# Module           : StatisticsTests13# Repository       : https://git.spboucher.ai/orix-sheet14# Created          : 2026-11-2115# Last Modified    : 2026-11-2116#17# =============================================================================18# AUTHOR & PROFESSIONAL AFFILIATION19# =============================================================================20#21# Author           : Simon-Pierre Boucher22# Position         : Professor of Finance23# Institution      : Université du Québec en Outaouais (UQO)24# Department       : Département des sciences administratives25# Organization     : SP Boucher26#27# Website          : https://spboucher.ai28# Git              : https://git.spboucher.ai29#30# =============================================================================31# OFFICIAL CONTACT DIRECTORY32# =============================================================================33#34# General          : info@spboucher.ai35# Professional     : contact@spboucher.ai36# Direct           : simon@spboucher.ai37# Research         : research@spboucher.ai38# Development      : dev@spboucher.ai39# Support          : support@spboucher.ai40# Security/Admin   : admin@spboucher.ai41# Notifications    : notifications@spboucher.ai42#43# Preferred Contact: support@spboucher.ai44#45# =============================================================================46# COPYRIGHT & INTELLECTUAL PROPERTY47# =============================================================================48#49# Copyright (c) 202650# Simon-Pierre Boucher51#52# All rights reserved where applicable.53#54# This file is governed by the applicable project license,55# copyright notices, institutional agreements and relevant law.56#57# Unless expressly authorized by the applicable license or58# rights holder, copying, redistribution, sublicensing,59# publication and commercial exploitation are not permitted.60#61# Existing third-party rights and notices remain unaffected.62#63# =============================================================================64# CONFIDENTIALITY & SECURITY65# =============================================================================66#67# Classification   : Public68# Distribution     : Public repository; use is governed by the project license69# Security Contact : admin@spboucher.ai70#71# Access to this source does not independently grant permission72# to redistribute or disclose confidential materials.73#74# Do not embed credentials, private keys, access tokens,75# certificates or confidential personal information.76#77# =============================================================================78# LICENSE & MAINTENANCE79# =============================================================================80#81# License          : None specified (no license file in this repository)82# Maintainer       : Simon-Pierre Boucher83# Technical Contact: dev@spboucher.ai84#85# =============================================================================86# END OF SP BOUCHER SOURCE HEADER87# =============================================================================8889"""Reference values for the studentized range distribution and Tukey's HSD (scipy.stats)."""90import numpy as np91from scipy import stats9293from gen_common import dump9495r = np.random.default_rng(77)96cdf = []97for k in [2, 3, 5, 10, 20]:98    for df in [2, 5, 12, 60, 1000]:99        for q in [0.8, 2.0, 3.5, 5.0, 8.0]:100            cdf.append([k, df, q, stats.studentized_range.cdf(q, k, df), stats.studentized_range.sf(q, k, df)])101ppf = []102for k in [2, 3, 5, 8]:103    for df in [4, 10, 60]:104        for p in [0.9, 0.95, 0.99]:105            ppf.append([k, df, p, stats.studentized_range.ppf(p, k, df)])106g = [np.round(r.normal(m, 3, n), 2) for m, n in [(20, 9), (24, 12), (19, 7), (27, 10)]]107res = stats.tukey_hsd(*g)108ci = res.confidence_interval(0.95)109ci90 = res.confidence_interval(0.90)110dump("tukey", {"cdf": cdf, "ppf": ppf, "groups": g, "stat": res.statistic, "p": res.pvalue, "low": ci.low, "high": ci.high,111               "low90": ci90.low, "high90": ci90.high})112
Files main
Menu

Theme