-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
195 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
This file demonstrates writing tests using the unittest module. These will pass | ||
when you run "manage.py test". | ||
Replace this with more appropriate tests for your application. | ||
""" | ||
|
||
from django.test import TestCase | ||
|
||
|
||
class SimpleTest(TestCase): | ||
def test_basic_addition(self): | ||
""" | ||
Tests that 1 + 1 always equals 2. | ||
""" | ||
self.assertEqual(1 + 1, 2) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.conf.urls import patterns, include, url | ||
|
||
from rm.stats.views import PowerCalcView | ||
|
||
urlpatterns = patterns( | ||
'', | ||
url(r'power-calc$', PowerCalcView.as_view(), name='power-calc'), | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Utility functions for statistical calculations on Randomise Me | ||
""" | ||
from statsmodels.stats.power import tt_ind_solve_power | ||
|
||
def nobs(estimated=None, impressive=None): | ||
""" | ||
Given the estimated and impressive figures, | ||
conduct a power calculation and return the | ||
number of required observations. | ||
Arguments: | ||
- `estimated`: int | ||
- `impressive`: int | ||
Return: int | ||
Exceptions: None | ||
""" | ||
estimated, impressive = float(estimated), float(impressive) | ||
if abs(estimated/impressive) > 1: | ||
effect_size = abs(estimated/impressive) | ||
else: | ||
effect_size = abs(impressive/estimated) | ||
num = tt_ind_solve_power(effect_size=effect_size, alpha=0.05, power=0.8, nobs1=None) | ||
return int(num) * 2 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
Views to do server-side stats help | ||
""" | ||
from django.http import HttpResponse | ||
from django.views.generic import View | ||
|
||
from rm.stats.utils import nobs | ||
|
||
class PowerCalcView(View): | ||
""" | ||
Run a power calculation | ||
""" | ||
def post(self, *args, **kwargs): | ||
""" | ||
Calculate the required number of participants | ||
for the variables given | ||
Return: str(int) | ||
Exceptions: None | ||
""" | ||
estimated, impressive = [int(self.request.POST.get(k)) | ||
for k in ['impressive', 'estimated']] | ||
num = nobs(estimated=estimated, impressive=impressive) | ||
return HttpResponse(str(num)) |
This file contains 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
This file contains 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
This file contains 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