Command Line Interface Reference
Real Simple Stats includes a command-line tool for quick calculations without writing Python code.
Installation and Setup
The CLI is automatically installed with the package:
pip install real-simple-stats
Verify installation:
rss-calc --help
Basic Usage
The CLI uses subcommands for different types of operations:
rss-calc <subcommand> [options]
Available subcommands:
stats- Descriptive statistics calculationsprobability- Probability calculationshypothesis- Hypothesis testingglossary- Statistical term lookup
Global Options
- --help, -h
Show help message and exit
- --version
Show version information
Statistics Commands
Calculate descriptive statistics for datasets.
Basic Usage
rss-calc stats --data "1,2,3,4,5" --stat mean
Options
- --data DATA
Comma-separated list of numeric values (required)
- --stat STATISTIC
Statistic to calculate. Options:
mean- Arithmetic meanmedian- Middle valuemode- Most frequent valuevariance- Population variancestd- Standard deviationcv- Coefficient of variationall- All available statistics
Examples
Calculate mean:
rss-calc stats --data "10,20,30,40,50" --stat mean
# Output: Mean: 30.0
Calculate all statistics:
rss-calc stats --data "1,2,2,3,4,5" --stat all
# Output:
# Mean: 2.83
# Median: 2.5
# Mode: 2
# Variance: 2.47
# Standard Deviation: 1.57
# Coefficient of Variation: 55.56%
Probability Commands
Perform probability calculations and work with distributions.
Basic Usage
rss-calc probability --type binomial --n 10 --k 3 --p 0.5
Options
- --type TYPE
Type of probability calculation:
binomial- Binomial probabilitynormal- Normal distribution (PDF or CDF)bayes- Bayes’ theorem
Normal Distribution Options
- --x X
Value at which to evaluate the PDF or CDF (required for normal)
- --mean MEAN
Mean of the normal distribution (default: 0.0)
- --std STD
Standard deviation of the normal distribution (default: 1.0, must be positive)
- --cdf
Calculate cumulative distribution function (CDF) instead of PDF
Binomial Distribution Options
- --n N
Number of trials (required for binomial, must be non-negative)
- --k K
Number of successes (required for binomial, must be between 0 and n)
- --p P
Probability of success (required for binomial, must be between 0 and 1)
Bayes’ Theorem Options
- --p_b_given_a P_B_GIVEN_A
Conditional probability P(B|A) (required, must be between 0 and 1)
- --p_a P_A
Prior probability P(A) (required, must be between 0 and 1)
- --p_b P_B
Prior probability P(B) (required, must be between 0 and 1, cannot be zero)
Combination/Permutation Options
- --n N
Total number of items
- --k K
Number of items to choose/arrange
Simple Probability Options
- --favorable F
Number of favorable outcomes
- --total T
Total number of possible outcomes
Examples
Normal distribution PDF:
rss-calc prob --type normal --x 0 --mean 0 --std 1
# Output: PDF(X = 0.0) = 0.398942
Normal distribution CDF:
rss-calc prob --type normal --x 1.96 --mean 0 --std 1 --cdf
# Output: P(X ≤ 1.96) = 0.975002
Binomial probability:
rss-calc prob --type binomial --n 10 --k 3 --p 0.5
# Output: P(X = 3) = 0.117188
Bayes’ theorem:
rss-calc prob --type bayes --p_b_given_a 0.9 --p_a 0.01 --p_b 0.05
# Output: P(A|B) = 0.180000
Hypothesis Testing Commands
Perform statistical hypothesis tests.
Basic Usage
rss-calc hypothesis --test t-test --data "1,2,3,4,5" --mu 3.0
Options
- --test TEST
Type of hypothesis test:
t-test- One-sample t-test
- --data DATA
Comma-separated sample data (required)
- --mu MU
Null hypothesis mean (required for t-test)
- --alpha ALPHA
Significance level (default: 0.05)
Examples
One-sample t-test:
rss-calc hypothesis --test t-test --data "23,25,27,24,26" --mu 24.0 --alpha 0.05
# Output:
# One-sample t-test:
# Sample data: [23.0, 25.0, 27.0, 24.0, 26.0]
# Null hypothesis mean: 24.0
# Significance level: α = 0.05
Glossary Commands
Look up definitions of statistical terms.
Basic Usage
rss-calc glossary --term "standard deviation"
Options
- --term TERM
Statistical term to look up (required)
- --list
List all available terms
Examples
Look up a term:
rss-calc glossary --term "p-value"
# Output: [Definition of p-value]
List all terms:
rss-calc glossary --list
# Output: [List of all available terms]
Advanced Usage
Piping and Redirection
Save results to file:
rss-calc stats --data "1,2,3,4,5" --stat all > results.txt
Use with other commands:
echo "10,20,30,40,50" | rss-calc stats --stat mean
Batch Processing
Process multiple datasets:
#!/bin/bash
datasets=("1,2,3,4,5" "10,20,30" "100,200,300,400")
for data in "${datasets[@]}"; do
echo "Dataset: $data"
rss-calc stats --data "$data" --stat mean
echo "---"
done
Integration with Scripts
Use in Python scripts:
import subprocess
result = subprocess.run([
'rss-calc', 'stats',
'--data', '1,2,3,4,5',
'--stat', 'mean'
], capture_output=True, text=True)
print(result.stdout)
Error Handling
Common Errors and Solutions
- Command not found: rss-calc
Ensure the package is installed:
pip install real-simple-statsCheck if it’s in your PATH
Try:
python -m real_simple_stats.cli --help
- Invalid data format
Use comma-separated values without spaces:
"1,2,3,4,5"Ensure all values are numeric
Quote the data string to prevent shell interpretation
- Missing required arguments
Check the help for required options:
rss-calc <subcommand> --helpThe CLI will tell you exactly which arguments are missing
- Invalid argument values
Binomial:
--nmust be non-negative,--kmust be between 0 and n,--pmust be between 0 and 1Normal:
--stdmust be positiveBayes: All probabilities must be between 0 and 1, and
--p_bcannot be zeroYou’ll get a specific error message explaining what’s wrong
- Invalid statistic type
Use
--stat allto see available optionsCheck spelling of statistic names
Tips and Best Practices
Quote your data: Always quote comma-separated data to prevent shell issues
Use meaningful filenames: When redirecting output, use descriptive names
Check help first: Use
--helpwith any command to see available optionsValidate your data: Ensure your input data makes sense for the calculation
Use appropriate precision: Consider rounding results for readability
Output Formats
The CLI provides human-readable output by default.
Getting More Help
Use
--helpwith any command for detailed usageCheck the main documentation for Python API details
Report CLI bugs on GitHub Issues
Request new CLI features through GitHub
The CLI is straightforward to use. Start with simple commands and explore more features as you need them.