C#, numerical calculation – random numbers, Monte Carlo (Miser) calculation method and source program

Monte Carlo samples a user-supplied ndim-dimensional function func in a rectangular volume specified by regn[0..2 * ndim – 1], a vector consisting of ndim “lower-left” coordinates of the region followed by ndim “upper-right” coordinates.The function is sampled a total of npts times, at locations determined by the method of recursive stratified sampling.The mean value of […]

C#, numerical calculation – calculation method and source program of Monte Carlo (Monte Carlo) integration method

1 Text format using System; namespace Legalsoft.Truffer { /// /// Monte Carlo (Monte Carlo) integration method /// Monte Carlo integration /// Object for Monte Carlo integration of one or /// more functions in an ndim-dimensional region /// public abstract class MCintegrate { private int n { get; set; } private int ndim { get; set; […]

The backend asks why the frontend numerical precision is lost?

I believe that all front-end partners will inevitably use JavaScript to process numeric related operations in their daily work, such as numeric calculation strong>, Keep specified decimal places, The value returned by the interface is too large, etc. These operations may cause the original normal value to be displayed in JavaScript code> does behave abnormally […]

C#, numerical calculation – calculation method and implementation code of 64-bit hash table

1 Text format using System; namespace Legalsoft.Truffer { public class HashAll { publicHashAll() { } /// /// Pseudo-DES hashing of the 64-bit word(lword, rword). Both 32-bit arguments /// are returned hashed on all bits. /// /// /// public static void psdes(ref uint lword, ref uint rword) { const int NITER = 2; uint[] c1 = […]

Spherical harmonic function analysis Actual particle shape formula derivation and numerical implementation Part 3 Particle shape analysis

Reference: 3D quantitative shape analysis on form, roundness, and compactness with μCT https://www.sciencedirect.com/science/article/pii/S0032591015302345 1. Types of shape analysis 1. Macroscopic shape (Aspect ratio, AR aspect ratio) Transpose the voxels of the particles, Corresponding to the directions respectively, ,,is the average of the two. Transpose code: % Transpose into a format in which x, y, and […]

C# Example of numerical formatting method that dynamically retains decimal places – retaining two non-zero digits after the decimal point for rounding

C# Example of numerical formatting method that dynamically retains decimal places – retaining two non-zero digits after the decimal point for rounding 1. Function introduction 2. Code cases 3. Output results 4. Encapsulation extension method 5. Console call 6. Other method addresses 1. Function introduction 1. If the input number is an integer, the string […]

Spherical harmonic function (Spherical harmonic function) analysis of actual particle shape formula derivation and numerical implementation Part 1

1. Formula derivation The spherical harmonic function is a set of basis functions defined on the unit sphere and is a type of Fourier expansion. The spherical harmonic function was first used in the calculation of electromagnetic fields, nuclear physics, and planetary gravity fields. Garboczi (2002) was the first to use it based on This […]