analysistoolbox 2.2.1__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/PKG-INFO +1 -1
  2. analysistoolbox-2.2.2/analysistoolbox/probability/ProbabilityOfHypothesisGivenData.py +129 -0
  3. analysistoolbox-2.2.2/analysistoolbox/probability/__init__.py +2 -0
  4. analysistoolbox-2.2.2/analysistoolbox/simulations/CreateCorrelatedSIPs.py +186 -0
  5. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/__init__.py +1 -0
  6. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox.egg-info/PKG-INFO +1 -1
  7. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox.egg-info/SOURCES.txt +2 -0
  8. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/setup.py +1 -1
  9. analysistoolbox-2.2.1/analysistoolbox/probability/__init__.py +0 -1
  10. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/LICENSE.md +0 -0
  11. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/README.md +0 -0
  12. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/__init__.py +0 -0
  13. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/calculus/FindDerivative.py +0 -0
  14. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/calculus/FindLimitOfFunction.py +0 -0
  15. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/calculus/FindMinimumSquareLoss.py +0 -0
  16. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/calculus/PlotFunction.py +0 -0
  17. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/calculus/__init__.py +0 -0
  18. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/ExtractTextFromPDF.py +0 -0
  19. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/FetchPDFFromURL.py +0 -0
  20. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/FetchUSShapefile.py +0 -0
  21. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/FetchWebsiteText.py +0 -0
  22. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/GetCompanyFilings.py +0 -0
  23. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/GetGoogleSearchResults.py +0 -0
  24. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/GetZipFile.py +0 -0
  25. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_collection/__init__.py +0 -0
  26. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/AddDateNumberColumns.py +0 -0
  27. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/AddLeadingZeros.py +0 -0
  28. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/AddRowCountColumn.py +0 -0
  29. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/AddTPeriodColumn.py +0 -0
  30. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/AddTukeyOutlierColumn.py +0 -0
  31. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/CleanTextColumns.py +0 -0
  32. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/ConductAnomalyDetection.py +0 -0
  33. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/ConductEntityMatching.py +0 -0
  34. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/ConvertOddsToProbability.py +0 -0
  35. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/CountMissingDataByGroup.py +0 -0
  36. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/CreateBinnedColumn.py +0 -0
  37. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/CreateDataOverview.py +0 -0
  38. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/CreateRandomSampleGroups.py +0 -0
  39. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/CreateRareCategoryColumn.py +0 -0
  40. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/CreateStratifiedRandomSampleGroups.py +0 -0
  41. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/GeocodeUSAddresses.py +0 -0
  42. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/ImputeMissingValuesUsingNearestNeighbors.py +0 -0
  43. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/VerifyGranularity.py +0 -0
  44. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/data_processing/__init__.py +0 -0
  45. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/ConductManifoldLearning.py +0 -0
  46. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/ConductPrincipalComponentAnalysis.py +0 -0
  47. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/ConductPropensityScoreMatching.py +0 -0
  48. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/CreateAssociationRules.py +0 -0
  49. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/CreateGaussianMixtureClusters.py +0 -0
  50. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/CreateHierarchicalClusters.py +0 -0
  51. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/CreateKMeansClusters.py +0 -0
  52. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/GenerateEDAWithLIDA.py +0 -0
  53. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/descriptive_analytics/__init__.py +0 -0
  54. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/file_management/ConvertWordDocsToPDF.py +0 -0
  55. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/file_management/CreateCopyOfPDF.py +0 -0
  56. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/file_management/CreateFileTree.py +0 -0
  57. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/file_management/ImportDataFromFolder.py +0 -0
  58. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/file_management/__init__.py +0 -0
  59. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/ChiSquareTestOfIndependence.py +0 -0
  60. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/ChiSquareTestOfIndependenceFromTable.py +0 -0
  61. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/ConductCoxProportionalHazardRegression.py +0 -0
  62. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/ConductLinearRegressionAnalysis.py +0 -0
  63. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/ConductLogisticRegressionAnalysis.py +0 -0
  64. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/ConductSurvivalAnalysis.py +0 -0
  65. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/OneSampleTTest.py +0 -0
  66. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/OneWayANOVA.py +0 -0
  67. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/TTestOfMeanFromStats.py +0 -0
  68. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/TTestOfProportionFromStats.py +0 -0
  69. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/TTestOfTwoMeansFromStats.py +0 -0
  70. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/TwoSampleTTestOfIndependence.py +0 -0
  71. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/TwoSampleTTestPaired.py +0 -0
  72. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/hypothesis_testing/__init__.py +0 -0
  73. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/linear_algebra/CalculateEigenvalues.py +0 -0
  74. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/linear_algebra/ConvertMatrixToRowEchelonForm.py +0 -0
  75. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/linear_algebra/ConvertSystemOfEquationsToMatrix.py +0 -0
  76. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/linear_algebra/PlotVectors.py +0 -0
  77. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/linear_algebra/SolveSystemOfEquations.py +0 -0
  78. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/linear_algebra/VisualizeMatrixAsLinearTransformation.py +0 -0
  79. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/linear_algebra/__init__.py +0 -0
  80. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/llm/SendPromptToAnthropic.py +0 -0
  81. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/llm/SendPromptToChatGPT.py +0 -0
  82. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/llm/__init__.py +0 -0
  83. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/predictive_analytics/CreateARIMAModel.py +0 -0
  84. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/predictive_analytics/CreateBoostedTreeModel.py +0 -0
  85. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/predictive_analytics/CreateDecisionTreeModel.py +0 -0
  86. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/predictive_analytics/CreateLinearRegressionModel.py +0 -0
  87. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/predictive_analytics/CreateLogisticRegressionModel.py +0 -0
  88. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/predictive_analytics/CreateNeuralNetwork_SingleOutcome.py +0 -0
  89. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/predictive_analytics/__init__.py +0 -0
  90. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/prescriptive_analytics/CreateContentBasedRecommender.py +0 -0
  91. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/prescriptive_analytics/__init__.py +0 -0
  92. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/probability/ProbabilityOfAtLeastOne.py +0 -0
  93. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/CreateMetalogDistribution.py +0 -0
  94. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/CreateMetalogDistributionFromPercentiles.py +0 -0
  95. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/CreateSIPDataframe.py +0 -0
  96. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/CreateSLURPDistribution.py +0 -0
  97. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/SimulateCountOfSuccesses.py +0 -0
  98. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/SimulateCountOutcome.py +0 -0
  99. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/SimulateCountUntilFirstSuccess.py +0 -0
  100. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/SimulateNormallyDistributedOutcome.py +0 -0
  101. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/SimulateTDistributedOutcome.py +0 -0
  102. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/SimulateTimeBetweenEvents.py +0 -0
  103. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/SimulateTimeUntilNEvents.py +0 -0
  104. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/pymetalog/__init__.py +0 -0
  105. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/pymetalog/a_vector.py +0 -0
  106. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/pymetalog/class_method.py +0 -0
  107. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/pymetalog/metalog.py +0 -0
  108. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/pymetalog/pdf_quantile_functions.py +0 -0
  109. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/simulations/pymetalog/support.py +0 -0
  110. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/statistics/CalculateConfidenceIntervalOfMean.py +0 -0
  111. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/statistics/CalculateConfidenceIntervalOfProportion.py +0 -0
  112. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/statistics/__init__.py +0 -0
  113. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/Plot100PercentStackedBarChart.py +0 -0
  114. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotBarChart.py +0 -0
  115. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotBoxWhiskerByGroup.py +0 -0
  116. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotBulletChart.py +0 -0
  117. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotCard.py +0 -0
  118. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotClusteredBarChart.py +0 -0
  119. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotContingencyHeatmap.py +0 -0
  120. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotCorrelationMatrix.py +0 -0
  121. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotDensityByGroup.py +0 -0
  122. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotDotPlot.py +0 -0
  123. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotHeatmap.py +0 -0
  124. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotOverlappingAreaChart.py +0 -0
  125. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotRiskTolerance.py +0 -0
  126. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotScatterplot.py +0 -0
  127. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotSingleVariableCountPlot.py +0 -0
  128. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotSingleVariableHistogram.py +0 -0
  129. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/PlotTimeSeries.py +0 -0
  130. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/RenderTableOne.py +0 -0
  131. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox/visualizations/__init__.py +0 -0
  132. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox.egg-info/dependency_links.txt +0 -0
  133. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox.egg-info/requires.txt +0 -0
  134. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/analysistoolbox.egg-info/top_level.txt +0 -0
  135. {analysistoolbox-2.2.1 → analysistoolbox-2.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: analysistoolbox
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: A collection tools in Python for data collection and processing, statistics, analytics, and intelligence analysis.
5
5
  Home-page: https://github.com/KyleProtho/AnalysisToolBox/tree/master/analysistoolbox
6
6
  Author: Kyle Protho
@@ -0,0 +1,129 @@
1
+ # Load packages
2
+
3
+ # Declare function
4
+ def ProbabilityOfHypothesisGivenData(prior_probability_of_hypothesis_being_true,
5
+ prior_probability_of_data_given_hypothesis_being_true,
6
+ prior_probability_of_data_given_hypothesis_being_false,
7
+ return_results=False,
8
+ # Payoff estimates
9
+ payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true=None,
10
+ payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false=None,
11
+ payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true=None,
12
+ payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false=None):
13
+ """
14
+ This function calculates the probability of a hypothesis given the data using Bayes' Theorem.
15
+
16
+ Args:
17
+ prior_probability_of_hypothesis_being_true (float): The prior probability (your initial belief) of the hypothesis being true.
18
+ prior_probability_of_data_given_hypothesis_being_true (float): The prior probability (your initial belief) of the data given the hypothesis is true.
19
+ prior_probability_of_data_given_hypothesis_being_false (float): The prior probability (your initial belief) of the data given the hypothesis is false.
20
+ """
21
+
22
+ # Ensure the prior probabilities are between 0 and 1
23
+ if prior_probability_of_hypothesis_being_true < 0 or prior_probability_of_hypothesis_being_true > 1:
24
+ raise ValueError("The prior probability of the hypothesis being true must be between 0 and 1.")
25
+ if prior_probability_of_data_given_hypothesis_being_true < 0 or prior_probability_of_data_given_hypothesis_being_true > 1:
26
+ raise ValueError("The prior probability of the data given the hypothesis is true must be between 0 and 1.")
27
+ if prior_probability_of_data_given_hypothesis_being_false < 0 or prior_probability_of_data_given_hypothesis_being_false > 1:
28
+ raise ValueError("The prior probability of the data given the hypothesis is false must be between 0 and 1.")
29
+
30
+ # Ensure that if any payoffs are provided, all four are provided
31
+ if payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true is not None and payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false is not None and payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true is not None and payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false is not None:
32
+ if payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true < 0 or payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false < 0 or payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true < 0 or payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false < 0:
33
+ raise ValueError("The payoffs must be non-negative.")
34
+
35
+ # Calculate the prior probability of hypothesis not being true
36
+ prior_probability_of_hypothesis_being_false = 1 - prior_probability_of_hypothesis_being_true
37
+ # print("The prior probability of the hypothesis being false is:", prior_probability_of_hypothesis_being_false)
38
+
39
+ # Calculate the posterior probability of observing the data
40
+ p_of_data = (prior_probability_of_hypothesis_being_true * prior_probability_of_data_given_hypothesis_being_true) + (prior_probability_of_hypothesis_being_false * prior_probability_of_data_given_hypothesis_being_false)
41
+ print("The posterior probability of the data (under the assumption that the data is a valid observation and not due to noise or error) is:", format(p_of_data, ".1%"))
42
+
43
+ # Calculate the posterior probability of not observing the data
44
+ p_of_not_data = 1 - p_of_data
45
+ print("The posterior probability of the data NOT being observed (i.e., the data/evidence is not what you expected it to be) is:", format(p_of_not_data, ".1%"))
46
+
47
+ # Calculate the posterior probability of the hypothesis given the data
48
+ p_of_hypothesis_being_true_given_data = (prior_probability_of_hypothesis_being_true * prior_probability_of_data_given_hypothesis_being_true) / p_of_data
49
+ print("\nThe posterior probability of the hypothesis being true given the data (under the assumption that the data is a valid observation and not due to noise or error) is:", format(p_of_hypothesis_being_true_given_data, ".1%"))
50
+
51
+ # Calculate the posterior probability of the hypothesis given the data
52
+ p_of_hypothesis_being_false_given_data = (prior_probability_of_hypothesis_being_false * prior_probability_of_data_given_hypothesis_being_false) / p_of_data
53
+ print("The posterior probability of the hypothesis being false given the data (under the assumption that the data is a valid observation and not due to noise or error) is:", format(p_of_hypothesis_being_false_given_data, ".1%"))
54
+
55
+ # Calculate the posterior probability of the hypothesis given the data
56
+ p_of_hypothesis_being_true_given_not_data = (prior_probability_of_hypothesis_being_true * (1 - prior_probability_of_data_given_hypothesis_being_true)) / p_of_not_data
57
+ print("\nThe posterior probability of the hypothesis being true given data NOT being observed (i.e., the data/evidence is not what you expected it to be) is:", format(p_of_hypothesis_being_true_given_not_data, ".1%"))
58
+
59
+ # Calculate the posterior probability of the hypothesis given the data
60
+ p_of_hypothesis_being_false_given_not_data = (prior_probability_of_hypothesis_being_false * (1 - prior_probability_of_data_given_hypothesis_being_false)) / p_of_not_data
61
+ print("The posterior probability of the hypothesis being false given data NOT being observed (i.e., the data/evidence is not what you expected it to be) is:", format(p_of_hypothesis_being_false_given_not_data, ".1%"))
62
+
63
+ # If payoff information provided....
64
+ if payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true is not None and payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false is not None and payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true is not None and payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false is not None:
65
+ # Calculate the value of bets on the hypothesis being true
66
+ value_of_bet_on_hypothesis_being_true = (payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true * prior_probability_of_hypothesis_being_true) + (payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false * prior_probability_of_hypothesis_being_false)
67
+ print("\nThe value of bets on the hypothesis being true is:", format(value_of_bet_on_hypothesis_being_true, ".2f"))
68
+
69
+ # Calculate the value of bets on the hypothesis being false
70
+ value_of_bet_on_hypothesis_being_false = (payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true * prior_probability_of_hypothesis_being_true) + (payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false * prior_probability_of_hypothesis_being_false)
71
+ print("The value of bets on the hypothesis being false is:", format(value_of_bet_on_hypothesis_being_false, ".2f"))
72
+
73
+ # Get the maximum value of bets
74
+ max_value_of_bets = max(value_of_bet_on_hypothesis_being_true, value_of_bet_on_hypothesis_being_false)
75
+
76
+ # Calculate the expected value of on the hypothesis being true given the data
77
+ expected_value_of_bets_on_hypothesis_being_true_given_data = (payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true * p_of_hypothesis_being_true_given_data) + (payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false * p_of_hypothesis_being_false_given_data)
78
+ print("\nThe expected value of bets on the hypothesis being true given the data (under the assumption that the data is a valid observation and not due to noise or error) is:", format(expected_value_of_bets_on_hypothesis_being_true_given_data, ".2f"))
79
+
80
+ # Calculate the expected value of on the hypothesis being false given the data
81
+ expected_value_of_bets_on_hypothesis_being_false_given_data = (payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true * p_of_hypothesis_being_true_given_data) + (payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false * p_of_hypothesis_being_false_given_data)
82
+ print("The expected value of bets on the hypothesis being false given the data (under the assumption that the data is a valid observation and not due to noise or error) is:", format(expected_value_of_bets_on_hypothesis_being_false_given_data, ".2f"))
83
+
84
+ # Get the maximum expected value of bets given the data
85
+ max_expected_value_of_bets_given_data = max(expected_value_of_bets_on_hypothesis_being_true_given_data, expected_value_of_bets_on_hypothesis_being_false_given_data)
86
+
87
+ # Calculate the expected value of on the hypothesis being true given data NOT being observed
88
+ expected_value_of_bets_on_hypothesis_being_true_given_not_data = (payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true * p_of_hypothesis_being_true_given_not_data) + (payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false * p_of_hypothesis_being_false_given_not_data)
89
+ print("\nThe expected value of bets on the hypothesis being true given data NOT being observed (i.e., the data/evidence is not what you expected it to be) is:", format(expected_value_of_bets_on_hypothesis_being_true_given_not_data, ".2f"))
90
+
91
+ # Calculate the expected value of on the hypothesis being false given data NOT being observed
92
+ expected_value_of_bets_on_hypothesis_being_false_given_not_data = (payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true * p_of_hypothesis_being_true_given_not_data) + (payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false * p_of_hypothesis_being_false_given_not_data)
93
+ print("The expected value of bets on the hypothesis being false given data NOT being observed (i.e., the data/evidence is not what you expected it to be) is:", format(expected_value_of_bets_on_hypothesis_being_false_given_not_data, ".2f"))
94
+
95
+ # Get the maximum expected value of bets given data NOT being observed
96
+ max_expected_value_of_bets_given_not_data = max(expected_value_of_bets_on_hypothesis_being_true_given_not_data, expected_value_of_bets_on_hypothesis_being_false_given_not_data)
97
+
98
+ # Calculate the expected value with data/information
99
+ exp_value_without_data = max_value_of_bets
100
+ exp_value_with_data = (max_expected_value_of_bets_given_data * p_of_data) + (max_expected_value_of_bets_given_not_data * (1 - p_of_data))
101
+
102
+ # Calculate the expected value of information
103
+ exp_value_of_information = exp_value_with_data - exp_value_without_data
104
+ print("\nThe expected value of additional information is:", format(exp_value_of_information, ".2f"))
105
+
106
+
107
+ # Return posterior probabilities as a dictionary
108
+ if return_results:
109
+ # Create dictionarity of posterior probabilities
110
+ return_dict = {
111
+ "Posterior probability of the hypothesis being true given the data": round(p_of_hypothesis_being_true_given_data, 4),
112
+ "Posterior probability of the hypothesis being false given the data": round(p_of_hypothesis_being_false_given_data, 4),
113
+ "Posterior probability of the hypothesis being true given data NOT being observed": round(p_of_hypothesis_being_true_given_not_data, 4),
114
+ "Posterior probability of the hypothesis being false given data NOT being observed": round(p_of_hypothesis_being_false_given_not_data, 4),
115
+ }
116
+
117
+ # Add expected value of information if payout information is provided
118
+ if payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_true is not None and payoff_if_bet_on_hypothesis_being_true_and_hypothesis_is_false is not None and payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_true is not None and payoff_if_bet_on_hypothesis_being_false_and_hypothesis_is_false is not None:
119
+ return_dict["Expected value of payoffs on the hypothesis being false given the data"] = round(expected_value_of_bets_on_hypothesis_being_false_given_data, 2)
120
+ return_dict["Expected value of payoffs on the hypothesis being true given the data"] = round(expected_value_of_bets_on_hypothesis_being_true_given_data, 2)
121
+ return_dict["Expected value of payoffs on the hypothesis being false given data NOT being observed"] = round(expected_value_of_bets_on_hypothesis_being_false_given_not_data, 2)
122
+ return_dict["Expected value of payoffs on the hypothesis being true given data NOT being observed"] = round(expected_value_of_bets_on_hypothesis_being_true_given_not_data, 2)
123
+ return_dict["Expected value of payoffs without data"] = round(exp_value_without_data, 2)
124
+ return_dict["Expected value of payoffs with data"] = round(exp_value_with_data, 2)
125
+ return_dict["Expected value of information"] = round(exp_value_of_information, 2)
126
+
127
+ # Return dictionary
128
+ return return_dict
129
+
@@ -0,0 +1,2 @@
1
+ from .ProbabilityOfAtLeastOne import ProbabilityOfAtLeastOne
2
+ from .ProbabilityOfHypothesisGivenData import ProbabilityOfHypothesisGivenData
@@ -0,0 +1,186 @@
1
+ # Load packages
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ import pandas as pd
5
+ import seaborn as sns
6
+ import textwrap
7
+
8
+ # Declare function
9
+ def CreateCorrelatedSIPs(mean_of_variable_1,
10
+ std_of_variable_1,
11
+ mean_of_variable_2,
12
+ std_of_variable_2,
13
+ correlation,
14
+ number_of_samples=10000,
15
+ variable_1_name='Variable 1',
16
+ variable_2_name='Variable 2',
17
+ # Scatterplot arguments
18
+ show_scatterplot=True,
19
+ dot_fill_color="#999999",
20
+ title_for_plot="Simulation Results",
21
+ subtitle_for_plot="Showing the correlation between two variables",
22
+ caption_for_plot=None,
23
+ data_source_for_plot=None,
24
+ x_indent=-0.128,
25
+ title_y_indent=1.125,
26
+ subtitle_y_indent=1.05,
27
+ caption_y_indent=-0.3):
28
+ """
29
+ This function creates a scatterplot of two variables with a specified correlation.
30
+
31
+ Args:
32
+ mean_of_variable_1 (float): The mean of the first variable.
33
+ std_of_variable_1 (float): The standard deviation of the first variable.
34
+ mean_of_variable_2 (float): The mean of the second variable.
35
+ std_of_variable_2 (float): The standard deviation of the second variable.
36
+ correlation (float): The correlation between the two variables.
37
+ number_of_samples (int, optional): The number of samples to generate. Defaults to 10000.
38
+ variable_1_name (str, optional): The name of the first variable. Defaults to 'Variable 1'.
39
+ variable_2_name (str, optional): The name of the second variable. Defaults to 'Variable 2'.
40
+ show_scatterplot (bool, optional): Whether to show the scatterplot. Defaults to True.
41
+ dot_fill_color (str, optional): The color of the dots in the scatterplot. Defaults to '#999999'.
42
+ title_for_plot (str, optional): The title of the plot. Defaults to 'Simulation Results'.
43
+ subtitle_for_plot (str, optional): The subtitle of the plot. Defaults to 'Showing the correlation between two variables'.
44
+ caption_for_plot (str, optional): The caption of the plot. Defaults to None.
45
+ data_source_for_plot (str, optional): The data source of the plot. Defaults to None.
46
+ x_indent (float, optional): The x-indent of the plot. Defaults to -0.128.
47
+ title_y_indent (float, optional): The y-indent of the title. Defaults to 1.125.
48
+ subtitle_y_indent (float, optional): The y-indent of the subtitle. Defaults to 1.05.
49
+ caption_y_indent (float, optional): The y-indent of the caption. Defaults to -0.3.
50
+ """
51
+
52
+ # Create a z-scored variable for the first variable
53
+ variable_1 = np.random.normal(
54
+ loc=0,
55
+ scale=1,
56
+ size=number_of_samples
57
+ )
58
+
59
+ # Create a z-scored variable for the second variable
60
+ variable_2 = np.random.normal(
61
+ loc=0,
62
+ scale=1,
63
+ size=number_of_samples
64
+ )
65
+
66
+ # If correlation is provided, force the correlation between the two variables
67
+ if correlation is not None:
68
+ variable_2 = variable_1 * correlation + (1 - correlation**2) ** 0.5 * variable_2
69
+
70
+ # Convert the z-scored variables to the original scale
71
+ variable_1 = variable_1 * std_of_variable_1 + mean_of_variable_1
72
+ variable_2 = variable_2 * std_of_variable_2 + mean_of_variable_2
73
+
74
+ # Create a dataframe
75
+ dataframe = pd.DataFrame({
76
+ variable_1_name: variable_1,
77
+ variable_2_name: variable_2
78
+ })
79
+
80
+ # Calculate the correlation between the two variables
81
+ simulated_correlation = dataframe[variable_1_name].corr(dataframe[variable_2_name])
82
+ print("Correlation between the two variables in the simulated data: ", simulated_correlation)
83
+
84
+ # Show the summary statistics of the dataframe
85
+ simulation_summary = dataframe.describe()
86
+ print("Summary statistics of the simulated data:")
87
+ print(simulation_summary)
88
+
89
+ # If scatterplot requested, generate plot
90
+ if show_scatterplot:
91
+ ax = sns.scatterplot(
92
+ data=dataframe,
93
+ x=variable_1_name,
94
+ y=variable_2_name,
95
+ alpha=0.5,
96
+ color=dot_fill_color
97
+ )
98
+
99
+ # Remove top and right spines, and set bottom and left spines to gray
100
+ ax.spines['top'].set_visible(False)
101
+ ax.spines['right'].set_visible(False)
102
+ ax.spines['bottom'].set_color('#666666')
103
+ ax.spines['left'].set_color('#666666')
104
+
105
+ # Format tick labels to be Arial, size 9, and color #666666
106
+ ax.tick_params(
107
+ which='major',
108
+ labelsize=9,
109
+ color='#666666'
110
+ )
111
+
112
+ # Set the title with Arial font, size 14, and color #262626 at the top of the plot
113
+ ax.text(
114
+ x=x_indent,
115
+ y=title_y_indent,
116
+ s=title_for_plot,
117
+ # fontname="Arial",
118
+ fontsize=14,
119
+ color="#262626",
120
+ transform=ax.transAxes
121
+ )
122
+
123
+ # Set the subtitle with Arial font, size 11, and color #666666
124
+ ax.text(
125
+ x=x_indent,
126
+ y=subtitle_y_indent,
127
+ s=subtitle_for_plot,
128
+ # fontname="Arial",
129
+ fontsize=11,
130
+ color="#666666",
131
+ transform=ax.transAxes
132
+ )
133
+
134
+ # Move the y-axis label to the top of the y-axis, and set the font to Arial, size 9, and color #666666
135
+ ax.yaxis.set_label_coords(-0.1, 0.99)
136
+ ax.yaxis.set_label_text(
137
+ textwrap.fill(variable_2_name, 30, break_long_words=False),
138
+ # fontname="Arial",
139
+ fontsize=10,
140
+ color="#666666",
141
+ ha='right'
142
+ )
143
+
144
+ # Move the x-axis label to the right of the x-axis, and set the font to Arial, size 9, and color #666666
145
+ ax.xaxis.set_label_coords(0.99, -0.1)
146
+ ax.xaxis.set_label_text(
147
+ textwrap.fill(variable_1_name, 30, break_long_words=False),
148
+ # fontname="Arial",
149
+ fontsize=10,
150
+ color="#666666",
151
+ ha='right'
152
+ )
153
+
154
+ # Add a word-wrapped caption if one is provided
155
+ if caption_for_plot != None or data_source_for_plot != None:
156
+ # Create starting point for caption
157
+ wrapped_caption = ""
158
+
159
+ # Add the caption to the plot, if one is provided
160
+ if caption_for_plot != None:
161
+ # Word wrap the caption without splitting words
162
+ wrapped_caption = textwrap.fill(caption_for_plot, 110, break_long_words=False)
163
+
164
+ # Add the data source to the caption, if one is provided
165
+ if data_source_for_plot != None:
166
+ wrapped_caption = wrapped_caption + "\n\nSource: " + data_source_for_plot
167
+
168
+ # Add the caption to the plot
169
+ ax.text(
170
+ x=x_indent,
171
+ y=caption_y_indent,
172
+ s=wrapped_caption,
173
+ # fontname="Arial",
174
+ fontsize=8,
175
+ color="#666666",
176
+ transform=ax.transAxes
177
+ )
178
+
179
+ # Show plot
180
+ plt.show()
181
+
182
+ # Clear plot
183
+ plt.clf()
184
+
185
+ # Return the dataframe
186
+ return dataframe
@@ -1,3 +1,4 @@
1
+ from .CreateCorrelatedSIPs import CreateCorrelatedSIPs
1
2
  from .CreateMetalogDistributionFromPercentiles import CreateMetalogDistributionFromPercentiles
2
3
  from .CreateMetalogDistribution import CreateMetalogDistribution
3
4
  from .CreateSIPDataframe import CreateSIPDataframe
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: analysistoolbox
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: A collection tools in Python for data collection and processing, statistics, analytics, and intelligence analysis.
5
5
  Home-page: https://github.com/KyleProtho/AnalysisToolBox/tree/master/analysistoolbox
6
6
  Author: Kyle Protho
@@ -87,7 +87,9 @@ analysistoolbox/predictive_analytics/__init__.py
87
87
  analysistoolbox/prescriptive_analytics/CreateContentBasedRecommender.py
88
88
  analysistoolbox/prescriptive_analytics/__init__.py
89
89
  analysistoolbox/probability/ProbabilityOfAtLeastOne.py
90
+ analysistoolbox/probability/ProbabilityOfHypothesisGivenData.py
90
91
  analysistoolbox/probability/__init__.py
92
+ analysistoolbox/simulations/CreateCorrelatedSIPs.py
91
93
  analysistoolbox/simulations/CreateMetalogDistribution.py
92
94
  analysistoolbox/simulations/CreateMetalogDistributionFromPercentiles.py
93
95
  analysistoolbox/simulations/CreateSIPDataframe.py
@@ -12,7 +12,7 @@ setup(
12
12
  long_description=long_description,
13
13
  long_description_content_type='text/markdown',
14
14
  url="https://github.com/KyleProtho/AnalysisToolBox/tree/master/analysistoolbox",
15
- version='2.2.1',
15
+ version='2.2.2',
16
16
  author='Kyle Protho',
17
17
  author_email='kyletprotho@gmail.com',
18
18
  license='GNU GPLv3',
@@ -1 +0,0 @@
1
- from .ProbabilityOfAtLeastOne import ProbabilityOfAtLeastOne