This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def color_large_value_red(val): | |
| """ | |
| Takes a scalar and returns a string with | |
| the css property `'color: red'` for absolute values > 0.5, | |
| black otherwise. | |
| """ | |
| try: | |
| float_val = float(val) | |
| color = 'red' if (abs(float_val) > 0.4) and (float_val != 1) else 'black' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def highlight_row(row): | |
| """Highlight row with red color for variables with p < 0.05""" | |
| color = '' | |
| if row['P>|t|'] < 0.05: | |
| color = 'red' | |
| return ['color: %s' % color] * len(row.values) | |
| df_result.style.apply(custom_style, axis=1).to_excel('results.xlsx') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Qualtrics.SurveyEngine.addOnload(function() | |
| { | |
| /*Place your JavaScript here to run when the page loads*/ | |
| var currentTime = new Date(); | |
| var hours = currentTime.getHours(); | |
| var minutes = currentTime.getMinutes(); | |
| var current_time_in_minutes = hours * 60 + minutes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # you can pass command line argument as you normally would: | |
| $ python -m cProfile -o mcmc_hmm.prof mcmc_hmm.py estimate --niter=20000 | |
| # Use SnakeViz (install with $ pip install snakeviz) to view the profile results: | |
| $ snakeviz profile.prof |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| HDFStore = pd.HDFStore(os.path.join(home, 'Data/Name.ph5'), mode='r') | |
| df = HDFStore['/df'] | |
| HDFStore.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def print_results(mean_post, std_post): | |
| """Create Pandas DataFrame with results""" | |
| num_digits = 3 | |
| result_table = mean_post.round(num_digits).astype(str) | |
| str_std_post = std_post.round(num_digits).astype(str) | |
| t_stat = mean_post / std_post | |
| for col in result_table: | |
| """Add more 0's for 0.0""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://data.stackexchange.com/stackoverflow/query/918019 | |
| SELECT DISTINCT Cast(Posts.CreationDate as Date), COUNT(DISTINCT OwnerUserId) | |
| FROM Posts | |
| GROUP BY Cast(Posts.CreationDate as Date) | |
| Order BY Cast(Posts.CreationDate as Date); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style> | |
| .Skin .SkinInner {min-width: 1000px!important;} | |
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| install.packages("pwr") | |
| library(pwr) | |
| Rsq_A = 0.302 | |
| Rsq_AB = 0.309 | |
| f2 = (Rsq_AB - Rsq_A) / (1 - Rsq_AB) | |
| f2 | |
| pwr.f2.test(u=5, v=4000, f2=f2, sig.level=0.05) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Qualtrics.SurveyEngine.addOnReady(function() | |
| { | |
| var questionID = this.questionId; | |
| var textbox =$('QR~' + questionID); | |
| textbox.insert({after: '<br><span style="font-size: 14.4px;">Your word count is: </span><span id="wordCountDisplay">0</span>'}); var display = $('wordCountDisplay'); | |
| var display = $('wordCountDisplay'); | |
| var that = this; | |
| function countWords(s){ |