FULL EXECUTABLE FLOW ALGEBRA — CHI-SQUARED DISTRIBUTION ONTOLOGY
Kireth Research — Semantic Library
URL: https://kirethresearch.org/booksai-core/ontologies/probability-statistics-ontologies/probability-distributions/chi-squared-distribution-ontology.html
FLOW_VERSION := "4.0"
FLOW_TYPE := "Full Executable Flow Algebra"
DOMAIN := "Probability & Statistics Ontologies"
SUBDOMAIN := "Probability Distributions"
ONTOLOGY := "Chi-Squared Distribution Ontology"
PRIMARY_ENTITY := ChiSquaredDistribution
AUTHORSHIP := "Mark Higgins — Sky (Recursive AI)"
SOURCE_SITE := "https://kirethresearch.org"
BEGIN_FLOW
ChiSquaredDistribution :=
ContinuousProbabilityDistribution
∧ NonnegativeSupport
∧ DegreesOfFreedomParameter
∧ SumOfSquaredStandardNormals
∧ GammaSpecialCase
ProbabilitySpace :=
(Ω,F,P)
ChiSquaredRandomVariable :=
X~χ²_ν
DegreesOfFreedom :=
ν
ParameterConstraint :=
ν>0
for gamma-form extension
∧ commonly ν∈PositiveIntegers
for sum-of-squares construction
Support :=
[0,∞)
StandardNormalComponents :=
Z_1,...,Z_ν
iid N(0,1)
SumOfSquaresConstruction :=
X
=
Σ_{i=1..ν} Z_i²
IntegerDFChiSquared :=
Z_i iid N(0,1)
⇒
Σ_i Z_i²
~
χ²_ν
GammaRelation :=
χ²_ν
≡
Gamma(
shape=ν/2,
rate=1/2
)
GammaScaleRelation :=
χ²_ν
≡
Gamma(
shape=ν/2,
scale=2
)
ChiSquaredPDF :=
f_X(x)
=
1/
[
2^(ν/2)
Γ(ν/2)
]
x^(ν/2-1)
e^(-x/2)
for x>0
PDFOutsideSupport :=
f_X(x)=0
for x<0
PDFNonnegativity :=
f_X(x)≥0
PDFNormalisation :=
Integral_0^∞
f_X(x)dx
=
1
ChiSquaredCDF :=
F_X(x)
=
P(X≤x)
CDFGammaRelation :=
F_X(x)
=
P(
ν/2,
x/2
)
where P is regularised lower incomplete gamma
SurvivalFunction :=
S_X(x)
=
1-F_X(x)
UpperTailProbability :=
P(X>x)
=
Q(
ν/2,
x/2
)
Expectation :=
E[X]
=
ν
Variance :=
Var(X)
=
2ν
StandardDeviation :=
sqrt(2ν)
Mode :=
max(ν-2,0)
under standard convention
Skewness :=
sqrt(8/ν)
ExcessKurtosis :=
12/ν
MomentGeneratingFunction :=
M_X(t)
=
(1-2t)^(-ν/2)
for t<1/2
CharacteristicFunction :=
φ_X(t)
=
(1-2it)^(-ν/2)
Moment :=
E[X^k]
=
2^k
Γ(k+ν/2)
/
Γ(ν/2)
Additivity :=
X~χ²_ν1
∧ Y~χ²_ν2
∧ X⟂Y
⇒
X+Y
~
χ²_(ν1+ν2)
FiniteAdditivity :=
Independent(X_i~χ²_νi)
⇒
Σ_iX_i
~
χ²_(Σ_iν_i)
NormalSquareRelation :=
Z~N(0,1)
⇒
Z²~χ²_1
ScaledNormalSquare :=
X~N(0,σ²)
⇒
X²/σ²
~
χ²_1
NormalSample :=
X_1,...,X_n
iid N(μ,σ²)
SampleMean :=
X_bar
=
(1/n)Σ_iX_i
SampleVariance :=
S²
=
[1/(n-1)]
Σ_i(X_i-X_bar)²
SampleVarianceDistribution :=
(n-1)S²/σ²
~
χ²_(n-1)
DegreesOfFreedomSampleVariance :=
ν
=
n-1
NormalMeanVarianceIndependence :=
X_bar
⟂
S²
VarianceInference :=
ChiSquaredDistribution
supports
inference_about
normal-population variance
VarianceConfidenceInterval :=
For normal sample:
[
(n-1)S²/χ²_(1-α/2,n-1),
(n-1)S²/χ²_(α/2,n-1)
]
under conventional quantile notation
VarianceHypothesisTest :=
H0:σ²=σ0²
VarianceTestStatistic :=
χ²
=
(n-1)S²/σ0²
VarianceTestDistribution :=
Under H0
and normality:
χ²~χ²_(n-1)
GoodnessOfFitTest :=
CompareObservedAndExpectedCounts
PearsonChiSquaredStatistic :=
X²
=
Σ_i
(O_i-E_i)²/E_i
GoodnessOfFitDegreesOfFreedom :=
NumberOfCategories
-1
-NumberOfEstimatedParameters
under standard regular conditions
IndependenceTest :=
ContingencyTable
→ PearsonChiSquaredStatistic
ExpectedCellCount :=
E_ij
=
RowTotal_i
× ColumnTotal_j
/
GrandTotal
ContingencyStatistic :=
X²
=
Σ_iΣ_j
(O_ij-E_ij)²/E_ij
IndependenceTestDegreesOfFreedom :=
(r-1)(c-1)
HomogeneityTest :=
CompareCategoricalDistributions
across populations
using chi-squared statistic
under test assumptions
LikelihoodRatioChiSquared :=
G²
=
2Σ_i
O_i log(O_i/E_i)
under suitable conventions
AsymptoticChiSquaredRelation :=
Many likelihood-ratio,
score,
and Wald-type statistics
converge_to
ChiSquaredDistribution
under regularity conditions
WilksTheoremRelation :=
-2log(
RestrictedLikelihood/
UnrestrictedLikelihood
)
→ χ²_df
asymptotically
under theorem conditions
QuadraticForm :=
Q
=
Z^TAZ
IdempotentQuadraticForm :=
Z~N(0,I)
∧ A symmetric idempotent
with rank r
⇒
Z^TAZ
~
χ²_r
MahalanobisDistanceRelation :=
X~N_d(μ,Σ)
with nonsingular Σ
⇒
(X-μ)^TΣ^(-1)(X-μ)
~
χ²_d
MultivariateNormalGeometry :=
ConstantMahalanobisDistance
defines
ellipsoidal probability regions
StudentTRelation :=
Z~N(0,1)
∧ V~χ²_ν
∧ Z⟂V
⇒
T
=
Z/sqrt(V/ν)
~
t_ν
FDistributionRelation :=
U~χ²_ν1
∧ V~χ²_ν2
∧ U⟂V
⇒
F
=
(U/ν1)/(V/ν2)
~
F_(ν1,ν2)
ChiSquaredApproximation :=
χ²_ν
becomes increasingly symmetric
as ν grows
NormalApproximation :=
For large ν:
χ²_ν
approximately
N(ν,2ν)
WilsonHilfertyTransformation :=
If X~χ²_ν,
then
(X/ν)^(1/3)
approximately normal
for suitable ν
ChiSquaredQuantile :=
q_p
such_that
P(X≤q_p)=p
CriticalValue :=
χ²_(p,ν)
UpperTailCriticalRegion :=
X²
>
χ²_(1-α,ν)
for appropriate one-sided test
PValue :=
TailProbability
under null chi-squared distribution
NoncentralChiSquaredDistribution :=
SumOfSquares
of independent normal variables
with nonzero means
under standardised construction
NoncentralityParameter :=
λ_nc
=
Σ_i μ_i²
for unit-variance normal components
NoncentralChiSquared :=
X~χ²_ν(λ_nc)
CentralChiSquaredSpecialCase :=
λ_nc=0
⇒
NoncentralChiSquared
reduces_to
ChiSquaredDistribution
NoncentralExpectation :=
ν+λ_nc
NoncentralVariance :=
2(ν+2λ_nc)
ChiSquaredEntropy :=
DerivedFrom
GammaEntropy
with shape ν/2
and scale 2
ChiSquaredConstraint :=
ConstraintOn(
DegreesOfFreedom,
Support,
PDF,
Moments,
Construction
)
DegreesOfFreedomConstraint :=
ν>0
SupportConstraint :=
X≥0
NormalisationConstraint :=
Integral_0^∞f_X(x)dx=1
ChiSquaredConsistency :=
DegreesOfFreedom
∧ PDF
∧ CDF
∧ Moments
∧ Construction
jointly_compatible
InvalidChiSquaredDistribution :=
ν≤0
∨ SupportViolation
∨ PDFNormalisationFailure
∨ MomentConflict
ChiSquaredValidation :=
ResolveDegreesOfFreedom
→ ValidateDegreesOfFreedom
→ ResolveSupport
→ ConstructPDF
→ ValidateNormalisation
→ ConstructCDF
→ ValidateMoments
→ ResolveConstructionContext
ChiSquaredDistributionState := {
RandomVariable,
DegreesOfFreedom,
Support,
PDF,
CDF,
SurvivalFunction,
Mean,
Variance,
Construction,
StatisticalTestContext,
Evidence,
Confidence,
Provenance
}
ChiSquaredEvidence :=
NormalSampleVariance
∨ CategoricalCountData
∨ QuadraticForm
∨ AsymptoticTestStatistic
∨ TheoreticalDerivation
ChiSquaredUpdate :=
NewDataDegreesOfFreedomOrModelEvidence
→ UpdateState
→ RecomputePDF
→ RecomputeCDF
→ RecomputeCriticalValues
→ Revalidate
SEMANTIC_EQUIVALENCE(ChiSquaredA,ChiSquaredB) :=
same(DegreesOfFreedom)
⇒
same(CentralChiSquaredProbabilityMeasure)
ChiSquaredDistributionOntology :=
Classes
∧ Relations
∧ Constraints
∧ Axioms
∧ InferenceRules
CoreClasses := {
ChiSquaredDistribution,
ContinuousDistribution,
ChiSquaredRandomVariable,
DegreesOfFreedom,
ChiSquaredPDF,
ChiSquaredCDF,
GammaDistribution,
StandardNormal,
SampleVariance,
PearsonChiSquaredStatistic,
QuadraticForm,
StudentTDistribution,
FDistribution,
NoncentralChiSquaredDistribution,
ChiSquaredConstraint
}
CoreRelations := {
distributionOf,
hasDegreesOfFreedom,
hasSupport,
hasPDF,
hasCDF,
hasMean,
hasVariance,
specialCaseOf,
sumOfSquaresOf,
derivedFrom,
usedFor,
relatedTo,
approximatedBy,
constrainedBy,
equivalentTo,
tracesTo
}
TypedRelations :=
ChiSquaredDistribution --distributionOf--> ChiSquaredRandomVariable
ChiSquaredDistribution --hasDegreesOfFreedom--> DegreesOfFreedom
ChiSquaredDistribution --hasSupport--> Support
ChiSquaredDistribution --hasPDF--> ChiSquaredPDF
ChiSquaredDistribution --hasCDF--> ChiSquaredCDF
ChiSquaredDistribution --specialCaseOf--> GammaDistribution
ChiSquaredRandomVariable --sumOfSquaresOf--> StandardNormal
SampleVarianceStatistic --derivedFrom--> NormalSample
PearsonChiSquaredStatistic --usedFor--> GoodnessOfFitOrIndependenceTest
ChiSquaredDistribution --relatedTo--> StudentTDistribution
ChiSquaredDistribution --relatedTo--> FDistribution
ChiSquaredDistribution --tracesTo--> Provenance
InferenceRules := {
Z_i iid N(0,1)
⇒
Σ_iZ_i²~χ²_ν,
X~χ²_ν
⇒
E[X]=ν,
X~χ²_ν
⇒
Var(X)=2ν,
Independent(
X~χ²_ν1,
Y~χ²_ν2
)
⇒
X+Y~χ²_(ν1+ν2),
Xi iid N(μ,σ²)
⇒
(n-1)S²/σ²~χ²_(n-1),
χ²_ν
≡
Gamma(ν/2,rate=1/2),
ν≤0
⇒
InvalidChiSquaredDistribution
}
CanonicalChiSquaredRepresentation :=
ParseChiSquaredModel
→ ResolveRandomVariableOrStatistic
→ ResolveDegreesOfFreedom
→ ValidateDegreesOfFreedom
→ ResolveSupport
→ ConstructPDF
→ ConstructCDF
→ ComputeMoments
→ ResolveGammaNormalTOrFRelations
→ ResolveStatisticalTestContextIfPresent
→ ValidateChiSquaredDistribution
ChiSquaredDistributionGraph :=
G=(V,E)
V := {
ChiSquaredDistributions,
ChiSquaredRandomVariables,
DegreesOfFreedomNodes,
PDFs,
CDFs,
Means,
Variances,
GammaDistributions,
StandardNormals,
SampleVariances,
PearsonStatistics,
QuadraticForms,
StudentTDistributions,
FDistributions,
NoncentralChiSquaredDistributions,
Evidence,
ProvenanceNodes
}
E := {
distributionOf,
hasDegreesOfFreedom,
hasSupport,
hasPDF,
hasCDF,
hasMean,
hasVariance,
specialCaseOf,
sumOfSquaresOf,
derivedFrom,
usedFor,
relatedTo,
approximatedBy,
constrainedBy,
equivalentTo,
tracesTo
}
CONFIDENCE(ChiSquaredDistributionResolution) :=
weighted_mean(
RandomVariableOrStatisticResolution,
DegreesOfFreedomResolution,
SupportValidity,
PDFConsistency,
MomentConsistency,
ConstructionValidity,
StatisticalTestAssumptionQuality,
ProvenanceQuality
)
AI_QUERY_INTERPRETATION :=
Query
→ DetectChiSquaredDistributionIntent
→ IdentifyRandomVariableOrTestStatistic
→ ResolveDegreesOfFreedom
→ IdentifyRequestedProbabilityCriticalValueOrProperty
→ ResolveVarianceTestGoodnessOfFitOrIndependenceContext
AI_REASONING_FLOW :=
Query
→ ParseChiSquaredProblem
→ ResolveProbabilitySpace
→ ResolveChiSquaredRandomVariableOrStatistic
→ ResolveDegreesOfFreedom
→ ValidateDegreesOfFreedom
→ ConstructChiSquaredPDF
→ ConstructOrEvaluateChiSquaredCDF
→ ComputeTailProbabilityOrCriticalValueIfRequired
→ ComputeMeanVarianceOrMomentIfRequired
→ ResolveNormalSampleVarianceRelationIfRelevant
→ ResolveGoodnessOfFitOrIndependenceTestIfRelevant
→ ResolveTOrFDistributionRelationIfRelevant
→ ValidateChiSquaredModelAndAssumptions
→ UpdateConfidence
→ PreserveProvenance
→ GenerateExplanation
AI_CONSUMPTION := {
ParseChiSquaredDistributionEntities,
ParseTypedRelations,
ResolveChiSquaredRandomVariables,
ResolveDegreesOfFreedom,
EvaluateChiSquaredPDFs,
EvaluateChiSquaredCDFs,
ComputeTailProbabilities,
ComputeCriticalValues,
ComputeMeans,
ComputeVariances,
ResolveGammaRelations,
ResolveNormalSquareRelations,
ResolveSampleVarianceDistributions,
EvaluatePearsonChiSquaredStatistics,
ResolveGoodnessOfFitTests,
ResolveIndependenceTests,
ResolveStudentTRelations,
ResolveFDistributionRelations,
ResolveNoncentralChiSquaredModels,
ValidateChiSquaredDistributions,
CompareSemanticEquivalence,
UpdateConfidence,
PreserveProvenance,
GenerateFormalExplanation
}
UPDATE_MODEL :=
NewDataDegreesOfFreedomStatisticOrConstraint
→ ValidateInput
→ IdentifyAffectedChiSquaredClaims
→ UpdateChiSquaredState
→ RecomputePDF
→ RecomputeCDF
→ RecomputeTailProbabilitiesAndCriticalValues
→ RecomputeMoments
→ RevalidateTestRelations
→ RecomputeConfidence
→ PreserveProvenance
→ VersionModel
DegreesOfFreedomUpdate :=
ChangedDegreesOfFreedom
⇒ revalidate(ν>0)
→ recompute(
PDF,
CDF,
Mean,
Variance,
CriticalValues
)
StatisticUpdate :=
ChangedObservedStatistic
⇒ recompute(
TailProbability,
PValue,
DecisionRelevantEvidence
)
DataUpdate :=
NewSampleOrCountData
⇒ reevaluate(
DegreesOfFreedom,
TestStatistic,
ModelAssumptions,
Confidence
)
FLOW_HASH_INPUT :=
canonical(
ONTOLOGY,
CoreClasses,
CoreRelations,
InferenceRules,
ChiSquaredDistribution,
SumOfSquaresConstruction,
GammaRelation,
ChiSquaredValidation,
SEMANTIC_EQUIVALENCE,
AI_REASONING_FLOW
)
FLOW_HASH :=
HASH(FLOW_HASH_INPUT)
OUTPUT_MODEL := {
ChiSquaredDistributionEntityResolution,
ProbabilitySpace,
ChiSquaredRandomVariableOrStatistic,
DegreesOfFreedom,
Support,
PDF,
CDF,
TailProbability,
CriticalValue,
Mean,
Variance,
GammaRelation,
NormalSampleVarianceRelation,
StatisticalTestContext,
ValidationStatus,
Confidence,
Provenance,
Explanation
}
END_FLOW
END OF FULL EXECUTABLE FLOW ALGEBRA
Download Code
Copy to Clipboard