Skip to content

Instantly share code, notes, and snippets.

@AviKav
Last active September 5, 2018 05:15
Show Gist options
  • Save AviKav/6e9732fbe406414b10a1cd6d722c390f to your computer and use it in GitHub Desktop.
Save AviKav/6e9732fbe406414b10a1cd6d722c390f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import scipy.stats
percentile_range = 50 # Centered in the middle of the distribution
math_lower = 650
math_upper = 740
reading_writing_lower = 650
reading_writing_upper = 710
math_average = (math_upper + math_lower) / 2
reading_writing_average = (reading_writing_upper + reading_writing_lower)/2
upper_percentile = (percentile_range / 2 + 50) / 100
upper_zscore = scipy.stats.norm.ppf(upper_percentile)
math_standard_deviation = (math_upper - math_average) / upper_zscore
reading_writing_standard_deviation = (reading_writing_upper - reading_writing_average) / upper_zscore
math_input = int(input('Math Score: '))
reading_writing_input = int(input('Reading & Writing Score: '))
math_percentile = scipy.stats.norm.cdf((math_input - math_average) / math_standard_deviation)
reading_writing_percentile = scipy.stats.norm.cdf((reading_writing_input - reading_writing_average) / reading_writing_standard_deviation)
print(f'Math: {math_percentile} Reading & Writing: {reading_writing_percentile}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment