Questions tagged [bernoulli-numbers]

In mathematics, the Bernoulli numbers Bn are a sequence of rational numbers with deep connections to number theory. The values of the first few Bernoulli numbers are B0 = 1, B1 = ±1⁄2, B2 = 1⁄6, B3 = 0, B4 = −1⁄30, B5 = 0, B6 = 1⁄42, B7 = 0, B8 = −1⁄30.

In mathematics, the Bernoulli numbers Bn are a sequence of rational numbers with deep connections to number theory. The values of the first few Bernoulli numbers are

B0 = 1, B1 = ±1⁄2, B2 = 1⁄6, B3 = 0, B4 = −1⁄30, B5 = 0, B6 = 1⁄42, B7 = 0, B8 = −1⁄30.

If the convention B1=−1⁄2 is used, this sequence is also known as the first Bernoulli numbers (A027641 / A027642 in OEIS); with the convention B1=+1⁄2 is known as the second Bernoulli numbers (A164555 / A027642 in OEIS). Except for this one difference, the first and second Bernoulli numbers agree. Since Bn=0 for all odd n>1, and many formulas only involve even-index Bernoulli numbers, some authors write Bn instead of B2n.

More Details

16 questions
13
votes
1 answer

What is the most efficient way of finding the first element of the ith row when A[i,j]=j*(A[i-1,j+1]-A[i-1,j])?

When the first row is 1, 1/2 , 1/3 .... Here's an image to support the question. Does there exist a more efficient approach than the naive O(n^2) approach? I came across this when studying Bernoulli numbers and then consequently on reaching…
Paagalpan
  • 1,261
  • 2
  • 16
  • 25
6
votes
1 answer

Julia, function to replicate "rbinom()" in R

I have dug around and googled but not found an example. I'm sure Julia has a powerful function (in base?) to generate random binomial (bernoulli?) "successes" with a given probability. I can't find it or figure out how to do the equivalent to in…
Jim Maas
  • 1,481
  • 2
  • 16
  • 36
2
votes
1 answer

Bernoulli function in Haskell

I want to write a bernoulli function bernoulli:: Integer -> Rational in haskell, using the following algorithm for calculating the bernoulli number for a given integer. the functions "frac" and "binom" are used to calculate the binomial in the…
yakubu
  • 23
  • 3
1
vote
1 answer

Calculating the Cosine/Sine/Tangent of an angle using Bernoulli Series Expansion in C++ without using outside libraries

I can't seem to find the error. I need a fresh pair of eyes. I am trying to calculate the values of Cos/Sin/Tan of an angle in C++ without using built-in functions or libraries. These are the only requirements. This is what I have gotten so far: I…
1
vote
0 answers

Bernoulli numbers in R

I am a new in R and I couldn't find any function to calculate Bernoulli numbers without using any loops. I will be really appreciated if someone explain the mentality of calculation.
FeyzaR
  • 11
  • 1
1
vote
1 answer

How to efficiently perform billions of Bernoulli extractions using numpy?

I am working at a thesis about epidemiology, and I have to simulate a SI epidemic in a temporal network. At each time step there's a probability ~ Bernoulli(beta) to perform an extraction between an infected and a susceptible node. I am using…
1
vote
1 answer

Ada95: Recursive function for Bernoulli numbers

I'm trying to code a function that calculates the N'th value of the positive Bernouille numbers. I want to do it with this recursive formula: What I've tried so far: function Get_B(N : in Integer) return Float is X,Bn,Bk:Float; begin …
Ludd
  • 53
  • 5
1
vote
2 answers

Bernoulli-number method wrong for input > 1

I'm trying to implement a method that returns the n:th bernoulli number, like so: Object subclass: #Bernoulli. Bernoulli class extend [ "****************************************************** * Psuedo code for bernoulli method I'm…
Mossmyr
  • 909
  • 2
  • 10
  • 26
0
votes
1 answer

Sampling from exponential Bernoulli

Bernoulli is a probability distribution. I need to sample from an exponential bernoulli and returns a binary value (i.e. either 0 or 1). I found this algorithm exponential bernoulli sampling and i want to implement it but i do not understand the…
0
votes
1 answer

Issues with accuracy with Bernoulli Number generator in java

I've created some code that generates the Bernoulli Numbers based off of formula 33 on MathWorld. This is given at https://mathworld.wolfram.com/BernoulliNumber.html and should work for all integers n but it diverges from the expected results…
Babai08
  • 3
  • 3
0
votes
0 answers

What is the distribution of n correlated Bernoulli variables?

For independent Bernoulli X_1, X_2, ..., X_n, the maximum distribution is Y=max{X_1,X_2,⋯,X_n }~Bernoulli(1-∏_(i=1)^n▒(1-p_i ) ) But for correlated Bernoulli, what is the maximum distribution? any advice? Many thanks.
0
votes
1 answer

Random matrix with diagonal entries 0's and all other entries are 0's and 1's

I tried using the rbern function in R but I realized that the diagonal entries are not all 0's.
0
votes
1 answer

Storing bernoulli number is giving overflow error in python even after using decimal module

I'm trying to store first 1000 bernoulli numbers in a dictionary in python. At first I just stored the numbers as it is. So I got an overflow error. Now after going through previous answers I thought of using decimal module. So here it…
Bharat
  • 1,044
  • 15
  • 34
0
votes
1 answer

Java- Implementation of Bernoulli Numbers in new method

I am having trouble editing an existing implementation of Bernoulli numbers in Java which has the BigRational helper class. The original implementation puts the calculation of the Bernoulli numbers inside the Main method. I made a new class to…
Axion004
  • 943
  • 1
  • 11
  • 37
0
votes
1 answer

Bernoulli numbers with Boost are different from Mathematica

In the latest Boost, there is a function to compute the Bernoulli number, but I miss what it does exactly. For example, Mathematica, Python mpmath and www.bernoulli.org say that: BernoulliB[1] == -1/2 but the boost version #include…
linello
  • 8,451
  • 18
  • 63
  • 109
1
2