Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a continuous distribution in python
    primarykey
    data
    text
    <p>I am having trouble creating a continuous distribution in python and its really beginning to annoy me. I have read and re-read <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html#scipy.stats.rv_continuous" rel="nofollow">this python guide (scipy guide)</a> and it hasn't helped my problem. </p> <p>My code reads:</p> <pre><code>import sys import scipy.stats import numpy def CDF_Random(N,NE,E,SE,S,SW,W,NW,Iterations): WindDir = [0,45,90,135,180,225,270,315] Freq = N,NE,E,SE,S,SW,W,NW mydist = scipy.stats.rv_continuous(#My problem is what to write here) cdf_rand=mydist.rvs(size=Iterations) return (cdf_rand) if __name__ == '__main__': N = float(sys.argv[1]) NE = float(sys.argv[2]) E = float(sys.argv[3]) SE = float(sys.argv[4]) S = float(sys.argv[5]) SW = float(sys.argv[6]) W = float(sys.argv[7]) NW = float(sys.argv[8]) Iterations = float(sys.argv[9]) numpy.set_printoptions(threshold=Iterations) sys.stdout.write(str(CDF_Random(N,NE,E,SE,S,SW,W,NW,Iterations))) </code></pre> <p>As you can see if you read the code, my problem is knowing what to put in the brackets to create the continuous distribution. <code>scipy.stats.rv_continuous(#what to put here)</code>.</p> <p>I have tried alot of different things, mainly the ones suggested in <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html#scipy.stats.rv_continuous" rel="nofollow">this document(scipy guide)</a>, like setting my upper and lower range values <code>a=,b=</code> setting it to a <code>pdf</code> or a <code>ppf</code>. I have tried <code>[arrays]</code> using the ones that are entered in the command line or just ones I wrote into the code itself. </p> <p>From the command line I run this command <code>python C:\Users\...\CDF.py 0.01 0.01 0.01 0.01 0.01 0.93 0.01 0.01 10</code> and every time I get;<code>RuntimeError:maximum recursion depth exceeded</code> I have tried resetting the recursion depth to different values but this didn't work or crashed python. <code>sys.setrecursionlimit(10000)</code></p> <p>So basically what should be entered in the brackets after <code>scipy.stats.rv_continuous()</code> to create a continuous distribution of the <code>[array]</code> called <code>WindDir</code> for a given distribution <code>freq</code>? I have honestly had a good look through Google and the stackoverflow website, searching using keywords, keywords with tags and tags alone and couldn't find a solution. </p> <p><strong>Edit 1-Desired outcome</strong> I would like the output to be a real number between <code>0,360</code> or <code>0,2pi</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload