POV-Ray : Newsgroups : povray.advanced-users : Problems using/graphing internal sum function Server Time
15 Oct 2024 08:43:59 EDT (-0400)
  Problems using/graphing internal sum function (Message 1 to 2 of 2)  
From: Bald Eagle
Subject: Problems using/graphing internal sum function
Date: 7 Nov 2022 19:50:00
Message: <web.6369a6d45447eee1f9dae3025979125@news.povray.org>
Something popped into my head recently, and now I am trying to write an equation
for the cumulative distribution function of a probability density function using
sum ().

I'm using a normal distribution, but when I try to graph the summation of the
values over the range of 0 through 5, I get unexpected results.

I tried using N, then since i is related to N, I tried seeing what that result
looked like, and then I averaged them...  It makes no sense that a graph of a
running tally starts to decrease, instead of being non-decreasing and
right-continuous like it should be.

#declare NDist = function (N, mu, sigma)
{1/(sigma*sqrt(tau))*exp(-0.5*pow((N-mu)/sigma,2))}


 #declare NDist_cdf = function (N, mu, sigma) {sum (i, 0, N, NDist (N, mu,
sigma))}

 #declare NDist_cdf2 = function (N, mu, sigma) {sum (i, 0, N, NDist (i, mu,
sigma))}

 #declare NDist_cdf3 = function (N, mu, sigma) {sum (i, 0, N, NDist ((i+N)/2,
mu, sigma))}

Has anyone ever tried to use sum () to graph a running tally of a function, or
have any idea what I'm doing wrong?

Have I broken POV-Ray _*AGAIN*_???!


Post a reply to this message


Attachments:
Download 'importancesamplingtest1.png' (67 KB)

Preview of image 'importancesamplingtest1.png'
importancesamplingtest1.png


 

From: Bald Eagle
Subject: Re: Problems using/graphing internal sum function
Date: 7 Nov 2022 21:55:00
Message: <web.6369c3f3a3234851f9dae3025979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> Have I broken POV-Ray _*AGAIN*_???!

Nope, just me glossing over the fact that sum doesn't have a step value, because
its default is one.
Tired brain does not listen to very little inner voice pointing out exactly
that.

"The iteration variable is incremented by one for each step, but its initial and
final value may be any value"
https://wiki.povray.org/content/Reference:Function


So, what I needed to do was:

#declare NDist_cdf2 = function (N, mu, sigma) {sum (i, 0, N*100, NDist (i/100,
mu, sigma))}

So at present, a can take a pdf, get the cdf, and even transpose it to its
inverse function.  :)

Now to figure out how to properly weigh the sample points and I think I should
have a semi-workable / partial importance sampling algorithm.

Like ...  7 years after clipka wanted one.

I'm glad I wrote that equation graphing scene way back when, but I also think I
need to debug my axis-labeling code.


Post a reply to this message


Attachments:
Download 'importancesamplingtest1.png' (64 KB)

Preview of image 'importancesamplingtest1.png'
importancesamplingtest1.png


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.