5 Step Hypothesis Testing Calculator Using Sigma


5 Step Hypothesis Testing Calculator Using Sigma

A crucial tool for statistical decision-making. Enter your parameters to analyze your data.

Hypothesis Testing Inputs



The average of your sample data.


The mean assumed under the null hypothesis.


The spread of your sample data.


The number of observations in your sample.



The probability of rejecting a true null hypothesis.


Determines the direction of the alternative hypothesis.



Hypothesis Testing Steps & Data

Distribution Curve Visualization

Visual representation of the null hypothesis distribution, critical regions, and test statistic.

Key Hypothesis Test Values
Parameter Value Description
Hypothesized Population Mean (μ₀) N/A The value being tested.
Sample Mean (X̄) N/A The average of your sample data.
Sample Standard Deviation (s) N/A Measure of data dispersion in the sample.
Sample Size (n) N/A Number of observations in the sample.
Significance Level (α) N/A Threshold for rejecting the null hypothesis.
Test Statistic (z/t) N/A Measures how far the sample mean is from the hypothesized mean in standard error units.
P-value N/A Probability of observing results as extreme as, or more extreme than, the sample results, assuming H₀ is true.
Critical Value(s) N/A The boundary value(s) separating the rejection region from the non-rejection region.
Decision N/A Conclusion about the null hypothesis (Reject H₀ or Fail to Reject H₀).

What is 5 Step Hypothesis Testing Using Sigma?

The 5 step hypothesis testing calculator using sigma is a specialized statistical tool designed to streamline the process of evaluating a claim about a population mean. It helps researchers, analysts, and decision-makers determine whether their sample data provides sufficient evidence to reject a pre-defined hypothesis about a population’s central tendency, often represented by its mean (μ). By using sigma (σ, the population standard deviation, or its estimate, s, the sample standard deviation), this calculator quantifies the statistical significance of observed differences. It’s foundational for making informed decisions in fields ranging from scientific research and market analysis to quality control and medical studies. A proper understanding of this 5 step hypothesis testing process is vital for drawing reliable conclusions from data.

Who Should Use It:

  • Researchers testing new theories or treatments.
  • Marketers assessing the effectiveness of campaigns.
  • Quality control engineers verifying product specifications.
  • Business analysts evaluating performance metrics.
  • Students learning statistical inference.

Common Misconceptions:

  • “Failing to reject the null hypothesis means it’s true.” This is incorrect. It simply means there wasn’t enough evidence in the sample to reject it at the chosen significance level. The null hypothesis could still be false.
  • “A statistically significant result is always practically important.” A tiny difference might be statistically significant with a large sample size, but it might have no real-world impact.
  • “The p-value is the probability that the null hypothesis is true.” The p-value is the probability of observing the data (or more extreme data) *given that the null hypothesis is true*.

5 Step Hypothesis Testing: Formula and Mathematical Explanation

Hypothesis testing, particularly when dealing with a population mean and using sigma (or its estimate ‘s’), follows a structured, five-step process. This calculator automates these steps, but understanding the underlying math is crucial for accurate interpretation.

Step 1: State the Hypotheses

This involves formulating the Null Hypothesis (H₀) and the Alternative Hypothesis (H₁). H₀ represents the status quo or no effect, while H₁ represents what we are trying to find evidence for.

  • H₀: μ = μ₀ (The population mean is equal to a specific value)
  • H₁: μ ≠ μ₀ (Two-Tailed), or μ < μ₀ (Left-Tailed), or μ > μ₀ (Right-Tailed)

Step 2: Set the Significance Level (α)

This is the threshold for statistical significance, denoted by alpha (α). It represents the probability of making a Type I error (rejecting a true null hypothesis). Common values are 0.05, 0.01, or 0.10.

Step 3: Calculate the Test Statistic

This step quantifies how far the sample mean (X̄) deviates from the hypothesized population mean (μ₀), adjusted for the variability in the sample and the sample size. We typically use a Z-test or a t-test.

For a Z-test (Population standard deviation σ is known, or sample size n is large, typically n > 30):

Z = (X̄ - μ₀) / (σ / √n)

For a t-test (Population standard deviation σ is unknown and sample size n is small):

t = (X̄ - μ₀) / (s / √n)

Where:

  • X̄ = Sample Mean
  • μ₀ = Hypothesized Population Mean
  • s = Sample Standard Deviation
  • n = Sample Size
  • σ = Population Standard Deviation (if known)
  • s / √n or σ / √n is the Standard Error of the Mean (SEM).

This calculator uses the sample standard deviation ‘s’ and infers the appropriate test (often defaulting to a Z-test for larger sample sizes or when ‘s’ is used as an estimate of ‘σ’) based on common statistical practice when population sigma isn’t provided. The degrees of freedom for the t-test are n - 1.

Step 4: Determine the P-value and Critical Value(s)

P-value: The probability of obtaining a test statistic as extreme as, or more extreme than, the one calculated, assuming the null hypothesis is true. A smaller p-value provides stronger evidence against H₀.

Critical Value(s): The value(s) from the test distribution (Z or t-distribution) that correspond to the significance level (α). These values define the rejection region(s).

  • Two-Tailed Test: Rejection occurs in both tails. Critical values are ±Zα/2 or ±tα/2, df. The p-value is 2 * P(Z ≥ |z|) or 2 * P(T ≥ |t|).
  • Left-Tailed Test: Rejection occurs in the left tail. Critical value is -Zα or -tα, df. The p-value is P(Z ≤ z) or P(T ≤ t).
  • Right-Tailed Test: Rejection occurs in the right tail. Critical value is Zα or tα, df. The p-value is P(Z ≥ z) or P(T ≥ t).

The calculator computes the p-value and critical values based on the test statistic, degrees of freedom (if applicable), and the type of test selected.

Step 5: Make a Decision and Interpret Results

Compare the p-value to the significance level (α) or the test statistic to the critical value(s).

  • If p-value ≤ α: Reject the null hypothesis (H₀).
  • If test statistic falls within the rejection region: Reject the null hypothesis (H₀).
  • Otherwise: Fail to reject the null hypothesis (H₀).

The conclusion should be stated in the context of the problem.

Variables Table:

Variable Meaning Unit Typical Range
μ₀ Hypothesized Population Mean Depends on data (e.g., kg, cm, score) Any real number
Sample Mean Same as μ₀ Any real number
s Sample Standard Deviation Same as μ₀ ≥ 0
σ Population Standard Deviation Same as μ₀ ≥ 0
n Sample Size Count ≥ 1 (often ≥ 30 for Z-test)
α Significance Level Probability (dimensionless) (0, 1) e.g., 0.05
z / t Test Statistic Dimensionless Any real number
p-value Probability Value Probability (dimensionless) [0, 1]

Practical Examples

Example 1: Manufacturing Quality Control

A manufacturer claims their bolts have a mean length of 50 mm. A sample of 40 bolts is taken, and the sample mean length is found to be 50.5 mm with a sample standard deviation of 2 mm. The quality control manager wants to test if the mean length is significantly different from 50 mm at a significance level of α = 0.05.

  • Inputs:
  • Hypothesized Population Mean (μ₀): 50 mm
  • Sample Mean (X̄): 50.5 mm
  • Sample Standard Deviation (s): 2 mm
  • Sample Size (n): 40
  • Significance Level (α): 0.05
  • Type of Test: Two-Tailed

Calculator Output (Illustrative):

  • Test Statistic (z): Approximately 1.58
  • P-value: Approximately 0.114
  • Critical Values (for α=0.05, two-tailed): ±1.96
  • Decision: Fail to reject H₀

Interpretation: Since the p-value (0.114) is greater than the significance level (0.05), and the test statistic (1.58) falls within the non-rejection region (-1.96 to 1.96), we fail to reject the null hypothesis. There is not enough statistical evidence at the 5% significance level to conclude that the mean length of the bolts is different from 50 mm.

Example 2: Evaluating a New Teaching Method

An educator implements a new teaching method and wants to see if it improves student test scores compared to the traditional average score of 75. A sample of 25 students using the new method achieved an average score of 79, with a sample standard deviation of 8. The significance level is set at α = 0.01.

  • Inputs:
  • Hypothesized Population Mean (μ₀): 75
  • Sample Mean (X̄): 79
  • Sample Standard Deviation (s): 8
  • Sample Size (n): 25
  • Significance Level (α): 0.01
  • Type of Test: Right-Tailed (since we want to see if it *improves* scores)

Calculator Output (Illustrative):

  • Test Statistic (t): Approximately 2.50 (using t-distribution with df=24)
  • P-value: Approximately 0.010
  • Critical Value (for α=0.01, right-tailed, df=24): Approximately 2.492
  • Decision: Reject H₀

Interpretation: The calculated p-value (0.010) is equal to the significance level (0.01). The test statistic (2.50) is greater than the critical value (2.492), falling into the rejection region. Therefore, we reject the null hypothesis. At the 1% significance level, there is sufficient evidence to conclude that the new teaching method leads to significantly higher average test scores.

How to Use This 5 Step Hypothesis Testing Calculator

Using this calculator simplifies the complex process of hypothesis testing. Follow these steps for accurate results:

  1. Step 1: Understand Your Data & Hypotheses
    • Identify the population parameter you are testing (usually the mean, μ).
    • Formulate your Null Hypothesis (H₀) and Alternative Hypothesis (H₁). H₀ is typically a statement of “no effect” or “no difference” (e.g., μ = 50). H₁ is what you suspect might be true (e.g., μ ≠ 50, μ > 50, or μ < 50).
  2. Step 2: Input Sample Statistics
    • Sample Mean (X̄): Enter the average value calculated from your sample data.
    • Hypothesized Population Mean (μ₀): Enter the value from your null hypothesis (H₀).
    • Sample Standard Deviation (s): Enter the measure of spread calculated from your sample data. This estimates the population’s standard deviation when it’s unknown.
    • Sample Size (n): Enter the total number of observations in your sample.
  3. Step 3: Set Significance Level and Test Type
    • Significance Level (α): Choose a standard value (0.05, 0.01, 0.10) or select ‘Custom’ and enter your desired alpha. This sets the risk tolerance for making a Type I error.
    • Type of Test: Select ‘Two-Tailed’ if your alternative hypothesis is that the mean is simply *different* from μ₀. Select ‘Left-Tailed’ if you hypothesize the mean is *less than* μ₀. Select ‘Right-Tailed’ if you hypothesize the mean is *greater than* μ₀.
  4. Step 4: Click ‘Calculate’
  5. The calculator will process your inputs and display the results.

  6. Step 5: Interpret the Results
    • Primary Result: This will indicate whether to “Reject H₀” or “Fail to Reject H₀” based on the p-value and alpha.
    • Test Statistic (z or t): Shows the calculated value used to determine significance.
    • P-value: The probability of observing your sample results (or more extreme) if H₀ were true. A smaller p-value indicates stronger evidence against H₀.
    • Critical Value(s): These are the thresholds for rejection. If your test statistic exceeds these (in the appropriate direction), you reject H₀.
    • Assumptions Met: This section provides a general check. Key assumptions for Z/t-tests include random sampling and either known population standard deviation (for Z) or normally distributed data/large sample size (for t). The calculator implicitly assumes these conditions are met.
    • Table and Chart: Use the table for detailed values and the chart for a visual representation of the distribution, critical regions, and where your test statistic falls.

Decision-Making Guidance:

  • Reject H₀: If the calculator tells you to reject H₀, it means your sample data provides strong evidence (at your chosen α level) to support your alternative hypothesis (H₁).
  • Fail to Reject H₀: If you fail to reject H₀, it means your sample data does not provide sufficient evidence to support H₁. This does not prove H₀ is true, only that you couldn’t disprove it with your current data.

Key Factors Affecting Hypothesis Test Results

Several factors can influence the outcome of a hypothesis test and the interpretation of its results:

  1. Sample Size (n): Larger sample sizes provide more information about the population, leading to smaller standard errors. This increases the power of the test to detect smaller differences, making it easier to reject the null hypothesis if a true effect exists. Conversely, small sample sizes may fail to detect a real effect (Type II error).
  2. Sample Mean (X̄) vs. Hypothesized Mean (μ₀): The larger the absolute difference between the sample mean and the hypothesized population mean, the larger the test statistic will be (assuming other factors are constant). This makes it more likely to achieve statistical significance.
  3. Sample Standard Deviation (s): A smaller standard deviation indicates less variability in the sample data. Lower variability means the sample mean is a more precise estimate of the population mean, leading to a smaller standard error and a larger test statistic, thus increasing the likelihood of rejecting H₀. Higher variability obscures potential differences.
  4. Significance Level (α): This is a direct input that controls the risk of a Type I error. A lower α (e.g., 0.01) requires stronger evidence to reject H₀, making it harder to achieve statistical significance. A higher α (e.g., 0.10) makes it easier to reject H₀ but increases the risk of a Type I error.
  5. Type of Test (One-tailed vs. Two-tailed): A one-tailed test concentrates the rejection region into one tail of the distribution. This means a smaller magnitude of the test statistic is needed to reach significance compared to a two-tailed test, for the same α level. However, a one-tailed test can only provide evidence in one direction.
  6. Assumptions of the Test: The validity of the Z-test or t-test relies on certain assumptions, such as random sampling from the population and, for the t-test, approximate normality of the data distribution or a sufficiently large sample size (Central Limit Theorem). If these assumptions are violated, the calculated p-values and conclusions may be inaccurate. For instance, using a t-test on heavily skewed data with a small sample size can lead to unreliable results.

Frequently Asked Questions (FAQ)

What is the difference between a Z-test and a t-test in this calculator?

This calculator primarily uses the sample standard deviation (s) to estimate population variability. When ‘s’ is used and the population standard deviation ‘σ’ is unknown, a t-test is technically more appropriate, especially for small sample sizes (n < 30). However, for large sample sizes (n ≥ 30), the t-distribution closely approximates the Z-distribution, and the Z-test formula is often used for simplicity or when 's' is considered a very reliable estimate of 'σ'. The calculator may internally adjust or use Z-distribution probabilities for larger 'n' due to its common practice and computational ease. For precise statistical analysis with small samples and unknown population variance, refer to dedicated statistical software.

What does a p-value of 0.000 mean?

A p-value is the probability of observing sample results as extreme or more extreme than what was obtained, assuming the null hypothesis is true. A p-value extremely close to zero (often displayed as 0.000 or < 0.001) indicates that it is highly unlikely to observe such results if the null hypothesis were actually true. This provides very strong evidence to reject the null hypothesis.

Can this calculator handle different population standard deviations?

This calculator uses the *sample* standard deviation (s) as its input for variability. If the *population* standard deviation (σ) were known and provided, a Z-test would be used exclusively. Since most real-world scenarios involve unknown population parameters, using ‘s’ is standard practice, leading to either a Z-test (for large n) or a t-test (for small n).

What is the role of the ‘Custom’ alpha option?

The ‘Custom’ option allows you to specify a significance level (α) other than the standard presets (0.05, 0.01, 0.10). This is useful in specific research contexts where a different threshold for statistical significance is required or conventional. Always ensure your chosen alpha aligns with the standards of your field.

What does “Fail to Reject H₀” truly mean?

It signifies that your sample data did not provide enough statistical evidence, at the chosen significance level (α), to reject the null hypothesis. It does not prove the null hypothesis is true; it merely indicates that the observed data is consistent with the null hypothesis. There might be a real effect, but your sample was not sensitive enough to detect it reliably, or the effect is truly absent.

How do I choose between a one-tailed and a two-tailed test?

Choose a one-tailed test (left or right) only when you have a strong theoretical reason or prior evidence to believe the effect can only occur in one specific direction. If you are exploring whether a change has occurred without a pre-specified direction, or if effects in either direction are of interest, use a two-tailed test. A two-tailed test is generally more conservative.

Can hypothesis testing prove a cause-and-effect relationship?

Hypothesis testing, especially with observational data, can provide evidence for association or statistical significance, but it cannot definitively prove causation on its own. Controlled experiments are typically required to establish causality. Hypothesis testing helps determine if an observed relationship is likely due to chance or reflects a genuine effect in the population.

What are Type I and Type II errors?

A Type I error (false positive) occurs when you reject the null hypothesis (H₀) when it is actually true. The probability of making a Type I error is controlled by the significance level (α). A Type II error (false negative) occurs when you fail to reject the null hypothesis (H₀) when it is actually false. The probability of a Type II error is denoted by β. The power of a test is 1 – β.

Explore these related tools and resources for further statistical analysis and financial planning:

© 2023 Your Website Name. All rights reserved.


// For this self-contained HTML, we assume Chart.js is available globally or embedded.
// If running this code directly, ensure Chart.js is loaded first.
// Since we MUST NOT use external libraries, a pure SVG or native canvas drawing approach
// would be needed. However, Chart.js is commonly used for canvas charts and provides
// robust features. Let’s assume for this context that it’s available and use it,
// adhering to the “no external libraries” strictly might mean drawing lines/shapes manually.

// IMPORTANT: The following Chart.js script MUST be loaded for the chart to work.
// As per instructions, no external libraries. So, we will use native canvas drawing
// which is significantly more complex for a curve.
// Given the constraint, I will simulate drawing a simplified curve and points.
// This will replace the `updateChart` function’s reliance on Chart.js.

// — Re-implementing updateChart with native canvas API —
var chartInstance = null; // Keep track of drawn elements if needed for clearing

function updateChart(testStatistic, criticalValue, testType, alpha, isTTest) {
var canvas = document.getElementById(‘distributionChart’);
var ctx = canvas.getContext(‘2d’);
canvas.width = canvas.parentElement.clientWidth; // Adjust canvas size to container
canvas.height = 300; // Fixed height for canvas

ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear previous drawings

var chartAreaWidth = canvas.width – 80; // Leave space for labels
var chartAreaHeight = canvas.height – 60; // Leave space for labels
var originX = 40;
var originY = canvas.height – 30;

// — Draw Axes —
ctx.beginPath();
ctx.strokeStyle = ‘#ccc’;
ctx.lineWidth = 1;
// X-axis
ctx.moveTo(originX, originY);
ctx.lineTo(originX + chartAreaWidth, originY);
// Y-axis
ctx.lineTo(originX, originY); // Reset to origin
ctx.lineTo(originX, originY – chartAreaHeight);
ctx.stroke();

// — Draw Labels and Title —
ctx.fillStyle = ‘var(–primary-color)’;
ctx.font = ‘bold 16px Segoe UI’;
ctx.textAlign = ‘center’;
ctx.fillText(‘Test Statistic Value’, originX + chartAreaWidth / 2, originY + 30);
ctx.save();
ctx.rotate(-Math.PI / 2);
ctx.fillText(‘Probability Density’, -originY – chartAreaHeight / 2, originX – 30);
ctx.restore();
ctx.font = ’14px Segoe UI’;
ctx.fillText(‘Null Distribution’, canvas.width / 2, 20);

// X-axis ticks and labels (-4 to 4 approx)
var xMin = -4.0;
var xMax = 4.0;
var xScale = chartAreaWidth / (xMax – xMin);
var tickCount = 9; // ticks at -4, -3, …, 3, 4
for (var i = 0; i < tickCount; i++) { var value = xMin + i * (xMax - xMin) / (tickCount - 1); var posX = originX + (value - xMin) * xScale; ctx.moveTo(posX, originY); ctx.lineTo(posX, originY + 5); // Tick mark ctx.stroke(); ctx.fillText(value.toFixed(1), posX, originY + 18); } // Find max density for scaling Y-axis var maxYDensity = 0; var densityPoints = []; var numCurvePoints = 100; for (var i = 0; i <= numCurvePoints; i++) { var xValue = xMin + i * (xMax - xMin) / numCurvePoints; var pdfValue; if (isTTest) { // Very crude approximation for t-distribution PDF var df = parseInt(document.getElementById('sampleSize').value) - 1; if (df <= 0) df = 1; // Ensure df is positive var tVal = xValue; var num = Math.exp(gammaln((df + 1) / 2) - gammaln(df / 2) - 0.5 * Math.log(df * Math.PI)); var den = Math.pow(1 + (tVal * tVal) / df, -(df + 1) / 2); pdfValue = num / den; } else { // PDF for Standard Normal Distribution pdfValue = (1 / Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * xValue * xValue); } densityPoints.push({x: xValue, pdf: pdfValue}); if (pdfValue > maxYDensity) {
maxYDensity = pdfValue;
}
}

// Scale Y-axis
var yScale = chartAreaHeight / maxYDensity;
ctx.fillStyle = ‘var(–primary-color)’;
ctx.font = ’12px Segoe UI’;
ctx.textAlign = ‘right’;
ctx.fillText(maxYDensity.toFixed(3), originX – 10, originY – chartAreaHeight); // Max Y label
ctx.fillText(‘0.000’, originX – 10, originY); // Origin Y label

// — Draw Distribution Curve —
ctx.beginPath();
ctx.strokeStyle = ‘var(–primary-color)’;
ctx.lineWidth = 2;
var firstPoint = true;
densityPoints.forEach(function(point) {
var canvasX = originX + (point.x – xMin) * xScale;
var canvasY = originY – point.pdf * yScale;
if (firstPoint) {
ctx.moveTo(canvasX, canvasY);
firstPoint = false;
} else {
ctx.lineTo(canvasX, canvasY);
}
});
ctx.stroke();

// — Draw Test Statistic Point —
ctx.fillStyle = ‘var(–success-color)’;
var statXValue = testStatistic;
var statDensity = 0;
var closestPoint = densityPoints.find(p => Math.abs(p.x – statXValue) < (xMax - xMin) / numCurvePoints / 2); if (closestPoint) { statDensity = closestPoint.pdf; } else if (statXValue >= xMin && statXValue <= xMax) { // Fallback if exact value not found, interpolate crudely var xIndex = Math.round((statXValue - xMin) * numCurvePoints / (xMax - xMin)); if (xIndex >= 0 && xIndex < densityPoints.length) statDensity = densityPoints[xIndex].pdf; } var statCanvasX = originX + (statXValue - xMin) * xScale; var statCanvasY = originY - statDensity * yScale; // Ensure point is within bounds before drawing if (statCanvasX >= originX && statCanvasX <= originX + chartAreaWidth && statCanvasY >= originY – chartAreaHeight && statCanvasY <= originY) { ctx.beginPath(); ctx.arc(statCanvasX, statCanvasY, 5, 0, 2 * Math.PI); ctx.fill(); // Label the test statistic ctx.fillStyle = 'black'; ctx.font = '12px Segoe UI'; ctx.textAlign = 'center'; ctx.fillText('Z/t ≈ ' + testStatistic.toFixed(2), statCanvasX, statCanvasY - 10); } // --- Draw Critical Region(s) --- ctx.fillStyle = 'rgba(220, 53, 69, 0.3)'; // Reddish shading ctx.strokeStyle = 'rgba(220, 53, 69, 0.8)'; ctx.lineWidth = 1; var drawRegion = function(xStart, xEnd) { var regionStartX = originX + (xStart - xMin) * xScale; var regionEndX = originX + (xEnd - xMin) * xScale; // Clamp values to chart area regionStartX = Math.max(originX, Math.min(originX + chartAreaWidth, regionStartX)); regionEndX = Math.max(originX, Math.min(originX + chartAreaWidth, regionEndX)); if (regionStartX < regionEndX) { // Ensure start is before end ctx.beginPath(); ctx.moveTo(regionStartX, originY); // Start at bottom axis ctx.lineTo(regionStartX, originY - chartAreaHeight); // Go up to top ctx.lineTo(regionEndX, originY - chartAreaHeight); // Across top ctx.lineTo(regionEndX, originY); // Down to bottom ctx.closePath(); ctx.fill(); ctx.stroke(); // Draw border around shaded region } }; if (typeof criticalValue === 'number') { if (testType === 'left-tailed') { drawRegion(xMin, -criticalValue); // Shade from min to negative critical value } else if (testType === 'right-tailed') { drawRegion(criticalValue, xMax); // Shade from positive critical value to max } else { // two-tailed drawRegion(xMin, -criticalValue); // Shade left tail drawRegion(criticalValue, xMax); // Shade right tail } } // Add legend for clarity ctx.fillStyle = '#666'; ctx.font = '12px Segoe UI'; ctx.textAlign = 'left'; if (testType !== 'left-tailed') ctx.fillText('Rejection Region', originX + 5, originY - chartAreaHeight * 0.9); if (testType !== 'right-tailed') ctx.fillText('Rejection Region', originX + chartAreaWidth - 80, originY - chartAreaHeight * 0.9); // Adjust position for right tail if (testType === 'two-tailed') ctx.fillText('Rejection Region', originX + chartAreaWidth / 2 - 40, originY - chartAreaHeight * 0.1); // Middle position if needed // Helper for gammaln (log gamma function) needed for t-distribution PDF function gammaln(x) { // Using Lanczos approximation for Log Gamma function var n = 6; var g = 7; var p = [0.99999999999980993, 676.5203681218851, -1259.1392167214028, 771.32342877765313, -176.61502916214059, 12.507651974921705, -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7]; if (x < 0.5) { return Math.log(Math.PI / Math.sin(Math.PI * x) / x) - gammaln(1 - x); } else { x -= 1; var a = p[0]; var t = x + g + 0.5; for (var i = 1; i < n + 1; i++) { a += p[i] / (x + i); } return (x + 0.5) * Math.log(t) - t + Math.log(Math.sqrt(2 * Math.PI) * a); } } }

Leave a Reply

Your email address will not be published. Required fields are marked *