Jump to content

Creating a probability node


RTHMan

Recommended Posts

@RTHMan find those Code's in Fee Lib
 

#if 0
    #include <mathdeep.vfl>
#else
    function
    int sample_pdf(
        float pdf[];
        float uniform_rand;
        ) {
        float cdf[]= create_cdf(pdf);
        return sample_cdf(cdf, uniform_rand);
    }
    
    function
    float random_uniform(
        float seed;
        int offset;
        int core;
        ) {
        if ( core == -1 ) {
            return offset;
        } else if ( core == 0 ) {
            return random(seed, offset);
        } else if ( core == 1 ) {
            return random_brj(seed, offset);
        } else if ( core == 2 ) {
            return random_sobol(seed, offset);
        } else {
            return -1;
        }
    }
#endif

int classes = (chi("../autoClasses") ? chi("numclasses") : chi("../classes")) - 1;

float pdf[];
resize(pdf, classes);

for (int i = classes; i > -1; --i) {
    pdf[i] = chf("../possibility" + itoa(i+1));
}
i@varient = sample_pdf(pdf, select(chi("../randtype"), random_uniform(chf('../seed'), @ptnum, chi("../randtype")-1), @ptnum/(@numpt-0.99999)));

//float cdf[]= create_cdf(pdf);
//create_pdf_fee();
//i@varient = sample_pdf(pdf, chf('a'));

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...