Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

356 Neutral

About jperalta

  • Rank
    Advanced Member
  1. 180 non-whitespace, 212 incl. whitespace   n=:<'no more' d=:,"1 b=:<'bottles of beer' o=:<'on the wall' t=:<'take one down, pass it around' c=:b,"_1~;/>:i.99 (|.c d o d c d t d b,"_1~o,"_1~n 0};/i.99),o,~b,~n,b,o,n,b,'go to the store and buy some more';99
  2. n=:<'no more' a=:(n,~<1)0}(>:(;"0)+)i.99 b=:<'bottles of beer' o=:<'on the wall' t=:<'take one down, pass it around' c=:(99#b),"0~{."1 a (|.c,"1 o,"1 c,"1 t,"1(}."1 a),"1 b,o),o,~b,~n,b,o,n,b,'go to the store and buy some more';99   201 non-whitespace, 230 whitespace characters in J. I could probably get it shorter but I've already forgotten how it works.
  3. jperalta

    Natural logarithms, exponential growth and C++

    Well, first, k should not be a function of population. It should be a constant. It is the fraction of the population that dies every year. Say 1/10 people in the model die every year, then k = 0.1, not 0.1 * current population. Second, if we look at our equation for population as a function of time... p(t) = (r/k) - (P_0 - (r/k))*exp(-k*t) we see that the lim t->infinity p(t) = r/k, because the second term will go to zero. This means that if your constant birth rate is 1,000 births per year and your death rate is 10% then the population for any sufficiently large value of t will be near to 10,000 people.
  4. jperalta

    Natural logarithms, exponential growth and C++

    [font="Arial"]p_0 is your population at time = 0, from your code it looks like you call it 'pop_at_start_of_periodint'. So what I would do is remove the birthdeathrate() function and change your population() function to look like... double r = constant population increase per year (for example 1000 births per year) double k = percentage of population killed per year (for example 0.30 -> 30% of the population dies every year) then double P = (r/k) + [/font](pop_at_start_of_periodint- (r/k)) *exp(-k*t) should give you a stable system.
  5. jperalta

    Natural logarithms, exponential growth and C++

    Your problem is that for a fixed growth rate r = births - deaths, if r > 0 the system explodes (diverges at t = infinity). If r < 0 then the system dies (converges to 0 at t = infinity). To make the system stable you need to model as a differential equation. Consider a population with initial population p_0, and every year there are r births and k% of the population dies. Our differential equation is p' = r - kp. The solution to this system with initial condition p(0) = p_0 is p(t) = r/k + (p_0 - r/k)*exp(-kt) This system is stable and for any initial condition p_0 will converge to p(infinity) = r/k.
  6. You may want to take a look at
  7. Look into algorithms like the LCG... [link][/link] and [link][/link] or multiple recursive generators (MRG). You should be able to find a free MRG implementation out there if you look for it.
  8. Daniel Webster College in Nashua, NH Sector Resource Management Airport and Airspace Capacity Management Senior Seminar in Media Images Public Speaking
  9. jperalta

    How Do Universally Uniqe IDs Work?

    Quote:Original post by fpsgamer I just looked that up the moment I posted :) .... does anyone the names of any alogrithms that are known to produce ids well? Its fairly exciting to think of what i could use it for in some apps. MD5 (badness), SHA-1 (badness), RIPE-MD (goodness), SHA-256 (goodness), if you need more look up 'hashing functions'
  10. jperalta

    Functional Programming

    Quote:Original post by Jack9 3.Is there good graphic libraries for functional programming languages? Nope. They exist, but I would put any Java lib or amateur C++ SDL wrapper's functionality over the FP SDL wrappers. This is patently false. There are OGL bindings for OCaml and F#/ can access managed directx just as easily as any other managed language can.
  11. jperalta

    Functional Programming

    Well, it looks like I posted my previous link wrong, so here it is again... Link
  12. jperalta

    Random numbers

    When generating random numbers from a to b there is always a 1/(b-a+1) chance of repeating any given number. The only solution to this is to test for equality and discard if the numbers are unequal. Potentially, this could run for quite a while, however it is highly unlikely. The probability of choosing a number, and then choosing that same number again is 1/10, three times is 1/100, four times 1/1000. Unless you are doing this quite a bit (generating hundreds of thousands of random numbers) you are unlikely to see any runs of more than 5 or 6 in a row. Making seven successive calls to rand() is not terribly slow and I wouldn't think it would cause your program to hang.
  13. jperalta

    Police Don't Have to Knock

    LessBread, your argument that "if there were officers killed in action due to having needed to knock to serve a warrant, they would have been in the article" is ridiculous. That article is clearly biased against the expansion of police powers, and is only giving examples in the defense of the author's point. Given that the author makes no reference to how many people have been killed in knock/no-knock raids and you find that an acceptable standard of evidence, what do you think of these cases? These are all cases of police officers being killed during the execution of drug-related search warrants. If using SWAT teams and executing no-knock warrants for drug-related searches saves the lives of the men and women who are dedicated to protecting us, then more power to them. "Jones was the 14th law enforcement officer to be killed enforcing the drug laws last year, according to Berneta Spence, director of research for the National Law Enforcement Officers Memorial Foundation in Washington, DC. "These 14 were responding to drug-related matters, serving drug warrants, or involved in a drug search," she told DRCNet. The foundation memorializes law enforcement officers killed in the line of duty each year with a May 13 vigil and a May 15 commemoration on National Law Officers Memorial Day. According to Spence, 55 officers have been killed enforcing the drug laws since 1995." 1 2 3 4 [Edited by - LessBread on June 16, 2006 6:41:26 PM]
  14. Quote:Original post by Joelvtx Is there an advantage to using the method in the code below... ... They both give the same result, but the top one seems like it would be easier to manage on bigger projects. Or are there situations where that is not true? Sorry for the noobish question......but then again.....I am a noob. The former method involves less namespace pollution, for example if you wanted to use the name 'cin' or 'endl' for an object in your program, you'll be assured as to which one you're getting if you don't just wholesale include a namespace. An optional way to get the best of both worlds is... using std::cout; using std::endl; ... cout << blah << endl; That way you know which items have been included from the std namespace and won't get namespace conflicts, but also don't have to type the fully qualified names of the things you'll be using.
  15. jperalta

    Learning Calculus for free?

    I highly recommend the following two books for teaching one's self calculus. I personally used the first to teach myself calculus the year before I took it in HS, and after seeing it here have recommended the second to others taking calculus and they've found it extremely helpful. Calculus Made Easy: Being a Very-Simplest Introduction to Those Beautiful Methods of Reckoning Which Are Generally Called by the Terrifying Names of the Differential Calculus Elementary Calculus: An Approach Using Infinitesimals
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!