U
    mh	                     @   s   d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	 d dl
mZ dee edddZee eeddf dd	d
Ze	dZdee eee  ee eee dddZdee eee  ee eee dddZdS )    N)Random)	GeneratorIterableOptionalSequenceTypeVarrandom)r	   returnc                 C   s   | d krt } | ddS )Ng        g      ?)
mod_randomuniformr    r   `/var/www/html/peyman_registration/venvv2/lib/python3.8/site-packages/faker/utils/distribution.pyrandom_sample
   s    r   )itr
   c                 c   s    d}| D ]}||7 }|V  qd S )Nr   r   )r   totalxr   r   r   cumsum   s    r   T   )apr	   lengthr
   c                    s   |d krt }|d k	stt| t|ks,tt| |ks@tdg }t| }t|}t|D ]f}tt|}|d   fdd|D }	t|d}
t	|	|
}|| }|
| || || q\|S )NzCYou can't request more unique samples than elements in the dataset.c                    s   g | ]}|  qS r   r   .0inormalr   r   
<listcomp>/   s     z/choices_distribution_unique.<locals>.<listcomp>r   )r   AssertionErrorlenlistrangetupler   r   bisectbisect_rightappendpop)r   r   r	   r   choicesitemsprobabilitiesr   cdfcdf2uniform_sampleidxitemr   r   r   choices_distribution_unique   s&    


r1   c                    s   |d krt }|d k	r(t| t|ks(tt|dr`|dkrN|d krN|| gS |j| ||dS n|g }|d kr|tdt| }tt	|}|d   fdd|D }t
|D ],}t|d}t||}	| |	 }
||
 q|S d S )Nr)   r   )weightskr   c                    s   g | ]}|  qS r   r   r   r   r   r   r   R   s     z(choices_distribution.<locals>.<listcomp>r   )r   r!   r    hasattrchoicer)   	itertoolsrepeatr"   r   r#   r   r%   r&   r'   )r   r   r	   r   r)   r,   r-   r   r.   r/   r0   r   r   r   choices_distribution9   s(    

r8   )N)Nr   )Nr   )r%   r6   r	   r   typingr   r   r   r   r   faker.generatorr   floatr   r   r   intr1   r8   r   r   r   r   <module>   s2     
"  
