## Introduction

A galactic survey encompasses a collection of observable galaxies with respective redshifts that have been obtained for a given spectroscopic area of the sky. Using a cosmological model, we can convert the redshifts into light-travel times and, by slicing the survey into small redshift buckets, compute a curve of galactic density over time.

Because foreground galaxies obstruct the images of more distant galaxies, we simulate the theoretical galactic density curve using an average galactic radius. By comparing the galactic density curves of the simulation with that of the survey, we can assess the cosmologies.

We use the simulation to generate a uniform distribution of galaxies for each redshift bucket. We then compute the number of visible galaxies (i.e., those that are not covered by foreground galaxies) to derive the simulated galactic density curve. Our method requires only a cosmological model that relates distances to redshifts, a behavior for the galactic density, and the average galactic radius versus redshifts.

## Background

In the research paper "A Monte Carlo simulation for testing cosmological models", we consider two distinct cosmologies: the de Sitter flat-universe cosmology and the dichotomous cosmology.

The de Sitter cosmology is a solution to the Friedmann equation for an empty universe, without matter, dominated by a repulsive cosmological constant Lambda corresponding to a positive vacuum energy density.

The dichotomous cosmology consists of a static material world and an expanding luminous world.

For both cosmologies, the Hubble parameter is a physical constant which does not vary over time.

## Using the Code

The class *GalaxyCount.cs* does the job. The class *Galaxy.cs* is used to represent a galaxy. This class holds the position of the galaxy using astronomical spherical coordinates, and also has the associated radius of the galaxy.

In the header of *GalaxyCount.cs*, we specify both the galactic density and the average galactic radius at present time.

In the method `generateBucket()`

, we need to specify the behavior for the galactic density versus redshift.

```
//Behavior for the galactic density in the dichotomous cosmology
double densityZ = density0;
```

For the expanding Universe theory, the density increases by a factor (1+z)^{3} when looking back in the past.

```
// Behavior for the galactic density in the expanding Universe cosmology
double densityZ = Math.Pow(1+z,3)*density0;
```

We iterate from redshift z_{1} to redshift z_{n}, and generate N_{i} galaxies for each redshift bucket, and then determine for each galaxy whether it is obscured by foreground galaxies. Using this procedure, we obtain the simulated galactic counts for each redshift bucket.

The number of galaxies that we need to generate for each redshift bucket is determined as follows:

```
//Spectroscopic area of the simulation
specArea = 180.0 / Math.PI * (Math.Sin(theta_max) - Math.Sin(theta_min)) * (phi_max-phi_min) * 180.0 / Math.PI;
//Factor to convert volume of the spherical shell to the spectroscopic area of the simulation
nu = 4 * Math.PI * Math.Pow(180.0 / Math.PI, 2)/specArea;
//Volume of the spherical shell
double volume = 4.0/3.0*Math.PI*(Math.Pow(getDistance(z),3)-Math.Pow(getDistance(zprevious),3));
// Density function, which is equal to the present galactic density for
// the dichotomous cosmology, and density0*(1+z)^3 for the expanding Universe cosmology.
double densityZ = density0; //Math.Pow(1+z,3)*density0 for the expanding cosmology
// Number of galaxies to generate for a given redshift bucket
int numberGalaxies = (int)(densityZ*volume/nu);
```

For each galaxy, we generate the declination and right ascension angles with a uniform distribution. The radial distance is set to the light-travel time at redshift z_{i}.

To determine if galaxy B is hidden by foreground galaxy A, we need to check whether the actual distance between the projection of galaxy A into the plan of B and galaxy B itself is larger or smaller than the critical distance. If it is smaller, then galaxy B is determined to be hidden. Otherwise, B is visible.

```
//The actual distance between the projection of galaxy A into the plan of B and galaxy B itself.
public double galaxyDistance(Galaxy a, Galaxy b, double r)
{
double dist = Math.Sqrt(Math.Pow(r*Math.Cos(a.Theta)*Math.Cos(a.Phi)-
r*Math.Cos(b.Theta)*Math.Cos(b.Phi),2)+Math.Pow(r*Math.Cos(a.Theta)*Math.Sin(a.Phi)-
r*Math.Cos(b.Theta)*Math.Sin(b.Phi),2)+Math.Pow(r*Math.Sin(a.Theta)-r*Math.Sin(b.Theta),2));
return dist;
}
```

Because galactic surveys are obtained using an automated device, and an algorithm cannot identify a galaxy that is not isolated from other sources of light, the critical distance is calculated as follows:

```
//Critical distance to determine if galaxy B is hidden by galaxy A
public double criticalDistance(Galaxy a, Galaxy b)
{
return b.Radius + b.R / a.R * a.Radius;
}
```

Mathematical details for the algorithm are described in the article "A Monte Carlo simulation framework for testing cosmological models".