2

I'm teaching a discrete math course in which I've incorporated a programming component. We have been using Python Notebooks through Jupyter.

We're coming up on a section in probability theory, and I would like to provide them with a "mystery random variable:" I want students to be able to sample the random variable without knowing how it is defined.

I don't know the best way to implement this, and was hoping someone could provide a suggestion. Here are the features that I want:

  • I define one or several random variables (preferably in Python),
  • The students should be able to sample from the random variable in a Python notebook (so they can do experimentation with it), but
  • the students should not be able to see the code that defines the random variable.
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
D Wiggles
  • 133
  • 4
  • 2
    It’s not really feasible to hide Python source code. – mkrieger1 Oct 26 '20 at 21:18
  • 4
    You could try to obfuscate it, or you could write a web service with a client module. – mkrieger1 Oct 26 '20 at 21:23
  • 1
    Yes to a web service, then you’re not revealing any source code. – DisappointedByUnaccountableMod Oct 26 '20 at 21:58
  • Give them a simple module with a simple interface, but under the hood use a simple socket service to another program running on your network (in a classroom setting), or on a "cloud server" somewhere (many are free). I don't know what you could do with a non-networked student though. It doesn't matter if they look at your socket code, though that's not the focus of your course. – RufusVS Oct 26 '20 at 23:07

1 Answers1

0

If this system support modules, you could define a function returning several random values (for instance giving an index) or several functions returning each a random value and put these functions in one module that your students don't have access to. They could import the .pyc module and use it but not seen the codes inside it.

dspr
  • 2,383
  • 2
  • 15
  • 19