Can we change the estimated population mean in Hypothesis Testing? My goal is to learn hypothesis testing. My understanding is that we do not have the population data. Therefore, we do not know the estimated population mean. So, we guess the population mean. If that so, can we change the population mean until the p-value is below 0.05, so we have enough evidence to reject the null hypothesis?
The code
import pandas as pd
from scipy import stats

sample = pd.Series([1,2,3,4,5,6,7,8,9,10])

# Hypothesis Testing:
#
# H0: μ <= 3.5 (previously it was μ <= 5.5, 
#               then 5, then 4.5, I change it until I get p value less than 0.05)
# H1: μ > 3.5

t_stat, p_value = stats.ttest_1samp(a = sample, popmean=3.5, alternative="greater")

print("sample mean:", sample.mean())
print("t-statistic: {0:.2f} p-value: {1:.2f}".format(t_stat, p_value))

print("since we do not have the population data, "
      "popmean=3.5 is not meaningful, "
      "we can change it until we get enough evidence to reject the null hypothesis")

print("critical value: 5%, therefore confidence interval: 90%")

print("because p-value is below 0.05, we have enough evidence to reject the null hypothesis. "
      "therefore, we can conclude that the mean population is more than 3.5")

print("population standard deviation {0:.2f}".format(sample.std(ddof=0)))

print("if we imagine the sample as the weight of waste, the conclusion is, "
      "90% of population data is between population mean + 3 * population standard deviation, "
      "in this case 3.5 +- 3 * 2.87")
```


Expanding a bit over my comments to the post and in addition to @Christian Henning's answer, there is nothing special about hypothesis testing. Indeed, the rationale behind hypothesis testing and confidence intervals follows that of the Scientific Method, which we have been exposed to since middle school.
It is the usual cycle

Formulate a hypothesis -> run experiments and collect data -> analyse
data and look if your hypothesis is supported.

The data collected may not support your hypothesis and that's perfectly acceptable. In that case, there are two things happening:

*

*the hypothesis is true but the data are not enough or

*the hypothesis is actually not true.

If you do not get evidence about your hypothesis, you can either decide to collect new data or rethink the hypothesis...
Nevertheless, tailoring the scientific hypothesis to what the data say is scientifically the most terrible thing you could do, since

*

*Observed data are subject to randomness, i.e. your results may not be replicable.

*Data should and can only offer you evidence about a scientific theory, but they cannot tell WHY or IF the theory is TRUE. Truthiness has to be based on domain-specific arguments.

Thus, to sum up, you can make the data tell you what you want, but what you will get will be, at best, useless or harmful.
